From 9a5115f7fe9da8c660e6e36b7726aa4a21a86c52 Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Sun, 21 Apr 2024 18:24:58 +0200 Subject: [PATCH] Final commit of the extension --- .../ExternalCurriculumController.java | 2 +- .../Inscription/InscriptionController.java | 34 +++++++++++++- .../Inscription/RequestsController.java | 19 +++++--- .../Inscription/InscriptionService.java | 3 +- .../Clyde/Services/ProtectionService.java | 1 + .../java/ovh/herisson/Clyde/Tables/User.java | 14 +++++- frontend/public/i18n/EN.txt | 7 ++- frontend/public/i18n/FR.txt | 5 ++- .../Inscription/AboutChangeCurriculum.vue | 23 ++-------- .../src/Apps/Inscription/AboutExemption.vue | 20 +-------- .../src/Apps/Inscription/AboutRequest.vue | 38 +++++++++++----- .../src/Apps/Inscription/AboutScholarship.vue | 7 ++- .../src/Apps/Inscription/AboutStudent.vue | 17 +------ .../src/Apps/Inscription/AboutUnregister.vue | 26 +---------- frontend/src/Apps/Inscription/CourseList.vue | 22 ++++----- .../Inscription/ExternalCurriculumList.vue | 5 +-- .../src/Apps/Inscription/ManageRequests.vue | 26 +++++++---- frontend/src/Apps/Inscription/PaymentInfo.vue | 1 - frontend/src/Apps/Login.vue | 45 +++++-------------- frontend/src/Apps/Profil.vue | 26 ++--------- frontend/src/rest/requests.js | 4 ++ 21 files changed, 162 insertions(+), 183 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/ExternalCurriculumController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/ExternalCurriculumController.java index a8a87ce..7b396d6 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/ExternalCurriculumController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/ExternalCurriculumController.java @@ -39,7 +39,7 @@ public class ExternalCurriculumController { user = userRepository.findById((Integer) externalCurrInfos.get("userRegNo")); } - ExternalCurriculum toSave = new ExternalCurriculum(ir, (String) externalCurrInfos.get("school"),(String) externalCurrInfos.get("formation"),(String) externalCurrInfos.get("completion"), (Integer)externalCurrInfos.get("startYear"), (Integer)externalCurrInfos.get("endYear"), (String)externalCurrInfos.get("justifDocUrl"), user); + ExternalCurriculum toSave = new ExternalCurriculum(ir, (String) externalCurrInfos.get("school"),(String) externalCurrInfos.get("formation"),(String) externalCurrInfos.get("completion"), (Integer)externalCurrInfos.get("startYear"), (Integer)externalCurrInfos.get("endYear"), (String)externalCurrInfos.get("justifdocUrl"), user); return new ResponseEntity<>(ecr.save(toSave), HttpStatus.OK); } diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/InscriptionController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/InscriptionController.java index eb283e8..8caf2d9 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/InscriptionController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/InscriptionController.java @@ -3,10 +3,12 @@ package ovh.herisson.Clyde.EndPoints.Inscription; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import ovh.herisson.Clyde.Repositories.CurriculumRepository; import ovh.herisson.Clyde.Responses.UnauthorizedResponse; import ovh.herisson.Clyde.Services.AuthenticatorService; import ovh.herisson.Clyde.Services.Inscription.InscriptionService; import ovh.herisson.Clyde.Services.ProtectionService; +import ovh.herisson.Clyde.Tables.Curriculum; import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; import ovh.herisson.Clyde.Tables.RequestState; import ovh.herisson.Clyde.Tables.Role; @@ -19,10 +21,11 @@ public class InscriptionController { private final InscriptionService inscriptionServ; private final AuthenticatorService authServ; - - public InscriptionController(InscriptionService inscriptionServ, AuthenticatorService authServ){ + private final CurriculumRepository curriculumRepository; + public InscriptionController(InscriptionService inscriptionServ, AuthenticatorService authServ, CurriculumRepository curriculumRepository){ this.inscriptionServ = inscriptionServ; this.authServ = authServ; + this.curriculumRepository = curriculumRepository; } @@ -103,4 +106,31 @@ public class InscriptionController { } return new ResponseEntity<>(HttpStatus.OK); } + + @PatchMapping("/request/registerequivimpose/{id}/{cursusid}") + public ResponseEntity editRegisterEquiv(@RequestHeader("Authorization") String token, @PathVariable long id, @PathVariable long cursusid){ + if (authServ.isNotIn(new Role[]{Role.Admin,Role.Teacher}, token)) + return new UnauthorizedResponse<>(null); + + InscriptionRequest toEdit = inscriptionServ.getById(id); + + //If the request is already accepted we just return ok (otherwise we would duplicate the procedure below) + if (toEdit.getEquivalenceState() == RequestState.Accepted){ + return new ResponseEntity<>(HttpStatus.OK); + } + + //We impose a curriculum + Curriculum curriculum = curriculumRepository.findById(cursusid); + + toEdit.setCurriculumId(curriculum.getCurriculumId()); + toEdit.setEquivalenceState(RequestState.Accepted); + + inscriptionServ.save(toEdit); + + if (toEdit.getState() == RequestState.Accepted && (toEdit.getEquivalenceState() == RequestState.Accepted || toEdit.getEquivalenceState() == RequestState.Unrequired)) + { + inscriptionServ.createUser(toEdit); + } + return new ResponseEntity<>(HttpStatus.OK); + } } 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 b21a6ca..65cbe4d 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 @@ -5,10 +5,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import ovh.herisson.Clyde.Repositories.CourseRepository; import ovh.herisson.Clyde.Repositories.CurriculumRepository; -import ovh.herisson.Clyde.Repositories.Inscription.ChangeCurriculumRequestRepository; -import ovh.herisson.Clyde.Repositories.Inscription.ExemptionsRequestRepository; -import ovh.herisson.Clyde.Repositories.Inscription.ScholarshipRequestRepository; -import ovh.herisson.Clyde.Repositories.Inscription.UnregisterRequestRepository; +import ovh.herisson.Clyde.Repositories.Inscription.*; import ovh.herisson.Clyde.Repositories.UserCurriculumRepository; import ovh.herisson.Clyde.Repositories.UserRepository; import ovh.herisson.Clyde.Responses.UnauthorizedResponse; @@ -17,6 +14,7 @@ import ovh.herisson.Clyde.Services.TokenService; import ovh.herisson.Clyde.Services.UserService; import ovh.herisson.Clyde.Tables.*; import ovh.herisson.Clyde.Tables.Inscription.ExemptionsRequest; +import ovh.herisson.Clyde.Tables.Inscription.Minerval; import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest; import ovh.herisson.Clyde.Tables.Inscription.UnregisterRequest; @@ -39,10 +37,10 @@ public class RequestsController { public final UserService userService; public final UserCurriculumRepository userCurriculumRepository; public final CurriculumRepository curriculumRepository; - + public final MinervalRepository minervalRepository; public final ChangeCurriculumRequestRepository changeCurriculumRequestRepository; - public RequestsController(TokenService tokenService, ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UnregisterRequestRepository unregisterRequestRepository, CourseRepository courseRepository, UserService userService, UserCurriculumRepository userCurriculumRepository, CurriculumRepository curriculumRepository, ChangeCurriculumRequestRepository changeCurriculumRequestRepository) { + public RequestsController(TokenService tokenService, ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UnregisterRequestRepository unregisterRequestRepository, CourseRepository courseRepository, UserService userService, UserCurriculumRepository userCurriculumRepository, CurriculumRepository curriculumRepository, MinervalRepository minervalRepository, ChangeCurriculumRequestRepository changeCurriculumRequestRepository) { this.tokenService = tokenService; this.err = err; this.srr = srr; @@ -53,6 +51,7 @@ public class RequestsController { this.userService = userService; this.userCurriculumRepository = userCurriculumRepository; this.curriculumRepository = curriculumRepository; + this.minervalRepository = minervalRepository; this.changeCurriculumRequestRepository = changeCurriculumRequestRepository; } @@ -154,6 +153,8 @@ public class RequestsController { ScholarshipRequest scholarshipRequest = srr.findById((Integer) infos.get("id")); + User u = scholarshipRequest.getUser(); + //If the request is already accepted we just return ok (otherwise we would duplicate the procedure below) if (scholarshipRequest.getState() == RequestState.Accepted){ return new ResponseEntity<>(HttpStatus.OK); @@ -162,6 +163,12 @@ public class RequestsController { if (infos.get("state").equals("Accepted")){ scholarshipRequest.setState(RequestState.Accepted); scholarshipRequest.setAmount((int) infos.get("amount")); + + //We then deduce then amount from the minerval + ArrayList minerval = minervalRepository.getMinervalsByStudentRegNoOrderByYearDesc(u.getRegNo()); + minerval.get(0).setPaidAmount(minerval.get(0).getPaidAmount() + scholarshipRequest.getAmount()); + minerval.get(0).setToPay(minerval.get(0).getToPay() - scholarshipRequest.getAmount()); + minervalRepository.save(minerval.get(0)); }else{ scholarshipRequest.setState(RequestState.Refused); } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/Inscription/InscriptionService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/Inscription/InscriptionService.java index 534fb88..374b03b 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/Inscription/InscriptionService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/Inscription/InscriptionService.java @@ -89,7 +89,8 @@ public class InscriptionService { inscrRequest.getCountry(), inscrRequest.getBirthDate(), inscrRequest.getProfilePicture(), - inscrRequest.getPassword() + inscrRequest.getPassword(), + inscrRequest.getIdentityCard() ); userService.save(userFromRequest); diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/ProtectionService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/ProtectionService.java index 8c3d847..ef52d5e 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/ProtectionService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/ProtectionService.java @@ -30,6 +30,7 @@ public class ProtectionService { toReturn.put("country",user.getCountry()); toReturn.put("profilePictureUrl",user.getProfilePictureUrl()); toReturn.put("role",user.getRole()); + toReturn.put("identityCard", user.getIdentityCardUrl()); return toReturn; } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java index 3fe8559..08184c9 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java @@ -28,6 +28,7 @@ public class User { private Date birthDate; private String profilePictureUrl; private Role role; + private String identityCardUrl; @JsonIgnore private String password; @@ -53,8 +54,10 @@ public class User { this.password = password; } + + //This constructor is used to add a student public User(String lastName, String firstName, String email, String address, - String country, Date birthDate, String profilePictureUrl, String password) + String country, Date birthDate, String profilePictureUrl, String password,String identityCardUrl) { this.lastName = lastName; this.firstName = firstName; @@ -65,6 +68,7 @@ public class User { this.profilePictureUrl = profilePictureUrl; this.password = password; this.role = Role.Student; + this.identityCardUrl = identityCardUrl; } public User() {} @@ -138,4 +142,12 @@ public class User { public void setPassword(String password) { this.password = password; } + + public void setIdentityCardUrl(String identityCardUrl) { + this.identityCardUrl = identityCardUrl; + } + + public String getIdentityCardUrl() { + return identityCardUrl; + } } diff --git a/frontend/public/i18n/EN.txt b/frontend/public/i18n/EN.txt index 0d7fa4a..7fa49b0 100644 --- a/frontend/public/i18n/EN.txt +++ b/frontend/public/i18n/EN.txt @@ -35,7 +35,7 @@ app.language=Language app.manage.profile=Manage profile app.studentList=Students List app.users=Users -app.payments = Payments +app.payments=Payments request.moreInfos=More Infos request.accept=Accept request.refuse=Refuse @@ -82,7 +82,7 @@ dltaxdoc=Download tax justification document dlresidency=Download residency justification document enteramount=Please enter the amount to provide : oldcursus=Old curriculums -newcursus = New curriculums +newcursus=New curriculums year=Year reason=Reason : selectedcursus=Selected curriculum : @@ -144,3 +144,6 @@ chcur=Change from a cursus to another iwouldlike=I would like to : newcurr=New curriculum cursusprereq=The cursus you selected has some prerequisites ensure that your external curriculum data is updated in your profile +imposecurriculum=Impose a curriculum +impose=Impose +gotimposed=The selected curriculum has been imposed \ No newline at end of file diff --git a/frontend/public/i18n/FR.txt b/frontend/public/i18n/FR.txt index dd4e591..0557a83 100644 --- a/frontend/public/i18n/FR.txt +++ b/frontend/public/i18n/FR.txt @@ -35,7 +35,7 @@ app.language=Langue app.manage.profile=Gérer le profil app.studentList=Liste des étudiants app.users=Utilisateurs -app.payments = Payements +app.payments=Payements request.moreInfos=Plus d'Infos request.accept=Accepter request.refuse=Refuser @@ -144,3 +144,6 @@ chcur=Changer d'un cursus vers un autre iwouldlike=Je voudrais : newcurr=Nouveau cursus cursusprereq=Le cursus que vous avez selectionné a des prérequis assurez vous que votre dossier de parcours est a jour dans votre profil +imposecurriculum=Imposer un cursusgotimposed +impose=Imposer +gotimposed=Le cursus selectionné a été imposé \ No newline at end of file diff --git a/frontend/src/Apps/Inscription/AboutChangeCurriculum.vue b/frontend/src/Apps/Inscription/AboutChangeCurriculum.vue index 0f2e21d..588221c 100644 --- a/frontend/src/Apps/Inscription/AboutChangeCurriculum.vue +++ b/frontend/src/Apps/Inscription/AboutChangeCurriculum.vue @@ -1,15 +1,12 @@ diff --git a/frontend/src/Apps/Inscription/AboutScholarship.vue b/frontend/src/Apps/Inscription/AboutScholarship.vue index 45c9e36..920bbea 100644 --- a/frontend/src/Apps/Inscription/AboutScholarship.vue +++ b/frontend/src/Apps/Inscription/AboutScholarship.vue @@ -1,8 +1,7 @@