From a89d1b192c3f4d0a0014093bd29617c7229eff4f Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Mon, 15 Apr 2024 16:17:27 +0200 Subject: [PATCH 1/8] Add the gestion of scholarshipRequest (accept and refuse and select the amount) --- .../Inscription/RequestsController.java | 22 ++++ .../ScholarshipRequestRepository.java | 2 +- frontend/src/App.vue | 2 - .../src/Apps/Inscription/AboutScholarship.vue | 124 ++++++++++++++++++ .../src/Apps/Inscription/ManageRequests.vue | 11 +- frontend/src/Apps/Login.vue | 9 +- frontend/src/Apps/Profil.vue | 15 --- frontend/src/rest/requests.js | 8 ++ 8 files changed, 165 insertions(+), 28 deletions(-) create mode 100644 frontend/src/Apps/Inscription/AboutScholarship.vue 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 61489bf..38b9117 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 @@ -15,6 +15,7 @@ import ovh.herisson.Clyde.Tables.Inscription.ExemptionsRequest; import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest; import ovh.herisson.Clyde.Tables.Inscription.UninscriptionRequest; +import javax.swing.text.html.parser.Entity; import java.util.ArrayList; import java.util.Date; import java.util.Map; @@ -94,4 +95,25 @@ public class RequestsController { uninscriptionRequestRepository.save(ur); return new ResponseEntity<>(HttpStatus.OK); } + + @PatchMapping(value = "/scholarshipreq/") + public ResponseEntity editScholReq(@RequestBody Map infos){ + ScholarshipRequest scholarshipRequest = srr.findById((Integer) infos.get("id")); + + if (infos.get("state").equals("Accepted")){ + scholarshipRequest.setState(RequestState.Accepted); + scholarshipRequest.setAmount((int) infos.get("amount")); + }else{ + scholarshipRequest.setState(RequestState.Refused); + } + + srr.save(scholarshipRequest); + return new ResponseEntity<>(HttpStatus.OK); + } + + @GetMapping(value = "/scholarshipreq/{id}") + public ResponseEntity getScholReqbyId(@PathVariable long id){ + ScholarshipRequest toReturn = srr.findById(id); + return new ResponseEntity<>(toReturn, HttpStatus.OK); + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ScholarshipRequestRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ScholarshipRequestRepository.java index 5550937..c0c1407 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ScholarshipRequestRepository.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ScholarshipRequestRepository.java @@ -4,5 +4,5 @@ import org.springframework.data.repository.CrudRepository; import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest; public interface ScholarshipRequestRepository extends CrudRepository { - + public ScholarshipRequest findById(long id); } diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 6dcad67..1c219b9 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -25,7 +25,6 @@ window.addEventListener('hashchange', () => { const login=ref(i18n("app.login")) const active=ref(false) - const apps = ref([]) appList().then(e => apps.value = e) @@ -33,7 +32,6 @@ window.addEventListener('hashchange', () => { \ No newline at end of file diff --git a/frontend/src/Apps/Inscription/ManageRequests.vue b/frontend/src/Apps/Inscription/ManageRequests.vue index b6a1a50..7869557 100644 --- a/frontend/src/Apps/Inscription/ManageRequests.vue +++ b/frontend/src/Apps/Inscription/ManageRequests.vue @@ -5,6 +5,7 @@ import AboutRequest from "@/Apps/Inscription/AboutRequest.vue"; import {getAllExemptionsRequest, getAllScholarShipsRequest, getAllUnregisters} from "@/rest/requests.js"; import AboutScholarship from "@/Apps/Inscription/AboutScholarship.vue"; + import AboutUnregister from "@/Apps/Inscription/AboutUnregister.vue"; const requests = ref(await getAllRegisters()); let targetId = ""; @@ -12,7 +13,7 @@ const requestType = ref("inscription"); const filterType = ref("None"); - //0 = liste, 1 = détails, 2 = sure?, 3 = manage scholarship + //0 = liste, 1 = détails, 2 = sure?, 3 = manage scholarship, 4 manage unregister let windowsState = ref(0); async function upPage(id,review){ @@ -101,7 +102,7 @@
{{item.lastName}}
id : {{item.regNo}}
{{item.state}}
-
+
@@ -111,12 +112,15 @@ -
+
+
+ +
+ diff --git a/frontend/src/Apps/Profil.vue b/frontend/src/Apps/Profil.vue index e45a0e4..f31f5da 100644 --- a/frontend/src/Apps/Profil.vue +++ b/frontend/src/Apps/Profil.vue @@ -22,17 +22,12 @@ if(user.role === "Teacher"){ UserCurriculum.value = await getCourses("Teacher"); } - const modif = ref(false); - const curric = ref(false); - const reg = ref(false); - const courseslist = ref(false); - const minerval = ref(false); - const paymentPage = ref(false); - const scholarship = ref(false); - const scholarshipinfos = ref(false); - const uninscr = ref(false); + const sure = ref(0); + //0 base, 1 modif, 2 curriculum, 3 register, 4 courselist, 5 minerval, 6 payment, 7 scholarship, 8 scholarshipinfos, 9 unregister, 10 sure, 11 aboutunregister + const windowState = ref(0); + const pattern = { profilPictureUrl:null, email:null, @@ -82,17 +77,17 @@ async function ChangeInfos(){ for (let element in toModify){ - if (element =="email" && (toModify[element] !== null)){ + if (element ==="email" && (toModify[element] !== null)){ await alterSelf(user.value.regNo,{email : toModify[element]}); } - if (element =="profilPictureUrl" && (toModify[element] !== null)){ + if (element ==="profilPictureUrl" && (toModify[element] !== null)){ await alterSelf(user.value.regNo,{ profilPictureUrl : toModify[element]}); } - else if(element == "address" && (toModify[element] !== null)){ + else if(element === "address" && (toModify[element] !== null)){ await alterSelf(user.value.regNo,{address : toModify[element]}); } - else if(element == "password" && (toModify[element] !== null)){ + else if(element === "password" && (toModify[element] !== null)){ await alterSelf(user.value.regNo,{password : toModify[element]}); } } @@ -159,12 +154,12 @@ diff --git a/frontend/src/rest/apps.js b/frontend/src/rest/apps.js index b414e68..eb13476 100644 --- a/frontend/src/rest/apps.js +++ b/frontend/src/rest/apps.js @@ -4,13 +4,12 @@ import i18n from '@/i18n.js' // Liste des apps import LoginPage from '@/Apps/Login.vue' -import Inscription from "@/Apps/Inscription/ManageRequests.vue" import Profil from "@/Apps/Profil.vue" import Courses from "@/Apps/ManageCourses.vue" import Users from "@/Apps/UsersList.vue" import Students from "@/Apps/StudentsList.vue" -import AboutStudent from "@/Apps/Inscription/AboutStudent.vue"; import Msg from "@/Apps/Msg.vue" +import Payments from "@/Apps/Inscription/PaymentInfo.vue"; import ManageRequests from "@/Apps/Inscription/ManageRequests.vue"; const apps = { @@ -21,6 +20,7 @@ const apps = { '/users-list' : Users, '/students-list' : Students, '/msg' : Msg, + '/payments': Payments } const appsList = { @@ -32,6 +32,7 @@ const appsList = { 'ManageCourses': { path: '#/manage-courses', icon: 'fa-book', text: i18n("app.manage.courses") }, 'StudentsList':{ path: '#/students-list',icon: 'fa-users',text: i18n("app.studentList")}, 'UsersList':{ path: '#/users-list',icon: 'fa-users',text: i18n("app.users")}, + 'Payments':{path: '#/payments', icon:'fa-users', text:i18n("app.payments")} } const currentPath = ref(window.location.hash) diff --git a/frontend/src/rest/requests.js b/frontend/src/rest/requests.js index 05140ae..9d43968 100644 --- a/frontend/src/rest/requests.js +++ b/frontend/src/rest/requests.js @@ -34,4 +34,16 @@ export async function getScholarshipReqById(id){ export async function getAllUnregisters(){ return restGet("/unregister") +} + +export async function getUnregisterbyId(id){ + return restGet("/unregister/"+id) +} + +export async function editUnregReq(id, newstate){ + return restPatch("/unregister/"+id+"/"+newstate) +} + +export async function getAllPayments(){ + return restGet("/payment") } \ No newline at end of file From 058c53dbbc6e5c92555666ed4c47155554c3afd7 Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Wed, 17 Apr 2024 11:55:56 +0200 Subject: [PATCH 4/8] Add the actual in UserCurriculum Rework the unregister procedure Add ChangeCurriculumRequest Add the changeCurriculumRequest submit --- .../Inscription/RequestsController.java | 35 +++++++- .../Clyde/EndPoints/MockController.java | 12 +-- .../ChangeCurriculumRequestRepository.java | 7 ++ .../Inscription/InscriptionService.java | 4 +- .../Clyde/Services/UserCurriculumService.java | 3 +- .../Clyde/Tables/ChangeCurriculumRequest.java | 83 +++++++++++++++++++ .../herisson/Clyde/Tables/UserCurriculum.java | 14 +++- .../src/Apps/Inscription/AboutStudent.vue | 12 +-- frontend/src/Apps/Profil.vue | 37 +++++---- frontend/src/rest/requests.js | 4 + 10 files changed, 179 insertions(+), 32 deletions(-) create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ChangeCurriculumRequestRepository.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/ChangeCurriculumRequest.java 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 934e37c..2b4f9d3 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 @@ -4,9 +4,12 @@ import org.springframework.http.HttpStatus; 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.UserCurriculumRepository; import ovh.herisson.Clyde.Repositories.UserRepository; import ovh.herisson.Clyde.Responses.UnauthorizedResponse; import ovh.herisson.Clyde.Services.AuthenticatorService; @@ -31,8 +34,12 @@ public class RequestsController { public final UnregisterRequestRepository unregisterRequestRepository; public final CourseRepository courseRepository; public final UserService userService; + public final UserCurriculumRepository userCurriculumRepository; + public final CurriculumRepository curriculumRepository; - public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UnregisterRequestRepository unregisterRequestRepository, CourseRepository courseRepository, UserService userService) { + public final ChangeCurriculumRequestRepository changeCurriculumRequestRepository; + + public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UnregisterRequestRepository unregisterRequestRepository, CourseRepository courseRepository, UserService userService, UserCurriculumRepository userCurriculumRepository, CurriculumRepository curriculumRepository, ChangeCurriculumRequestRepository changeCurriculumRequestRepository) { this.err = err; this.srr = srr; this.userRepository = userRepository; @@ -40,6 +47,9 @@ public class RequestsController { this.unregisterRequestRepository = unregisterRequestRepository; this.courseRepository = courseRepository; this.userService = userService; + this.userCurriculumRepository = userCurriculumRepository; + this.curriculumRepository = curriculumRepository; + this.changeCurriculumRequestRepository = changeCurriculumRequestRepository; } @PostMapping(value="/exemptionreq") @@ -135,14 +145,33 @@ public class RequestsController { @PatchMapping(value = "/unregister/{id}/{newstate}") public ResponseEntity pathUnregReq(@PathVariable long id, @PathVariable RequestState newstate){ UnregisterRequest unregisterRequest = unregisterRequestRepository.findById(id); - + User u = userRepository.findById(unregisterRequest.getRegNo()); unregisterRequest.setState(newstate); if (newstate == RequestState.Accepted){ - userService.delete(userRepository.findById(unregisterRequest.getRegNo())); + ArrayList userCurricula = userCurriculumRepository.findByUserOrderByCurriculum(u); + for (int i = 0; i < userCurricula.size(); i++){ + userCurricula.get(i).setActual(false); + } + userCurriculumRepository.saveAll(userCurricula); } unregisterRequestRepository.save(unregisterRequest); return new ResponseEntity<>(HttpStatus.OK); } + + @PostMapping("/changecurriculumreq") + public ResponseEntity addChangeCurrReq(@RequestBody Map reqInfos){ + User user = userRepository.findById((Integer) reqInfos.get("userId")); + + Curriculum actualCurriculum = curriculumRepository.findById((Integer) reqInfos.get("actualcursus")); + + Curriculum destinationCurriculum = curriculumRepository.findById((Integer) reqInfos.get("newcursus")); + + ChangeCurriculumRequest changeCurriculumRequest = new ChangeCurriculumRequest(user, actualCurriculum, destinationCurriculum, new Date(), RequestState.Pending); + + changeCurriculumRequestRepository.save(changeCurriculumRequest); + + return new ResponseEntity<>(HttpStatus.OK); + } } 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 11ca6fd..918a924 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -93,12 +93,12 @@ public class MockController { curriculumService.save(masterinfo1); curriculumService.save(masterinfo2); - ucr.save(new UserCurriculum(joe, infoBab1, 2022)); - ucr.save(new UserCurriculum(joe, chemistryBab1, 2023)); - ucr.save(new UserCurriculum(joe, infoBab1, 2023)); - ucr.save(new UserCurriculum(joe, psychologyBab1, 2020)); - ucr.save(new UserCurriculum(popo, infoBab1, 2022)); - ucr.save(new UserCurriculum(popo, infoBab2, 2023)); + ucr.save(new UserCurriculum(joe, infoBab1, 2022, false)); + ucr.save(new UserCurriculum(joe, chemistryBab1, 2023, true)); + ucr.save(new UserCurriculum(joe, infoBab1, 2023, true)); + ucr.save(new UserCurriculum(joe, psychologyBab1, 2020, false)); + ucr.save(new UserCurriculum(popo, infoBab1, 2022, false)); + ucr.save(new UserCurriculum(popo, infoBab2, 2023, true)); Course progra1 = new Course(5,"Programmation et algorithmique 1",joke); Course chemistry1 = new Course(12, "Thermochimie",joke); diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ChangeCurriculumRequestRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ChangeCurriculumRequestRepository.java new file mode 100644 index 0000000..414f119 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ChangeCurriculumRequestRepository.java @@ -0,0 +1,7 @@ +package ovh.herisson.Clyde.Repositories.Inscription; + +import org.springframework.data.repository.CrudRepository; +import ovh.herisson.Clyde.Tables.ChangeCurriculumRequest; + +public interface ChangeCurriculumRequestRepository extends CrudRepository { +} 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 c80e2d9..a40f537 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 @@ -12,6 +12,7 @@ import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest; import ovh.herisson.Clyde.Tables.Inscription.Minerval; import java.util.ArrayList; +import java.util.Calendar; @Service public class InscriptionService { @@ -85,7 +86,8 @@ public class InscriptionService { ); userRepo.save(userFromRequest); - userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId()),0)); + Calendar c = Calendar.getInstance(); + userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId()),c.get(Calendar.YEAR), true)); //Create a minerval for the new student Minerval minerval = new Minerval(userFromRequest.getRegNo(), 0, 852, 2023); 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 8b446df..2861a6e 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/UserCurriculumService.java @@ -35,11 +35,12 @@ public class UserCurriculumService { HashMap element = new HashMap<>(); Curriculum c = list.get(i).getCurriculum(); - element.put("curriculumId", c.getCurriculumId()); element.put("year", c.getYear()); element.put("option", c.getOption()); element.put("dateyear", list.get(i).getYear()); + element.put("actual", list.get(i).isActual()); + curriculumlist.add(element); } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ChangeCurriculumRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ChangeCurriculumRequest.java new file mode 100644 index 0000000..72feebd --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ChangeCurriculumRequest.java @@ -0,0 +1,83 @@ +package ovh.herisson.Clyde.Tables; + +import jakarta.persistence.*; + +import java.util.Date; + +@Entity +public class ChangeCurriculumRequest { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + @ManyToOne + @JoinColumn(name="Users") + private User user; + + @ManyToOne + @JoinColumn(name = "ActualCurriculum") + private Curriculum actualCurriculum; + + @ManyToOne + @JoinColumn(name = "DestCurriculum") + private Curriculum destinationCurriculum; + + private Date date; + + private RequestState state; + + public ChangeCurriculumRequest(){} + + public ChangeCurriculumRequest(User user, Curriculum actualCurriculum, Curriculum destinationCurriculum, Date date, RequestState state){ + this.user = user; + this.actualCurriculum = actualCurriculum; + this.destinationCurriculum = destinationCurriculum; + this.date = date; + this.state = state; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + + public Curriculum getActualCurriculum() { + return actualCurriculum; + } + + public void setActualCurriculum(Curriculum actualCurriculum) { + this.actualCurriculum = actualCurriculum; + } + + public Curriculum getDestinationCurriculum() { + return destinationCurriculum; + } + + public void setDestinationCurriculum(Curriculum destinationCurriculum) { + this.destinationCurriculum = destinationCurriculum; + } + + public void setDate(Date date) { + this.date = date; + } + + public Date getDate() { + return date; + } + + public RequestState getState() { + return state; + } + + public void setState(RequestState state) { + this.state = state; + } + + public int getId() { + return id; + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCurriculum.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCurriculum.java index b79295b..395eca7 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCurriculum.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/UserCurriculum.java @@ -23,10 +23,14 @@ public class UserCurriculum { private int year; - public UserCurriculum(User user, Curriculum curriculum, int year){ + //True if the user has that curriculum at the moment false if not + private boolean actual; + + public UserCurriculum(User user, Curriculum curriculum, int year, boolean actual){ this.user = user; this.curriculum = curriculum; this.year = year; + this.actual = actual; } public UserCurriculum() {} @@ -58,4 +62,12 @@ public class UserCurriculum { public void setYear(int year) { this.year = year; } + + public void setActual(boolean actual) { + this.actual = actual; + } + + public boolean isActual() { + return actual; + } } diff --git a/frontend/src/Apps/Inscription/AboutStudent.vue b/frontend/src/Apps/Inscription/AboutStudent.vue index 03368c2..54d81fc 100644 --- a/frontend/src/Apps/Inscription/AboutStudent.vue +++ b/frontend/src/Apps/Inscription/AboutStudent.vue @@ -66,9 +66,9 @@
-
Bac {{item.year}}
-
{{item.option}}
-
Année {{item.dateyear}}-{{item.dateyear+1}}
+
Bac {{item.year}}
+
{{item.option}}
+
Année {{item.dateyear}}-{{item.dateyear+1}}
@@ -78,9 +78,9 @@
-
Bac {{item.year}}
-
{{item.option}}
-
Année {{item.dateyear}}-{{item.dateyear+1}}
+
Bac {{item.year}}
+
{{item.option}}
+
Année {{item.dateyear}}-{{item.dateyear+1}}
diff --git a/frontend/src/Apps/Profil.vue b/frontend/src/Apps/Profil.vue index f31f5da..28a0763 100644 --- a/frontend/src/Apps/Profil.vue +++ b/frontend/src/Apps/Profil.vue @@ -8,7 +8,7 @@ import CourseList from "@/Apps/Inscription/CourseList.vue"; import {editMinerval, getCurrentMinerval} from "@/rest/minerval.js"; import {postPayment} from "@/rest/payment.js"; - import {addUninscReq, createScholarshipRequest} from "@/rest/requests.js"; + import {addUninscReq, createScholarshipRequest, postChangeCurrReq} from "@/rest/requests.js"; const user = ref(await getSelf()); const UserCurriculum = ref(""); @@ -62,6 +62,12 @@ residencyDocUrl : "" }) + const changecurrdata = reactive({ + userId : user.value.regNo, + actualcursus:null, + newcursus:null + }) + //Used to post a uninscription request const uninscriptionData = reactive({ reason : null, @@ -132,7 +138,7 @@ function getActualCurriculumList(){ let actualCurriculumList = []; for (let i = 0; i < UserCurriculum.value.curriculumList.length; i++){ - if (UserCurriculum.value.curriculumList[i].dateyear === getYear()){ + if (UserCurriculum.value.curriculumList[i].actual === true){ actualCurriculumList.push(UserCurriculum.value.curriculumList[i]); } } @@ -281,20 +287,23 @@
- +
- {{i18n("Curriculum")}}: - + + + New Curriculum : +
-
- +
@@ -329,9 +338,9 @@
-
Bac {{item.year}}
-
{{item.option}}
-
Année {{item.dateyear}}-{{item.dateyear+1}}
+
Bac {{item.year}}
+
{{item.option}}
+
Année {{item.dateyear}}-{{item.dateyear+1}}
@@ -341,9 +350,9 @@
-
Bac {{item.year}}
-
{{item.option}}
-
Année {{item.dateyear}}-{{item.dateyear+1}}
+
Bac {{item.year}}
+
{{item.option}}
+
Année {{item.dateyear}}-{{item.dateyear+1}}
diff --git a/frontend/src/rest/requests.js b/frontend/src/rest/requests.js index 9d43968..a4396a4 100644 --- a/frontend/src/rest/requests.js +++ b/frontend/src/rest/requests.js @@ -46,4 +46,8 @@ export async function editUnregReq(id, newstate){ export async function getAllPayments(){ return restGet("/payment") +} + +export async function postChangeCurrReq(item){ + return restPost("/changecurriculumreq", item) } \ No newline at end of file From 1be7b4cdbe96c04b515decb983c8cf29c605065f Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Wed, 17 Apr 2024 13:57:52 +0200 Subject: [PATCH 5/8] Add the unregistration of a specific cursus only --- .../Inscription/RequestsController.java | 25 +++++++++++++++---- .../Clyde/EndPoints/MockController.java | 2 +- .../UserCurriculumRepository.java | 1 + .../Tables/Inscription/UnregisterRequest.java | 18 ++++++++++++- frontend/src/Apps/Profil.vue | 19 +++++++++++--- frontend/src/rest/requests.js | 4 +-- 6 files changed, 57 insertions(+), 12 deletions(-) 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 2b4f9d3..faeefb2 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 @@ -103,7 +103,15 @@ public class RequestsController { @PostMapping(value = "/unregister") public ResponseEntity postUnregReq(@RequestBody Map uninscr){ User u = userRepository.findById((int) uninscr.get("userId")); - UnregisterRequest ur = new UnregisterRequest(RequestState.Pending, (String) uninscr.get("reason"), new Date(), u.getRegNo(), u.getFirstName(), u.getLastName(), u.getEmail()); + Curriculum c; + + if (uninscr.get("curriculumId") == null){ + c = null; + }else{ + c = curriculumRepository.findById((Integer) uninscr.get("curriculumId")); + } + + UnregisterRequest ur = new UnregisterRequest(RequestState.Pending, (String) uninscr.get("reason"), new Date(), u.getRegNo(), u.getFirstName(), u.getLastName(), u.getEmail(), c); unregisterRequestRepository.save(ur); return new ResponseEntity<>(HttpStatus.OK); } @@ -149,11 +157,18 @@ public class RequestsController { unregisterRequest.setState(newstate); if (newstate == RequestState.Accepted){ - ArrayList userCurricula = userCurriculumRepository.findByUserOrderByCurriculum(u); - for (int i = 0; i < userCurricula.size(); i++){ - userCurricula.get(i).setActual(false); + if (unregisterRequest.getCurriculum() == null){ + ArrayList userCurricula = userCurriculumRepository.findByUserOrderByCurriculum(u); + for (int i = 0; i < userCurricula.size(); i++){ + userCurricula.get(i).setActual(false); + } + userCurriculumRepository.saveAll(userCurricula); + }else{ + //This usercurriculum will contain the usercurriculum to set false + UserCurriculum userCurriculum = userCurriculumRepository.findByUserAndCurriculumAndActual(u, unregisterRequest.getCurriculum(), true); + userCurriculum.setActual(false); + userCurriculumRepository.save(userCurriculum); } - userCurriculumRepository.saveAll(userCurricula); } unregisterRequestRepository.save(unregisterRequest); 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 918a924..3919597 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -128,7 +128,7 @@ public class MockController { inscriptionService.save(inscriptionRequest); - UnregisterRequest unregisterRequest = new UnregisterRequest(RequestState.Pending, "je veux partir", new Date(), joe.getRegNo(), joe.getFirstName(), joe.getLastName(), joe.getEmail()); + UnregisterRequest unregisterRequest = new UnregisterRequest(RequestState.Pending, "je veux partir", new Date(), joe.getRegNo(), joe.getFirstName(), joe.getLastName(), joe.getEmail(), null); uninscriptionRequestRepository.save(unregisterRequest); ExternalCurriculum externalCurriculum = new ExternalCurriculum(inscriptionRequest, "HEH", "Bachelier en informatique", "Completed", 2015, 2018, null, null); diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserCurriculumRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserCurriculumRepository.java index 2f1c2a3..dbf203e 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserCurriculumRepository.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/UserCurriculumRepository.java @@ -14,4 +14,5 @@ public interface UserCurriculumRepository extends CrudRepository findByUserOrderByCurriculum(User student); + UserCurriculum findByUserAndCurriculumAndActual(User user, Curriculum curriculum, boolean actual); } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/UnregisterRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/UnregisterRequest.java index ba22294..9127ecb 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/UnregisterRequest.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/UnregisterRequest.java @@ -1,6 +1,7 @@ package ovh.herisson.Clyde.Tables.Inscription; import jakarta.persistence.*; +import ovh.herisson.Clyde.Tables.Curriculum; import ovh.herisson.Clyde.Tables.RequestState; import ovh.herisson.Clyde.Tables.User; @@ -24,7 +25,12 @@ public class UnregisterRequest { private String email; - public UnregisterRequest(RequestState state, String reason, Date date, long regNo, String firstName, String lastName, String email){ + //Null if the user unregister for the academic year, contains a curriculum if the user wants to unregister from a specific curriculum + @ManyToOne + @JoinColumn(name = "Curriculum") + private Curriculum curriculum; + + public UnregisterRequest(RequestState state, String reason, Date date, long regNo, String firstName, String lastName, String email, Curriculum curriculum){ this.state = state; this.reason = reason; this.date = date; @@ -32,6 +38,7 @@ public class UnregisterRequest { this.firstName = firstName; this.lastName = lastName; this.email = email; + this.curriculum = curriculum; } public UnregisterRequest(){} @@ -95,5 +102,14 @@ public class UnregisterRequest { public long getRegNo() { return regNo; } + + public void setCurriculum(Curriculum curriculum) { + this.curriculum = curriculum; + } + + public Curriculum getCurriculum() { + return curriculum; + } + } diff --git a/frontend/src/Apps/Profil.vue b/frontend/src/Apps/Profil.vue index 28a0763..7a9fbc0 100644 --- a/frontend/src/Apps/Profil.vue +++ b/frontend/src/Apps/Profil.vue @@ -28,6 +28,8 @@ //0 base, 1 modif, 2 curriculum, 3 register, 4 courselist, 5 minerval, 6 payment, 7 scholarship, 8 scholarshipinfos, 9 unregister, 10 sure, 11 aboutunregister const windowState = ref(0); + const isChecked = ref(false); + const pattern = { profilPictureUrl:null, email:null, @@ -71,7 +73,8 @@ //Used to post a uninscription request const uninscriptionData = reactive({ reason : null, - userId : user.value.regNo + userId : user.value.regNo, + curriculumId:null }) const paymentAmount = ref(0); let toModify= Object.assign({}, pattern); @@ -194,14 +197,24 @@
-
Please enter the reason you leave the university
+
Please enter the reason you leave
+
+ I only want to unregister from a specific cursus + +
+
+ Please select that cursus + +
Are you sure that you want to unregister ? - +

You request has been send !

diff --git a/frontend/src/rest/requests.js b/frontend/src/rest/requests.js index a4396a4..4bf8411 100644 --- a/frontend/src/rest/requests.js +++ b/frontend/src/rest/requests.js @@ -20,8 +20,8 @@ export async function editEquivalenceState(id, newstate){ return restPatch("/request/registerequiv/"+id+"/"+newstate) } -export async function addUninscReq(userId, reason){ - return restPost("/unregister", {"userId" : userId, "reason" : reason}) +export async function addUninscReq(userId, reason, curriculumId){ + return restPost("/unregister", {"userId" : userId, "reason" : reason, "curriculumId":curriculumId}) } export async function editScholarshipReq(body){ From a27cf63daf9b7de35f8154a4c7c3d7d46977cea0 Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Wed, 17 Apr 2024 21:42:33 +0200 Subject: [PATCH 6/8] Add the post feature for differents types of changeCurriculumRequest --- .../Inscription/RequestsController.java | 9 +++- .../Clyde/EndPoints/MockController.java | 3 +- frontend/src/Apps/Profil.vue | 52 +++++++++++++++++-- 3 files changed, 59 insertions(+), 5 deletions(-) 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 faeefb2..83292ec 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 @@ -179,7 +179,14 @@ public class RequestsController { public ResponseEntity addChangeCurrReq(@RequestBody Map reqInfos){ User user = userRepository.findById((Integer) reqInfos.get("userId")); - Curriculum actualCurriculum = curriculumRepository.findById((Integer) reqInfos.get("actualcursus")); + Curriculum actualCurriculum; + + //If null then it means we are in a supplementary cursus case + if (reqInfos.get("actualcursus") == null){ + actualCurriculum = null; + }else{ + actualCurriculum = curriculumRepository.findById((Integer) reqInfos.get("actualcursus")); + } Curriculum destinationCurriculum = curriculumRepository.findById((Integer) reqInfos.get("newcursus")); 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 3919597..2181da0 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -85,13 +85,14 @@ public class MockController { Curriculum infoBab2 = new Curriculum(2,"info"); Curriculum masterinfo1 = new Curriculum(4, "info"); Curriculum masterinfo2 = new Curriculum(5, "info"); - + Curriculum chemistryBab2 = new Curriculum(2, "chemistry"); curriculumService.save(infoBab1); curriculumService.save(chemistryBab1); curriculumService.save(psychologyBab1); curriculumService.save(infoBab2); curriculumService.save(masterinfo1); curriculumService.save(masterinfo2); + curriculumService.save(chemistryBab2); ucr.save(new UserCurriculum(joe, infoBab1, 2022, false)); ucr.save(new UserCurriculum(joe, chemistryBab1, 2023, true)); diff --git a/frontend/src/Apps/Profil.vue b/frontend/src/Apps/Profil.vue index 7a9fbc0..eb9a80b 100644 --- a/frontend/src/Apps/Profil.vue +++ b/frontend/src/Apps/Profil.vue @@ -1,7 +1,7 @@ diff --git a/frontend/src/Apps/Login.vue b/frontend/src/Apps/Login.vue index dbac9e3..705012f 100644 --- a/frontend/src/Apps/Login.vue +++ b/frontend/src/Apps/Login.vue @@ -100,7 +100,7 @@