From 5516f753464aff0cf3123edddb02b6c90d8c3151 Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Mon, 22 Apr 2024 18:27:06 +0200 Subject: [PATCH 1/6] Fixing stuffs --- .../Clyde/EndPoints/Inscription/RequestsController.java | 7 ++----- .../Inscription/ChangeCurriculumRequestRepository.java | 2 +- .../Tables/{ => Inscription}/ChangeCurriculumRequest.java | 5 ++++- frontend/src/Apps/Inscription/AboutChangeCurriculum.vue | 4 ++-- frontend/src/Apps/Profil.vue | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) rename backend/src/main/java/ovh/herisson/Clyde/Tables/{ => Inscription}/ChangeCurriculumRequest.java (92%) 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 65cbe4d..ae22329 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 @@ -13,10 +13,7 @@ import ovh.herisson.Clyde.Services.AuthenticatorService; 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; +import ovh.herisson.Clyde.Tables.Inscription.*; import java.util.ArrayList; import java.util.Calendar; @@ -328,7 +325,7 @@ public class RequestsController { return new ResponseEntity<>(HttpStatus.OK); } - toEdit.setState(newteacherstate); + toEdit.setTeacherApprovalState(newteacherstate); changeCurriculumRequestRepository.save(toEdit); if (newteacherstate == RequestState.Accepted && toEdit.getState() == RequestState.Accepted){ 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 index 0248e43..3aa815c 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ChangeCurriculumRequestRepository.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/ChangeCurriculumRequestRepository.java @@ -1,7 +1,7 @@ package ovh.herisson.Clyde.Repositories.Inscription; import org.springframework.data.repository.CrudRepository; -import ovh.herisson.Clyde.Tables.ChangeCurriculumRequest; +import ovh.herisson.Clyde.Tables.Inscription.ChangeCurriculumRequest; public interface ChangeCurriculumRequestRepository extends CrudRepository { ChangeCurriculumRequest findById(long id); diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/ChangeCurriculumRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ChangeCurriculumRequest.java similarity index 92% rename from backend/src/main/java/ovh/herisson/Clyde/Tables/ChangeCurriculumRequest.java rename to backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ChangeCurriculumRequest.java index a309023..b4a2436 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/ChangeCurriculumRequest.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ChangeCurriculumRequest.java @@ -1,6 +1,9 @@ -package ovh.herisson.Clyde.Tables; +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; import java.util.Date; diff --git a/frontend/src/Apps/Inscription/AboutChangeCurriculum.vue b/frontend/src/Apps/Inscription/AboutChangeCurriculum.vue index 588221c..e10854f 100644 --- a/frontend/src/Apps/Inscription/AboutChangeCurriculum.vue +++ b/frontend/src/Apps/Inscription/AboutChangeCurriculum.vue @@ -51,12 +51,12 @@ async function editChangeCurrReqTeacherApproval(state){
-
+
- +
diff --git a/frontend/src/Apps/Profil.vue b/frontend/src/Apps/Profil.vue index e4e942b..5e05ff2 100644 --- a/frontend/src/Apps/Profil.vue +++ b/frontend/src/Apps/Profil.vue @@ -343,19 +343,19 @@ - {{ i18n("newcurr") }} : + {{ i18n("newcursus") }} :
- {{ i18n("newcurr") }} : + {{ i18n("newcursus") }} :
- {{ i18n("newcurr") }} : + {{ i18n("newcursus") }} : From 772fa09e28e7b13ca7660e1281d14c92b13f5c38 Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Mon, 22 Apr 2024 20:35:30 +0200 Subject: [PATCH 2/6] Fixing tests and tokenService --- .../java/ovh/herisson/Clyde/Services/TokenService.java | 4 ++-- .../ovh/herisson/Clyde/Endpoints/UserControllerTest.java | 7 +++++-- .../java/ovh/herisson/Clyde/Services/TokenServiceTest.java | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java index c20977d..1cb3c2a 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java @@ -51,8 +51,8 @@ public class TokenService { ArrayList tokenList = tokenRepo.getByUserOrderByExpirationDate(token.getUser()); while(tokenList.size() >= 5){ - tokenRepo.delete(tokenList.getFirst()); - tokenList.remove(tokenList.getFirst()); + tokenRepo.delete(tokenList.get(0)); + tokenList.remove(tokenList.get(0)); } tokenRepo.save(token); } diff --git a/backend/src/test/java/ovh/herisson/Clyde/Endpoints/UserControllerTest.java b/backend/src/test/java/ovh/herisson/Clyde/Endpoints/UserControllerTest.java index 0d1322c..32682be 100644 --- a/backend/src/test/java/ovh/herisson/Clyde/Endpoints/UserControllerTest.java +++ b/backend/src/test/java/ovh/herisson/Clyde/Endpoints/UserControllerTest.java @@ -23,6 +23,7 @@ import ovh.herisson.Clyde.Repositories.TokenRepository; import ovh.herisson.Clyde.Repositories.UserRepository; import ovh.herisson.Clyde.Responses.UnauthorizedResponse; import ovh.herisson.Clyde.Services.TokenService; +import ovh.herisson.Clyde.Services.UserService; import ovh.herisson.Clyde.Tables.Role; import ovh.herisson.Clyde.Tables.Token; import ovh.herisson.Clyde.Tables.User; @@ -46,7 +47,8 @@ public class UserControllerTest { @Autowired private TokenService tokenService; - + @Autowired + private UserService userService; @Autowired private UserRepository userRepository; @Autowired @@ -72,6 +74,7 @@ public class UserControllerTest { @BeforeEach void setup(){ RestAssured.baseURI = "http://localhost:" + port; + userRepository.deleteAll(); } @AfterEach @@ -84,7 +87,7 @@ public class UserControllerTest { public void userPostTest(){ User god = new User("god","god","admin@admin.com","everywhere","every",new Date(0), null, Role.Admin,"goddoesntneedpassword"); Token godToken = new Token(god, tokenService.generateNewToken(), new Date()); - userRepository.save(god); + userService.save(god); tokenService.saveToken(godToken); //Can god post herobrine himself ? diff --git a/backend/src/test/java/ovh/herisson/Clyde/Services/TokenServiceTest.java b/backend/src/test/java/ovh/herisson/Clyde/Services/TokenServiceTest.java index 0e9a81a..8607ceb 100644 --- a/backend/src/test/java/ovh/herisson/Clyde/Services/TokenServiceTest.java +++ b/backend/src/test/java/ovh/herisson/Clyde/Services/TokenServiceTest.java @@ -70,7 +70,7 @@ class TokenServiceTest { ArrayList tokenList = new ArrayList<>(); GregorianCalendar gc = new GregorianCalendar(); - User malveillant = new User("Cargo", "John", "CargoJ@mail.com", "secret", "secret", null, null, null, "secret"); + User malveillant = new User("Cargo", "John", "CargoJ@mail.com", "secret", "secret", new Date(), null, "secret", null); userRepository.save(malveillant); for (int i = 0; i < 20; i++){ From 44bb04f21b5f2abf769544c90c7c39bb4485de5f Mon Sep 17 00:00:00 2001 From: Wawilski Date: Mon, 22 Apr 2024 20:49:39 +0200 Subject: [PATCH 3/6] Little Correction in schedules --- .../ovh/herisson/Clyde/EndPoints/MockController.java | 10 +++++----- frontend/src/Apps/Schedule.vue | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) 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 f98a7ee..7cb7665 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -185,11 +185,11 @@ public class MockController { //Schedule part - Lesson lesson_0_progra1 = new Lesson(progra1, "Mon Apr 22 2024 08:15", "Mon Apr 22 2024 10:15","rgb(0,50,100)","A0B2","Course"); - Lesson lesson_0_chemistry1 = new Lesson(chemistry1, "Wed Mar 27 2024 08:15", "Wed Mar 27 2024 09:15","rgb(100,50,0)","A0B2","TP"); - Lesson lesson_0_psycho1 = new Lesson(psycho1, "Sun Mar 24 2024 10:30 ","Sun Mar 24 2024 12:30 ","rgb(100,50,100)", "A0B2","TD"); - Lesson lesson_1_progra1 = new Lesson(progra1, "Mon Apr 02 2024 13:30", "Mon Apr 02 2024 15:30","rgb(0,50,100)","A0B2","TP"); - Lesson lesson_0_commun = new Lesson(commun, "Mon Apr 01 2024 10:30", "Mon Apr 01 2024 12:30","rgb(0,50,100)","A0B2","Course"); + Lesson lesson_0_progra1 = new Lesson(progra1, "Mon Apr 22 2024 08:15", "Mon Apr 22 2024 10:15","rgb(255,36,175)","A0B2","Course"); + Lesson lesson_0_chemistry1 = new Lesson(chemistry1, "Wed Mar 27 2024 08:15", "Wed Mar 27 2024 09:15","rgb(36,175,255)","A0B2","TP"); + Lesson lesson_0_psycho1 = new Lesson(psycho1, "Sun Mar 24 2024 10:30 ","Sun Mar 24 2024 12:30 ","rgb(255,36,175)", "A0B2","TD"); + Lesson lesson_1_progra1 = new Lesson(progra1, "Mon Apr 02 2024 13:30", "Mon Apr 02 2024 15:30","rgb(36,175,255)","A0B2","TP"); + Lesson lesson_0_commun = new Lesson(commun, "Mon Apr 01 2024 10:30", "Mon Apr 01 2024 12:30","rgb(255,36,175)","A0B2","Course"); LessonChangesRequest request1 = new LessonChangesRequest(joke,RequestState.Pending,null,null,null,null,2,null,1); LessonChangesRequest request2 = new LessonChangesRequest(joke,RequestState.Pending,"Fri Apr 19 2024 10:30 ","Fri Apr 19 2024 12:30 ",null,null,1,null,2); diff --git a/frontend/src/Apps/Schedule.vue b/frontend/src/Apps/Schedule.vue index 1ee30fd..a1e63ac 100644 --- a/frontend/src/Apps/Schedule.vue +++ b/frontend/src/Apps/Schedule.vue @@ -8,7 +8,7 @@