diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java index d4fdaa0..b2dcd50 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java @@ -70,6 +70,9 @@ public class ApplicationsController { if (!authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token)){ authorizedApps.add(Applications.UsersList);} + + if (!authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin, Role.InscriptionService},token)){ + authorizedApps.add(Applications.Payments);} return authorizedApps; } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/PaymentController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/PaymentController.java index b70ad59..9a16fb2 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/PaymentController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/Inscription/PaymentController.java @@ -34,4 +34,12 @@ public class PaymentController { return new ResponseEntity<>(toReturn, HttpStatus.OK); } + @GetMapping("/payment") + public ResponseEntity> getAllPayments(){ + ArrayList toReturn = new ArrayList(); + + + paymentRepository.findAll().forEach(toReturn::add); + return new ResponseEntity<>(toReturn, 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 d30dab7..934e37c 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 @@ -10,6 +10,7 @@ import ovh.herisson.Clyde.Repositories.Inscription.UnregisterRequestRepository; import ovh.herisson.Clyde.Repositories.UserRepository; import ovh.herisson.Clyde.Responses.UnauthorizedResponse; import ovh.herisson.Clyde.Services.AuthenticatorService; +import ovh.herisson.Clyde.Services.UserService; import ovh.herisson.Clyde.Tables.*; import ovh.herisson.Clyde.Tables.Inscription.ExemptionsRequest; import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest; @@ -29,15 +30,16 @@ public class RequestsController { public final AuthenticatorService authServ; public final UnregisterRequestRepository unregisterRequestRepository; public final CourseRepository courseRepository; + public final UserService userService; - - public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UnregisterRequestRepository unregisterRequestRepository, CourseRepository courseRepository) { + public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UnregisterRequestRepository unregisterRequestRepository, CourseRepository courseRepository, UserService userService) { this.err = err; this.srr = srr; this.userRepository = userRepository; this.authServ = authServ; this.unregisterRequestRepository = unregisterRequestRepository; this.courseRepository = courseRepository; + this.userService = userService; } @PostMapping(value="/exemptionreq") @@ -123,4 +125,24 @@ public class RequestsController { unregisterRequestRepository.findAll().forEach(toReturn::add); return new ResponseEntity<>(toReturn, HttpStatus.OK); } + + @GetMapping(value = "/unregister/{id}") + public ResponseEntity getUnregbyId(@PathVariable long id){ + UnregisterRequest unregisterRequest = unregisterRequestRepository.findById(id); + return new ResponseEntity<>(unregisterRequest, HttpStatus.OK); + } + + @PatchMapping(value = "/unregister/{id}/{newstate}") + public ResponseEntity pathUnregReq(@PathVariable long id, @PathVariable RequestState newstate){ + UnregisterRequest unregisterRequest = unregisterRequestRepository.findById(id); + + unregisterRequest.setState(newstate); + + if (newstate == RequestState.Accepted){ + userService.delete(userRepository.findById(unregisterRequest.getRegNo())); + } + + unregisterRequestRepository.save(unregisterRequest); + return new ResponseEntity<>(HttpStatus.OK); + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/UnregisterRequestRepository.java b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/UnregisterRequestRepository.java index 8e6ab5a..f6a4ebc 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/UnregisterRequestRepository.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Repositories/Inscription/UnregisterRequestRepository.java @@ -4,5 +4,5 @@ import org.springframework.data.repository.CrudRepository; import ovh.herisson.Clyde.Tables.Inscription.UnregisterRequest; public interface UnregisterRequestRepository extends CrudRepository { - + public UnregisterRequest findById(long l); } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java index 5c39891..77a7074 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java @@ -19,5 +19,6 @@ public enum Applications { // InscriptionService authorization Requests, - StudentsList + StudentsList, + Payments } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/Payment.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/Payment.java index 48626e1..5f4fbf9 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/Payment.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/Payment.java @@ -12,7 +12,6 @@ public class Payment { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; - private long studentRegNo; private String card; private String client; diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ScholarshipRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ScholarshipRequest.java index 18ebee6..842bf90 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ScholarshipRequest.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/ScholarshipRequest.java @@ -7,15 +7,16 @@ import ovh.herisson.Clyde.Tables.RequestState; import ovh.herisson.Clyde.Tables.User; import java.util.Date; +import java.util.Map; @Entity public class ScholarshipRequest { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; - @JoinColumn(name="Users") @ManyToOne(fetch = FetchType.EAGER) + @OnDelete(action = OnDeleteAction.CASCADE) private User user; private RequestState state; private Date date; 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 2badd32..9f088a8 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/User.java @@ -1,6 +1,8 @@ package ovh.herisson.Clyde.Tables; import jakarta.persistence.*; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; import ovh.herisson.Clyde.Tables.Msg.Discussion; import ovh.herisson.Clyde.Tables.Msg.Message; diff --git a/frontend/public/i18n/EN.txt b/frontend/public/i18n/EN.txt index e79a8a1..2e860ac 100644 --- a/frontend/public/i18n/EN.txt +++ b/frontend/public/i18n/EN.txt @@ -28,6 +28,7 @@ app.language=Language app.manage.profile=Manage profile app.studentList=Students List app.users=Users +app.payments = Payments request.moreInfos=More Infos request.accept=Accept request.refuse=Refuse diff --git a/frontend/public/i18n/FR.txt b/frontend/public/i18n/FR.txt index c5f3ebf..de9af13 100644 --- a/frontend/public/i18n/FR.txt +++ b/frontend/public/i18n/FR.txt @@ -28,6 +28,7 @@ app.language=Langue app.manage.profile=Gérer le profil app.studentList=Liste des étudiants app.users=Utilisateurs +app.payments = Payements request.moreInfos=Plus d'Infos request.accept=Accepter request.refuse=Refuser @@ -52,3 +53,4 @@ Curriculum=Cursus Credits=Credits InscriptionService=S.I. faculty=Faculté + diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 1c219b9..485aaa8 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -67,7 +67,6 @@ window.addEventListener('hashchange', () => { {{i18n("app.manage.profile")}} - diff --git a/frontend/src/Apps/Inscription/AboutUnregister.vue b/frontend/src/Apps/Inscription/AboutUnregister.vue new file mode 100644 index 0000000..fe8f001 --- /dev/null +++ b/frontend/src/Apps/Inscription/AboutUnregister.vue @@ -0,0 +1,109 @@ + + + + + + \ 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