diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/RequestsController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/RequestsController.java index f423984..74d1bf0 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/RequestsController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/RequestsController.java @@ -88,6 +88,28 @@ public class RequestsController { return new ResponseEntity<>(toReturn, HttpStatus.OK); } + @GetMapping(value = "/exemptionsreq/{id}") + public ResponseEntity getExemptionRequestbyId(@RequestHeader("Authorization") String token, @PathVariable long id){ + if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token)) + return new UnauthorizedResponse<>(null); + + ExemptionsRequest exemptionsRequest = err.findById(id); + + return new ResponseEntity<>(exemptionsRequest, HttpStatus.OK); + } + + @PatchMapping(value = "/exemptionsreq/{id}/{newstate}") + public ResponseEntity changeExemptionReqState(@RequestHeader("Authorization") String token, @PathVariable long id, @PathVariable RequestState newstate){ + if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token)) + return new UnauthorizedResponse<>(null); + + ExemptionsRequest exemptionsRequest = err.findById(id); + exemptionsRequest.setState(newstate); + err.save(exemptionsRequest); + + return new ResponseEntity<>(HttpStatus.OK); + } + //Get all the scholarships requests @GetMapping(value = "/scholarshipreq") public ResponseEntity> getAllScholarshipRequests(@RequestHeader("Authorization") String token){ @@ -176,6 +198,16 @@ public class RequestsController { return new ResponseEntity<>(HttpStatus.OK); } + //We look in the usercursus table if the student has already the previous year of a curriculum + public boolean studentHasPrevYear(Curriculum curriculum, User user){ + ArrayList userCurrList = userCurriculumRepository.findByUserOrderByCurriculum(user); + for (int i = 0; i < userCurrList.size(); i++){ + if (userCurrList.get(i).getCurriculum().getOption().equals(curriculum.getOption()) && userCurrList.get(i).getCurriculum().getYear() == curriculum.getYear()-1){ + return true; + } + } + return false; + } @PostMapping("/changecurriculumreq") public ResponseEntity addChangeCurrReq(@RequestBody Map reqInfos){ User user = userRepository.findById((Integer) reqInfos.get("userId")); @@ -191,8 +223,12 @@ public class RequestsController { Curriculum destinationCurriculum = curriculumRepository.findById((Integer) reqInfos.get("newcursus")); - ChangeCurriculumRequest changeCurriculumRequest = new ChangeCurriculumRequest(user, actualCurriculum, destinationCurriculum, new Date(), RequestState.Pending); + ChangeCurriculumRequest changeCurriculumRequest = new ChangeCurriculumRequest(user, actualCurriculum, destinationCurriculum, new Date(), RequestState.Pending, RequestState.Unrequired); + //Si l'année du cursus est plus grande que 1 et que l'étudiant n'a pas dans sa liste de cursus l'année d'en dessous alors on demande l'accord du prof + if (destinationCurriculum.getYear() > 1 && !studentHasPrevYear(destinationCurriculum, user)){ + changeCurriculumRequest.setTeacherApprovalState(RequestState.Pending); + } changeCurriculumRequestRepository.save(changeCurriculumRequest); return new ResponseEntity<>(HttpStatus.OK); @@ -228,27 +264,49 @@ public class RequestsController { toEdit.setState(newState); - if (newState == RequestState.Accepted){ + if (newState == RequestState.Accepted && (toEdit.getTeacherApprovalState() == RequestState.Accepted || toEdit.getTeacherApprovalState() == RequestState.Unrequired)){ //If actual curriculum is not null then we need to set that the user doesn't follow it anymore - User u = toEdit.getUser(); - if (toEdit.getActualCurriculum() != null){ - ArrayList listcurr = userCurriculumRepository.findByUserOrderByCurriculum(u); - - for (int i = 0; i < listcurr.size(); i++){ - if (listcurr.get(i).getCurriculum() == toEdit.getActualCurriculum()){ - listcurr.get(i).setActual(false); - } - } - - userCurriculumRepository.saveAll(listcurr); - } - - Calendar c = Calendar.getInstance(); - UserCurriculum userCurriculum = new UserCurriculum(u, toEdit.getDestinationCurriculum(), c.get(Calendar.YEAR), true); - userCurriculumRepository.save(userCurriculum); + acceptProcedure(toEdit); } changeCurriculumRequestRepository.save(toEdit); return new ResponseEntity<>(HttpStatus.OK); } + + @PatchMapping("/changecurriculumreqteacher/{id}/{newteacherstate}") + public ResponseEntity editCCReqTeacherState(@RequestHeader("Authorization") String token, @PathVariable long id, @PathVariable RequestState newteacherstate){ + if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token)) + return new UnauthorizedResponse<>(null); + + ChangeCurriculumRequest toEdit = changeCurriculumRequestRepository.findById(id); + + toEdit.setState(newteacherstate); + + if (newteacherstate == RequestState.Accepted && toEdit.getState() == RequestState.Accepted){ + //If actual curriculum is not null then we need to set that the user doesn't follow it anymore + acceptProcedure(toEdit); + } + + changeCurriculumRequestRepository.save(toEdit); + return new ResponseEntity<>(HttpStatus.OK); + } + + private void acceptProcedure(ChangeCurriculumRequest toEdit) { + User u = toEdit.getUser(); + if (toEdit.getActualCurriculum() != null){ + ArrayList listcurr = userCurriculumRepository.findByUserOrderByCurriculum(u); + + for (int i = 0; i < listcurr.size(); i++){ + if (listcurr.get(i).getCurriculum() == toEdit.getActualCurriculum()){ + listcurr.get(i).setActual(false); + } + } + + userCurriculumRepository.saveAll(listcurr); + } + + Calendar c = Calendar.getInstance(); + UserCurriculum userCurriculum = new UserCurriculum(u, toEdit.getDestinationCurriculum(), c.get(Calendar.YEAR), true); + userCurriculumRepository.save(userCurriculum); + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java index 6ff0707..d9320a9 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -83,13 +83,15 @@ public class MockController { minervalRepository.save(minerval); // Course / Curriculum part - Curriculum infoBab1 = new Curriculum(1,"info"); - Curriculum chemistryBab1 = new Curriculum(1,"chemistry"); - Curriculum psychologyBab1 = new Curriculum(1,"psychology"); - Curriculum infoBab2 = new Curriculum(2,"info"); - Curriculum masterinfo1 = new Curriculum(4, "info"); - Curriculum masterinfo2 = new Curriculum(5, "info"); - Curriculum chemistryBab2 = new Curriculum(2, "chemistry"); + Curriculum infoBab1 = new Curriculum(1,"info", false); + Curriculum chemistryBab1 = new Curriculum(1,"chemistry", false); + Curriculum psychologyBab1 = new Curriculum(1,"psychology", false); + Curriculum infoBab2 = new Curriculum(2,"info", false); + Curriculum masterinfo1 = new Curriculum(4, "info", false); + Curriculum masterinfo2 = new Curriculum(5, "info", false); + Curriculum chemistryBab2 = new Curriculum(2, "chemistry", false); + Curriculum ingebab1 = new Curriculum(1, "ingénieur", true); + curriculumService.save(infoBab1); curriculumService.save(chemistryBab1); curriculumService.save(psychologyBab1); @@ -97,6 +99,7 @@ public class MockController { curriculumService.save(masterinfo1); curriculumService.save(masterinfo2); curriculumService.save(chemistryBab2); + curriculumService.save(ingebab1); ucr.save(new UserCurriculum(joe, infoBab1, 2022, false)); ucr.save(new UserCurriculum(joe, chemistryBab1, 2023, true)); @@ -128,8 +131,7 @@ public class MockController { CurriculumCourseService.save(new CurriculumCourse(chemistryBab1,commun)); CurriculumCourseService.save(new CurriculumCourse(chemistryBab1,chemistry1)); - - InscriptionRequest inscriptionRequest = new InscriptionRequest("helen","prenom","non","helen@gmail.com","america",new Date(),(long) 4,RequestState.Pending,"yes.png","password", null, new Date(), RequestState.Pending); + InscriptionRequest inscriptionRequest = new InscriptionRequest("helen","prenom","non","helen@gmail.com","america",new Date(),(long) 4,RequestState.Pending,"yes.png","password", null, new Date(), RequestState.Pending, null); inscriptionService.save(inscriptionRequest); diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ExemptionsRequestRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ExemptionsRequestRepository.java index 3f66e80..d644ef1 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ExemptionsRequestRepository.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ExemptionsRequestRepository.java @@ -4,5 +4,5 @@ import org.springframework.data.repository.CrudRepository; import ovh.herisson.Clyde.Tables.Inscription.ExemptionsRequest; public interface ExemptionsRequestRepository extends CrudRepository { - + ExemptionsRequest findById(long id); } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumCourseService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumCourseService.java index 19549d0..b522da3 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumCourseService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumCourseService.java @@ -46,7 +46,7 @@ public class CurriculumCourseService { toReturn.put("curriculumId", curriculum.getCurriculumId()); toReturn.put("year", curriculum.getYear()); toReturn.put("option", curriculum.getOption()); - + toReturn.put("requireCertificate", curriculum.isRequireCertificate()); return toReturn; } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ChangeCurriculumRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ChangeCurriculumRequest.java index 72feebd..a309023 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/ChangeCurriculumRequest.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ChangeCurriculumRequest.java @@ -26,14 +26,16 @@ public class ChangeCurriculumRequest { private RequestState state; + private RequestState teacherApprovalState; public ChangeCurriculumRequest(){} - public ChangeCurriculumRequest(User user, Curriculum actualCurriculum, Curriculum destinationCurriculum, Date date, RequestState state){ + public ChangeCurriculumRequest(User user, Curriculum actualCurriculum, Curriculum destinationCurriculum, Date date, RequestState state, RequestState teacherApprovalState){ this.user = user; this.actualCurriculum = actualCurriculum; this.destinationCurriculum = destinationCurriculum; this.date = date; this.state = state; + this.teacherApprovalState = teacherApprovalState; } public User getUser() { @@ -80,4 +82,14 @@ public class ChangeCurriculumRequest { public int getId() { return id; } + + public RequestState getTeacherApprovalState() { + return teacherApprovalState; + } + + public void setTeacherApprovalState(RequestState teacherApprovalState) { + this.teacherApprovalState = teacherApprovalState; + } } + + diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Curriculum.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Curriculum.java index 67075d1..4bcac40 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Curriculum.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Curriculum.java @@ -12,9 +12,13 @@ public class Curriculum { private int curriculumId; private int year; private String option; - public Curriculum(int year, String option){ + + //True if the curriculum need an entry exam + private boolean requireCertificate; + public Curriculum(int year, String option, boolean requireCertificate){ this.year = year; this.option = option; + this.requireCertificate = requireCertificate; } public Curriculum() {} @@ -39,4 +43,11 @@ public class Curriculum { this.option = option; } + public void setRequireCertificate(boolean requireCertificate) { + this.requireCertificate = requireCertificate; + } + + public boolean isRequireCertificate() { + return requireCertificate; + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java index e7a081b..ad5eab4 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java @@ -3,5 +3,6 @@ package ovh.herisson.Clyde.Tables; public enum FileType { ProfilePicture, EducationCertificate, - JustificationDocument + JustificationDocument, + IdentityCard, } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ExemptionsRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ExemptionsRequest.java index 75ee926..8942bb6 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ExemptionsRequest.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ExemptionsRequest.java @@ -80,4 +80,8 @@ public class ExemptionsRequest { public void setDate(Date date) { this.date = date; } + + public int getId() { + return id; + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/InscriptionRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/InscriptionRequest.java index 07c720f..1d0271c 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/InscriptionRequest.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/InscriptionRequest.java @@ -22,11 +22,12 @@ public class InscriptionRequest { private String profilePicture; private String password; private String identityCard; + private String admissionDocUrl; private Date submissionDate; private RequestState equivalenceState; public InscriptionRequest(){} - public InscriptionRequest(String lastName, String firstName, String address, String email, String country, Date birthDate,Long curriculumId, RequestState state, String profilePicture, String password, String identityCard, Date submissionDate, RequestState equivalenceState){ + public InscriptionRequest(String lastName, String firstName, String address, String email, String country, Date birthDate,Long curriculumId, RequestState state, String profilePicture, String password, String identityCard, Date submissionDate, RequestState equivalenceState, String admissionDocUrl){ this.lastName = lastName; this.firstName = firstName; this.address = address; @@ -40,6 +41,7 @@ public class InscriptionRequest { this.identityCard = identityCard; this.submissionDate = submissionDate; this.equivalenceState = equivalenceState; + this.admissionDocUrl = admissionDocUrl; } public int getId() { @@ -149,4 +151,12 @@ public class InscriptionRequest { public void setEquivalenceState(RequestState equivalenceState) { this.equivalenceState = equivalenceState; } + + public String getAdmissionDocUrl() { + return admissionDocUrl; + } + + public void setAdmissionDocUrl(String admissionDocUrl) { + this.admissionDocUrl = admissionDocUrl; + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ReInscriptionRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ReInscriptionRequest.java deleted file mode 100644 index cafffe6..0000000 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ReInscriptionRequest.java +++ /dev/null @@ -1,81 +0,0 @@ -package ovh.herisson.Clyde.Tables.Inscription; - -import jakarta.persistence.*; -import org.hibernate.annotations.OnDelete; -import org.hibernate.annotations.OnDeleteAction; -import ovh.herisson.Clyde.Tables.Curriculum; -import ovh.herisson.Clyde.Tables.RequestState; -import ovh.herisson.Clyde.Tables.User; - -@Entity -public class ReInscriptionRequest { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private int id; - - @ManyToOne - @JoinColumn(name = "Users") - @OnDelete(action = OnDeleteAction.CASCADE) - private User user; - - @ManyToOne - @JoinColumn(name = "Curriculum") - @OnDelete(action = OnDeleteAction.CASCADE) - private Curriculum newCurriculum; - private RequestState state; - - //Permet de différencier les demandes de changement et une réinscription dans le même Curriculum - //Pour la réinscription on va le mettre a 0 - private boolean type = false; - - public ReInscriptionRequest(){} - - public ReInscriptionRequest(User user, Curriculum newCurriculum, RequestState state, boolean type){ - this.user = user; - this.newCurriculum = newCurriculum; - this.state = state; - this.type = type; - } - - public ReInscriptionRequest(User user, Curriculum newCurriculum, RequestState state){ - this.user = user; - this.newCurriculum = newCurriculum; - this.state = state; - } - - public int getId() { - return id; - } - - public User getUser() { - return user; - } - - public void setUser(User user) { - this.user = user; - } - - public Curriculum getNewCurriculum() { - return newCurriculum; - } - - public void setNewCurriculum(Curriculum newCurriculum) { - this.newCurriculum = newCurriculum; - } - - public RequestState getState() { - return state; - } - - public void setState(RequestState state) { - this.state = state; - } - - public boolean isType() { - return type; - } - - public void setType(boolean type) { - this.type = type; - } -} diff --git a/frontend/src/Apps/Inscription/AboutChangeCurriculum.vue b/frontend/src/Apps/Inscription/AboutChangeCurriculum.vue index 1427446..9a3f40d 100644 --- a/frontend/src/Apps/Inscription/AboutChangeCurriculum.vue +++ b/frontend/src/Apps/Inscription/AboutChangeCurriculum.vue @@ -1,34 +1,40 @@ diff --git a/frontend/src/Apps/Inscription/AboutExemption.vue b/frontend/src/Apps/Inscription/AboutExemption.vue new file mode 100644 index 0000000..366c32a --- /dev/null +++ b/frontend/src/Apps/Inscription/AboutExemption.vue @@ -0,0 +1,116 @@ + + + + + + \ No newline at end of file diff --git a/frontend/src/Apps/Inscription/AboutRequest.vue b/frontend/src/Apps/Inscription/AboutRequest.vue index 15c72f5..c6d15df 100644 --- a/frontend/src/Apps/Inscription/AboutRequest.vue +++ b/frontend/src/Apps/Inscription/AboutRequest.vue @@ -16,6 +16,8 @@ const user = await getSelf(); const list = ref(false); const externalCurriculum = await getExternalCurriculumByInscrReq(request.id) +//Get the parent page windowState to display the correct button +const windowState = defineModel("windowState") function getPP(){ if(request.profilePictureUrl === null){ return "/Clyde.png" @@ -61,12 +63,15 @@ async function editEquivalence(id, newstate){ +
+ +
- +
- +
diff --git a/frontend/src/Apps/Inscription/ExternalCurriculumList.vue b/frontend/src/Apps/Inscription/ExternalCurriculumList.vue index eba1cdf..c467853 100644 --- a/frontend/src/Apps/Inscription/ExternalCurriculumList.vue +++ b/frontend/src/Apps/Inscription/ExternalCurriculumList.vue @@ -4,15 +4,23 @@ import {getSelf} from "@/rest/Users.js"; import {createExternalCurriculum, getExternalCurriculumByUser} from "@/rest/externalCurriculum.js"; - //mode 0 = externalcurr related to inscrreq, 1 = externalcurr related to user + //mode 0 = externalcurr related to inscrreq, 1 = externalcurr related to user, 2 inscription procedure const props = defineProps(["extCurrList", "mode"]) - const extCurrList = ref(props.extCurrList) + //Only usefull to pass the external curr array in the inscription procedure + const externalCurrTab = defineModel(); + + const extCurrList = ref({}) + let extNum = 0 + const User = ref({}) + + if (props.mode === 1){ + User.value = await getSelf() + } - const User = await getSelf() const list = ref(true) - + const editmode = ref(false) const notcompletedCheck = ref(false); const externalCurr = reactive({ @@ -28,22 +36,49 @@ if (props.mode === 1){ externalCurr.userRegNo = props.extCurrList[0].user.regNo + }else if(props.mode === 2){ + extCurrList.value = externalCurrTab.value + } + + if(props.mode !== 2){ + extCurrList.value = props.extCurrList + console.log("oe") + } + + function deleteExtCursus(extcursus){ + externalCurrTab.value.splice(externalCurrTab.value.indexOf(extcursus),1) } async function postExternalCurr(){ - await createExternalCurriculum(externalCurr.inscriptionRequestId, externalCurr.school, externalCurr.formation, externalCurr.completion, externalCurr.startYear, externalCurr.endYear, externalCurr.justifdocUrl, externalCurr.userRegNo); - //We refresh the list - extCurrList.value = await getExternalCurriculumByUser(externalCurr.userRegNo); - list.value = !list.value; + if (props.mode === 1){ + await createExternalCurriculum(externalCurr.inscriptionRequestId, externalCurr.school, externalCurr.formation, externalCurr.completion, externalCurr.startYear, externalCurr.endYear, externalCurr.justifdocUrl, externalCurr.userRegNo); + //We refresh the list + extCurrList.value = await getExternalCurriculumByUser(externalCurr.userRegNo); + list.value = !list.value; + }else if (props.mode === 2){ + externalCurrTab.value.push({ + inscriptionRequestId : externalCurr.inscriptionRequestId, + school:externalCurr.school, + formation :externalCurr.formation, + completion : externalCurr.completion, + startYear : externalCurr.startYear, + endYear: externalCurr.endYear, + justifdocUrl : externalCurr.justifdocUrl, + userRegNo : externalCurr.userRegNo + }); + extCurrList.value = externalCurrTab.value + list.value = !list.value; + console.log(externalCurrTab.value) + } }