From 3c721de18bd818d5554c21ca9825c9a12a40f9ed Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Sat, 6 Apr 2024 16:12:11 +0200 Subject: [PATCH] Big commit: make some changes to profile to provide an interface for a student to manage his courses. implements the submission of exemptions request --- .../Clyde/EndPoints/CourseController.java | 1 + .../Clyde/EndPoints/CurriculumController.java | 4 +- .../Clyde/EndPoints/MockController.java | 3 +- .../Clyde/EndPoints/RequestsController.java | 32 ++++ .../ExemptionsRequestRepository.java | 8 + .../Clyde/Tables/ExemptionsRequest.java | 31 ++-- .../ovh/herisson/Clyde/Tables/FileType.java | 5 +- frontend/src/Apps/AboutRequest.vue | 57 ++++++- frontend/src/Apps/AboutStudent.vue | 2 +- frontend/src/Apps/CourseList.vue | 145 ++++++++++++++++++ frontend/src/Apps/Profil.vue | 135 ++++++++++------ frontend/src/rest/ServiceInscription.js | 2 +- frontend/src/rest/curriculum.js | 4 + frontend/src/rest/requests.js | 5 + 14 files changed, 360 insertions(+), 74 deletions(-) create mode 100644 backend/src/main/java/ovh/herisson/Clyde/EndPoints/RequestsController.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Repositories/ExemptionsRequestRepository.java create mode 100644 frontend/src/Apps/CourseList.vue create mode 100644 frontend/src/rest/requests.js diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CourseController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CourseController.java index d5e87a8..474e2cb 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CourseController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CourseController.java @@ -135,4 +135,5 @@ public class CourseController { courseServ.delete(courseServ.findById(id)); return new ResponseEntity<>(HttpStatus.OK); } + } 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 4be7ba9..5f917e4 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java @@ -120,11 +120,11 @@ public class CurriculumController { } @GetMapping("/externalcurriculum/{inscriptionRequestId}") - public ResponseEntity> getInscriptionRequestExternalCurriculum(@RequestHeader("Authorization") String token, @PathVariable String inscriptionRequestId){ + public ResponseEntity> getInscriptionRequestExternalCurriculum(@RequestHeader("Authorization") String token, @PathVariable long inscriptionRequestId){ if (authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin, Role.Teacher},token)) return new UnauthorizedResponse<>(null); - HashMap toReturn = userCurriculumServ.findAllExternalCurriculumByInscriptionRequestId(Long.parseLong(inscriptionRequestId)); + HashMap toReturn = userCurriculumServ.findAllExternalCurriculumByInscriptionRequestId(inscriptionRequestId); if (toReturn == null) return new ResponseEntity<>(HttpStatus.BAD_REQUEST); 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 96e7be4..3fda0d5 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -79,6 +79,7 @@ public class MockController { 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)); @@ -96,7 +97,7 @@ public class MockController { CurriculumCourseService.save(new CurriculumCourse(infoBab1,progra1)); CurriculumCourseService.save(new CurriculumCourse(infoBab1,commun)); - + CurriculumCourseService.save(new CurriculumCourse(infoBab1, psycho1)); CurriculumCourseService.save(new CurriculumCourse(psychologyBab1,psycho1)); CurriculumCourseService.save(new CurriculumCourse(psychologyBab1,commun)); diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/RequestsController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/RequestsController.java new file mode 100644 index 0000000..e5865d2 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/RequestsController.java @@ -0,0 +1,32 @@ +package ovh.herisson.Clyde.EndPoints; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; +import ovh.herisson.Clyde.Repositories.ExemptionsRequestRepository; +import ovh.herisson.Clyde.Tables.ExemptionsRequest; +import ovh.herisson.Clyde.Tables.RequestState; + +@RestController +@CrossOrigin(originPatterns = "*", allowCredentials = "true") +public class RequestsController { + + public final ExemptionsRequestRepository err; + + public RequestsController(ExemptionsRequestRepository err) { + this.err = err; + } + + @PostMapping(value="/exemptionreq") + public ResponseEntity register(@RequestBody ExemptionsRequest exemptionsRequest){ + + exemptionsRequest.setState(RequestState.Pending); + + err.save(exemptionsRequest); + + return new ResponseEntity<>(HttpStatus.CREATED); + } +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/ExemptionsRequestRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ExemptionsRequestRepository.java new file mode 100644 index 0000000..917af1e --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/ExemptionsRequestRepository.java @@ -0,0 +1,8 @@ +package ovh.herisson.Clyde.Repositories; + +import org.springframework.data.repository.CrudRepository; +import ovh.herisson.Clyde.Tables.ExemptionsRequest; + +public interface ExemptionsRequestRepository extends CrudRepository { + +} diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ExemptionsRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/ExemptionsRequest.java index 1feacc8..ba01d15 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/ExemptionsRequest.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/ExemptionsRequest.java @@ -9,21 +9,16 @@ public class ExemptionsRequest { @GeneratedValue(strategy = GenerationType.AUTO) private int id; - @ManyToOne - @JoinColumn(name = "Users") - private User user; - - @ManyToOne - @JoinColumn(name = "Course") - private Course course; + private long userRegNo; + private long courseId; private String justifDocument; private RequestState state; - public ExemptionsRequest(User user, Course course, String justifDocument, RequestState state){ - this.user = user; - this.course = course; + public ExemptionsRequest(Long userRegNo, long courseId, String justifDocument, RequestState state){ + this.userRegNo = userRegNo; + this.courseId = courseId; this.justifDocument = justifDocument; this.state = state; } @@ -31,20 +26,20 @@ public class ExemptionsRequest { public ExemptionsRequest(){} - public User getUser() { - return user; + public Long getUserRegNo() { + return userRegNo; } - public void setUser(User user) { - this.user = user; + public void setUserRegNo(Long userRegNo) { + this.userRegNo = userRegNo; } - public Course getCourse() { - return course; + public long getCourseId() { + return courseId; } - public void setCourse(Course course) { - this.course = course; + public void setCourseId(long courseId) { + this.courseId = courseId; } public String getJustifDocument() { 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 18ce1be..e7a081b 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java @@ -1,8 +1,7 @@ package ovh.herisson.Clyde.Tables; public enum FileType { - ProfilePicture, - - EducationCertificate + EducationCertificate, + JustificationDocument } diff --git a/frontend/src/Apps/AboutRequest.vue b/frontend/src/Apps/AboutRequest.vue index 186f75c..05c76c5 100644 --- a/frontend/src/Apps/AboutRequest.vue +++ b/frontend/src/Apps/AboutRequest.vue @@ -1,13 +1,15 @@ + + + + + diff --git a/frontend/src/Apps/Profil.vue b/frontend/src/Apps/Profil.vue index 643cc7d..2471429 100644 --- a/frontend/src/Apps/Profil.vue +++ b/frontend/src/Apps/Profil.vue @@ -1,16 +1,18 @@