From 648b73b585c54367b58006ee3803590a5dc56057 Mon Sep 17 00:00:00 2001
From: LeoMoulin
Date: Thu, 4 Apr 2024 16:54:11 +0200
Subject: [PATCH] Fix the implementation of externalCurriculum upload
---
.../Clyde/EndPoints/CurriculumController.java | 27 ++--
.../ExternalCurriculumRepository.java | 3 +-
.../Clyde/Services/UserCurriculumService.java | 13 +-
.../Clyde/Tables/ExternalCurriculum.java | 30 ++---
.../Clyde/Tables/InscriptionRequest.java | 1 -
frontend/src/Apps/Login.vue | 125 ++++++++++++++++--
frontend/src/rest/curriculum.js | 12 ++
7 files changed, 167 insertions(+), 44 deletions(-)
diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java
index 0fc0e4c..4be7ba9 100644
--- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java
+++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java
@@ -4,11 +4,11 @@ package ovh.herisson.Clyde.EndPoints;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
+import ovh.herisson.Clyde.Repositories.ExternalCurriculumRepository;
+import ovh.herisson.Clyde.Repositories.InscriptionRepository;
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
import ovh.herisson.Clyde.Services.*;
-import ovh.herisson.Clyde.Tables.Curriculum;
-import ovh.herisson.Clyde.Tables.Role;
-import ovh.herisson.Clyde.Tables.User;
+import ovh.herisson.Clyde.Tables.*;
import java.util.HashMap;
import java.util.Map;
@@ -23,15 +23,18 @@ public class CurriculumController {
private final UserCurriculumService userCurriculumServ;
private final CurriculumCourseService curriculumCourseServ;
-
+ private final InscriptionRepository ir;
private final UserService userServ;
- public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, UserCurriculumService userCurriculumServ, CurriculumCourseService curriculumCourseServ, UserService userServ){
+ private final ExternalCurriculumRepository ecr;
+ public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, UserCurriculumService userCurriculumServ, CurriculumCourseService curriculumCourseServ, InscriptionRepository ir, UserService userServ, ExternalCurriculumRepository ecr){
this.curriculumServ = curriculumServ;
this.authServ = authServ;
this.userCurriculumServ = userCurriculumServ;
this.curriculumCourseServ = curriculumCourseServ;
+ this.ir = ir;
this.userServ = userServ;
+ this.ecr = ecr;
}
@GetMapping("/curriculum/{id}")
@@ -116,13 +119,12 @@ public class CurriculumController {
return new ResponseEntity<>(HttpStatus.OK);
}
- @GetMapping("/externalcurriculum/{userId}")
- public ResponseEntity> getStudentsExternalCurriculum(@RequestHeader("Authorization") String token, @PathVariable String userId){
+ @GetMapping("/externalcurriculum/{inscriptionRequestId}")
+ public ResponseEntity> getInscriptionRequestExternalCurriculum(@RequestHeader("Authorization") String token, @PathVariable String inscriptionRequestId){
if (authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin, Role.Teacher},token))
return new UnauthorizedResponse<>(null);
- User u = userServ.getUserById(Long.parseLong(userId));
- HashMap toReturn = userCurriculumServ.findAllExternalCurriculumByStudent(u);
+ HashMap toReturn = userCurriculumServ.findAllExternalCurriculumByInscriptionRequestId(Long.parseLong(inscriptionRequestId));
if (toReturn == null)
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
@@ -131,4 +133,11 @@ public class CurriculumController {
}
+ //Note : everyone can post some externalcurriculums (the validity of the elements is assured by the inscription service)
+ @PostMapping("/externalcurriculum")
+ public ResponseEntity postExternalCurriculum(@RequestBody ExternalCurriculum ec){
+ ec.setState(RequestState.Pending);
+ return new ResponseEntity<>(ecr.save(ec), HttpStatus.OK);
+ }
+
}
diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/ExternalCurriculumRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ExternalCurriculumRepository.java
index 32346a4..5835fab 100644
--- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/ExternalCurriculumRepository.java
+++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ExternalCurriculumRepository.java
@@ -2,10 +2,11 @@ package ovh.herisson.Clyde.Repositories;
import org.springframework.data.repository.CrudRepository;
import ovh.herisson.Clyde.Tables.ExternalCurriculum;
+import ovh.herisson.Clyde.Tables.InscriptionRequest;
import ovh.herisson.Clyde.Tables.User;
import java.util.ArrayList;
public interface ExternalCurriculumRepository extends CrudRepository {
- ArrayList getExternalCurriculumByUser(User user);
+ ArrayList getExternalCurriculumByInscriptionRequestId(Long id);
}
diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java
index 0b0cebf..7c65e2e 100644
--- a/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java
+++ b/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java
@@ -4,10 +4,7 @@ import org.springframework.stereotype.Service;
import ovh.herisson.Clyde.Repositories.CurriculumRepository;
import ovh.herisson.Clyde.Repositories.ExternalCurriculumRepository;
import ovh.herisson.Clyde.Repositories.UserCurriculumRepository;
-import ovh.herisson.Clyde.Tables.Curriculum;
-import ovh.herisson.Clyde.Tables.ExternalCurriculum;
-import ovh.herisson.Clyde.Tables.User;
-import ovh.herisson.Clyde.Tables.UserCurriculum;
+import ovh.herisson.Clyde.Tables.*;
import java.util.ArrayList;
import java.util.HashMap;
@@ -52,16 +49,16 @@ public class UserCurriculumService {
}
- public HashMap findAllExternalCurriculumByStudent(User student) {
- ArrayList list = externalCurriculumRepo.getExternalCurriculumByUser(student);
+ public HashMap findAllExternalCurriculumByInscriptionRequestId(Long id) {
+ ArrayList list = externalCurriculumRepo.getExternalCurriculumByInscriptionRequestId(id);
ArrayList> externalCurriculumList = new ArrayList>();
for (int i = 0; i < list.size(); i++) {
HashMap element = new HashMap<>();
element.put("id", list.get(0).getId());
- element.put("user", list.get(0).getUser());
- element.put("university", list.get(0).getUniversity());
+ element.put("inscriptionRequestId", list.get(0).getInscriptionRequestId());
+ element.put("school", list.get(0).getSchool());
element.put("formation", list.get(0).getFormation());
element.put("completion", list.get(0).getCompletion());
element.put("startYear", list.get(0).getStartYear());
diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ExternalCurriculum.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ExternalCurriculum.java
index 6e0d90f..5193f22 100644
--- a/backend/src/main/java/ovh/herisson/Clyde/Tables/ExternalCurriculum.java
+++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ExternalCurriculum.java
@@ -10,13 +10,9 @@ public class ExternalCurriculum {
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
- @ManyToOne
- @JoinColumn(name="Users")
- private User user;
+ private Long inscriptionRequestId;
- @ManyToOne
- @JoinColumn(name="University")
- private University university;
+ private String school;
private String formation;
@@ -32,9 +28,9 @@ public class ExternalCurriculum {
public ExternalCurriculum(){}
- public ExternalCurriculum(User user, University university, String formation, String completion, int startYear, int endYear, String justifdocUrl, RequestState state){
- this.user = user;
- this.university = university;
+ public ExternalCurriculum(Long ir, String school, String formation, String completion, int startYear, int endYear, String justifdocUrl, RequestState state){
+ this.inscriptionRequestId = ir;
+ this.school = school;
this.formation = formation;
this.completion = completion;
this.startYear = startYear;
@@ -47,20 +43,20 @@ public class ExternalCurriculum {
return id;
}
- public User getUser() {
- return user;
+ public Long getInscriptionRequestId() {
+ return inscriptionRequestId;
}
- public void setUser(User user) {
- this.user = user;
+ public void setInscriptionRequest(Long inscriptionRequestId) {
+ this.inscriptionRequestId = inscriptionRequestId;
}
- public University getUniversity() {
- return university;
+ public String getSchool() {
+ return school;
}
- public void setUniversity(University university) {
- this.university = university;
+ public void setSchool(String school) {
+ this.school = school;
}
public String getFormation() {
diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/InscriptionRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/InscriptionRequest.java
index b01644e..bbcf921 100644
--- a/backend/src/main/java/ovh/herisson/Clyde/Tables/InscriptionRequest.java
+++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/InscriptionRequest.java
@@ -15,7 +15,6 @@ public class InscriptionRequest {
private String email;
private String country;
private Date birthDate;
-
private Long curriculumId;
private RequestState state;
private String profilePicture;
diff --git a/frontend/src/Apps/Login.vue b/frontend/src/Apps/Login.vue
index a1cf99a..5bbf682 100644
--- a/frontend/src/Apps/Login.vue
+++ b/frontend/src/Apps/Login.vue
@@ -1,16 +1,15 @@
@@ -168,7 +205,7 @@
changer de cursus/réinscription sinon continuez ici.
-
+
{{i18n("login.guest.nextpage")}}
@@ -183,11 +220,65 @@
+ {{i18n("login.guest.nextpage")}}
+
+
+
+ Vous avez séléctionné un cursus qui possède des prérequis veuillez ajouter vos formations antérieures
+ dans l'enseignement supérieur, votre dossier sera vérifié par un membre du service d'inscription.
+
+
Ajouter une formation
+
Envoyer la demande d'inscription
+
+
+
+
+
+
+
+
+ Edit
+
+
+ Remove
+
+
+
+
diff --git a/frontend/src/rest/curriculum.js b/frontend/src/rest/curriculum.js
index 29815ab..32b9878 100644
--- a/frontend/src/rest/curriculum.js
+++ b/frontend/src/rest/curriculum.js
@@ -52,3 +52,15 @@ export async function getSelfCurriculum(){
export async function getSomeonesCurriculumList(user){
return restGet("/onescurriculum/"+user)
}
+
+export async function createExternalCurriculum(inscriptionRequestId,school, formation, completion, startYear, endYear, justifdocUrl){
+ return restPost("/externalcurriculum", {
+ inscriptionRequestId: inscriptionRequestId,
+ school:school,
+ formation :formation,
+ completion : completion,
+ startYear : startYear,
+ endYear: endYear,
+ justifdocUrl : justifdocUrl
+ })
+}