Add the display for unregister requests
Rename all ocurrences of uninscription to unregister Rework the uninscriptionRequest so we have an history and it doesn't take an user so better security
This commit is contained in:
parent
a89d1b192c
commit
c434b28fe3
@ -6,16 +6,15 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import ovh.herisson.Clyde.Repositories.CourseRepository;
|
import ovh.herisson.Clyde.Repositories.CourseRepository;
|
||||||
import ovh.herisson.Clyde.Repositories.Inscription.ExemptionsRequestRepository;
|
import ovh.herisson.Clyde.Repositories.Inscription.ExemptionsRequestRepository;
|
||||||
import ovh.herisson.Clyde.Repositories.Inscription.ScholarshipRequestRepository;
|
import ovh.herisson.Clyde.Repositories.Inscription.ScholarshipRequestRepository;
|
||||||
import ovh.herisson.Clyde.Repositories.Inscription.UninscriptionRequestRepository;
|
import ovh.herisson.Clyde.Repositories.Inscription.UnregisterRequestRepository;
|
||||||
import ovh.herisson.Clyde.Repositories.UserRepository;
|
import ovh.herisson.Clyde.Repositories.UserRepository;
|
||||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||||
import ovh.herisson.Clyde.Tables.*;
|
import ovh.herisson.Clyde.Tables.*;
|
||||||
import ovh.herisson.Clyde.Tables.Inscription.ExemptionsRequest;
|
import ovh.herisson.Clyde.Tables.Inscription.ExemptionsRequest;
|
||||||
import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest;
|
import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest;
|
||||||
import ovh.herisson.Clyde.Tables.Inscription.UninscriptionRequest;
|
import ovh.herisson.Clyde.Tables.Inscription.UnregisterRequest;
|
||||||
|
|
||||||
import javax.swing.text.html.parser.Entity;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -28,15 +27,16 @@ public class RequestsController {
|
|||||||
public final ScholarshipRequestRepository srr;
|
public final ScholarshipRequestRepository srr;
|
||||||
public final UserRepository userRepository;
|
public final UserRepository userRepository;
|
||||||
public final AuthenticatorService authServ;
|
public final AuthenticatorService authServ;
|
||||||
public final UninscriptionRequestRepository uninscriptionRequestRepository;
|
public final UnregisterRequestRepository unregisterRequestRepository;
|
||||||
public final CourseRepository courseRepository;
|
public final CourseRepository courseRepository;
|
||||||
|
|
||||||
public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UninscriptionRequestRepository uninscriptionRequestRepository, CourseRepository courseRepository) {
|
|
||||||
|
public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UnregisterRequestRepository unregisterRequestRepository, CourseRepository courseRepository) {
|
||||||
this.err = err;
|
this.err = err;
|
||||||
this.srr = srr;
|
this.srr = srr;
|
||||||
this.userRepository = userRepository;
|
this.userRepository = userRepository;
|
||||||
this.authServ = authServ;
|
this.authServ = authServ;
|
||||||
this.uninscriptionRequestRepository = uninscriptionRequestRepository;
|
this.unregisterRequestRepository = unregisterRequestRepository;
|
||||||
this.courseRepository = courseRepository;
|
this.courseRepository = courseRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,11 +88,11 @@ public class RequestsController {
|
|||||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/uninscriptionreq")
|
@PostMapping(value = "/unregister")
|
||||||
public ResponseEntity<String> postUnregReq(@RequestBody Map<String,Object> uninscr){
|
public ResponseEntity<String> postUnregReq(@RequestBody Map<String,Object> uninscr){
|
||||||
User u = userRepository.findById((int) uninscr.get("userId"));
|
User u = userRepository.findById((int) uninscr.get("userId"));
|
||||||
UninscriptionRequest ur = new UninscriptionRequest(RequestState.Pending, (String) uninscr.get("reason"), new Date(), u);
|
UnregisterRequest ur = new UnregisterRequest(RequestState.Pending, (String) uninscr.get("reason"), new Date(), u.getRegNo(), u.getFirstName(), u.getLastName(), u.getEmail());
|
||||||
uninscriptionRequestRepository.save(ur);
|
unregisterRequestRepository.save(ur);
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,4 +116,11 @@ public class RequestsController {
|
|||||||
ScholarshipRequest toReturn = srr.findById(id);
|
ScholarshipRequest toReturn = srr.findById(id);
|
||||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/unregister")
|
||||||
|
public ResponseEntity<ArrayList<UnregisterRequest>> getAllUnregReq(){
|
||||||
|
ArrayList<UnregisterRequest> toReturn = new ArrayList<>();
|
||||||
|
unregisterRequestRepository.findAll().forEach(toReturn::add);
|
||||||
|
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,11 @@ import ovh.herisson.Clyde.Repositories.*;
|
|||||||
import ovh.herisson.Clyde.Repositories.Inscription.ExternalCurriculumRepository;
|
import ovh.herisson.Clyde.Repositories.Inscription.ExternalCurriculumRepository;
|
||||||
import ovh.herisson.Clyde.Repositories.Inscription.MinervalRepository;
|
import ovh.herisson.Clyde.Repositories.Inscription.MinervalRepository;
|
||||||
import ovh.herisson.Clyde.Repositories.Inscription.ScholarshipRequestRepository;
|
import ovh.herisson.Clyde.Repositories.Inscription.ScholarshipRequestRepository;
|
||||||
|
import ovh.herisson.Clyde.Repositories.Inscription.UnregisterRequestRepository;
|
||||||
import ovh.herisson.Clyde.Services.*;
|
import ovh.herisson.Clyde.Services.*;
|
||||||
import ovh.herisson.Clyde.Services.Inscription.InscriptionService;
|
import ovh.herisson.Clyde.Services.Inscription.InscriptionService;
|
||||||
import ovh.herisson.Clyde.Tables.*;
|
import ovh.herisson.Clyde.Tables.*;
|
||||||
import ovh.herisson.Clyde.Tables.Inscription.ExternalCurriculum;
|
import ovh.herisson.Clyde.Tables.Inscription.*;
|
||||||
import ovh.herisson.Clyde.Tables.Inscription.InscriptionRequest;
|
|
||||||
import ovh.herisson.Clyde.Tables.Inscription.Minerval;
|
|
||||||
import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -40,7 +38,8 @@ public class MockController {
|
|||||||
|
|
||||||
public final ScholarshipRequestRepository scholarshipRequestRepository;
|
public final ScholarshipRequestRepository scholarshipRequestRepository;
|
||||||
|
|
||||||
public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, ExternalCurriculumRepository externalCurriculumRepository, InscriptionService inscriptionService, UserCurriculumRepository ucr, MinervalRepository minervalRepository, ScholarshipRequestRepository scholarshipRequestRepository){
|
public final UnregisterRequestRepository uninscriptionRequestRepository;
|
||||||
|
public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, ExternalCurriculumRepository externalCurriculumRepository, InscriptionService inscriptionService, UserCurriculumRepository ucr, MinervalRepository minervalRepository, ScholarshipRequestRepository scholarshipRequestRepository, UnregisterRequestRepository unregisterRequestRepository){
|
||||||
this.tokenRepo = tokenRepo;
|
this.tokenRepo = tokenRepo;
|
||||||
this.userRepo = userRepo;
|
this.userRepo = userRepo;
|
||||||
this.tokenService = tokenService;
|
this.tokenService = tokenService;
|
||||||
@ -52,6 +51,7 @@ public class MockController {
|
|||||||
this.ucr = ucr;
|
this.ucr = ucr;
|
||||||
this.minervalRepository = minervalRepository;
|
this.minervalRepository = minervalRepository;
|
||||||
this.scholarshipRequestRepository = scholarshipRequestRepository;
|
this.scholarshipRequestRepository = scholarshipRequestRepository;
|
||||||
|
this.uninscriptionRequestRepository = unregisterRequestRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Saves an example of each user type by :
|
/** Saves an example of each user type by :
|
||||||
@ -128,6 +128,9 @@ public class MockController {
|
|||||||
|
|
||||||
inscriptionService.save(inscriptionRequest);
|
inscriptionService.save(inscriptionRequest);
|
||||||
|
|
||||||
|
UnregisterRequest unregisterRequest = new UnregisterRequest(RequestState.Pending, "je veux partir", new Date(), joe.getRegNo(), joe.getFirstName(), joe.getLastName(), joe.getEmail());
|
||||||
|
uninscriptionRequestRepository.save(unregisterRequest);
|
||||||
|
|
||||||
ExternalCurriculum externalCurriculum = new ExternalCurriculum(inscriptionRequest, "HEH", "Bachelier en informatique", "Completed", 2015, 2018, null, null);
|
ExternalCurriculum externalCurriculum = new ExternalCurriculum(inscriptionRequest, "HEH", "Bachelier en informatique", "Completed", 2015, 2018, null, null);
|
||||||
externalCurriculumRepository.save(externalCurriculum);
|
externalCurriculumRepository.save(externalCurriculum);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
package ovh.herisson.Clyde.Repositories.Inscription;
|
|
||||||
|
|
||||||
import org.springframework.data.repository.CrudRepository;
|
|
||||||
import ovh.herisson.Clyde.Tables.Inscription.UninscriptionRequest;
|
|
||||||
|
|
||||||
public interface UninscriptionRequestRepository extends CrudRepository<UninscriptionRequest, Long> {
|
|
||||||
}
|
|
@ -0,0 +1,8 @@
|
|||||||
|
package ovh.herisson.Clyde.Repositories.Inscription;
|
||||||
|
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import ovh.herisson.Clyde.Tables.Inscription.UnregisterRequest;
|
||||||
|
|
||||||
|
public interface UnregisterRequestRepository extends CrudRepository<UnregisterRequest, Long> {
|
||||||
|
|
||||||
|
}
|
@ -1,67 +0,0 @@
|
|||||||
package ovh.herisson.Clyde.Tables.Inscription;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import ovh.herisson.Clyde.Tables.RequestState;
|
|
||||||
import ovh.herisson.Clyde.Tables.User;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
public class UninscriptionRequest {
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
|
||||||
private long id;
|
|
||||||
private RequestState state;
|
|
||||||
private String reason;
|
|
||||||
private Date date;
|
|
||||||
|
|
||||||
@JoinColumn(name = "Users")
|
|
||||||
@ManyToOne(fetch = FetchType.EAGER)
|
|
||||||
private User user;
|
|
||||||
|
|
||||||
public UninscriptionRequest(RequestState state,String reason, Date date, User user){
|
|
||||||
this.state = state;
|
|
||||||
this.reason = reason;
|
|
||||||
this.date = date;
|
|
||||||
this.user = user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UninscriptionRequest(){}
|
|
||||||
|
|
||||||
public RequestState getState() {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setState(RequestState state) {
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReason() {
|
|
||||||
return reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReason(String reason) {
|
|
||||||
this.reason = reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public User getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUser(User user) {
|
|
||||||
this.user = user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDate(Date date) {
|
|
||||||
this.date = date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getDate() {
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,99 @@
|
|||||||
|
package ovh.herisson.Clyde.Tables.Inscription;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import ovh.herisson.Clyde.Tables.RequestState;
|
||||||
|
import ovh.herisson.Clyde.Tables.User;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class UnregisterRequest {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private long id;
|
||||||
|
private RequestState state;
|
||||||
|
private String reason;
|
||||||
|
private Date date;
|
||||||
|
|
||||||
|
//We store these informations again so if the user is deleted we still have the informations for history
|
||||||
|
private long regNo;
|
||||||
|
|
||||||
|
private String firstName;
|
||||||
|
|
||||||
|
private String lastName;
|
||||||
|
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
public UnregisterRequest(RequestState state, String reason, Date date, long regNo, String firstName, String lastName, String email){
|
||||||
|
this.state = state;
|
||||||
|
this.reason = reason;
|
||||||
|
this.date = date;
|
||||||
|
this.regNo = regNo;
|
||||||
|
this.firstName = firstName;
|
||||||
|
this.lastName = lastName;
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnregisterRequest(){}
|
||||||
|
|
||||||
|
public RequestState getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(RequestState state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReason(String reason) {
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDate(Date date) {
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getDate() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastName() {
|
||||||
|
return lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFirstName() {
|
||||||
|
return firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastName(String lastName) {
|
||||||
|
this.lastName = lastName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstName(String firstName) {
|
||||||
|
this.firstName = firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegNo(long regNo) {
|
||||||
|
this.regNo = regNo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getRegNo() {
|
||||||
|
return regNo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
import {ref} from 'vue'
|
import {ref} from 'vue'
|
||||||
import {validateRegister, getAllRegisters } from '@/rest/ServiceInscription.js'
|
import {validateRegister, getAllRegisters } from '@/rest/ServiceInscription.js'
|
||||||
import AboutRequest from "@/Apps/Inscription/AboutRequest.vue";
|
import AboutRequest from "@/Apps/Inscription/AboutRequest.vue";
|
||||||
import {getAllExemptionsRequest, getAllScholarShipsRequest} from "@/rest/requests.js";
|
import {getAllExemptionsRequest, getAllScholarShipsRequest, getAllUnregisters} from "@/rest/requests.js";
|
||||||
import AboutScholarship from "@/Apps/Inscription/AboutScholarship.vue";
|
import AboutScholarship from "@/Apps/Inscription/AboutScholarship.vue";
|
||||||
|
|
||||||
const requests = ref(await getAllRegisters());
|
const requests = ref(await getAllRegisters());
|
||||||
@ -22,14 +22,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function loadRequests(){
|
async function loadRequests(){
|
||||||
if (requestType.value === "inscription"){
|
switch (requestType.value){
|
||||||
|
case "inscription":
|
||||||
requests.value = await getAllRegisters();
|
requests.value = await getAllRegisters();
|
||||||
}
|
break;
|
||||||
if (requestType.value === "scholarship"){
|
case "scholarship":
|
||||||
requests.value = await getAllScholarShipsRequest();
|
requests.value = await getAllScholarShipsRequest();
|
||||||
}
|
break;
|
||||||
if(requestType.value === "exemption"){
|
case "exemption":
|
||||||
requests.value = await getAllExemptionsRequest();
|
requests.value = await getAllExemptionsRequest();
|
||||||
|
break;
|
||||||
|
case "unregister":
|
||||||
|
requests.value = await getAllUnregisters();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -47,6 +51,7 @@
|
|||||||
<option>inscription</option>
|
<option>inscription</option>
|
||||||
<option>scholarship</option>
|
<option>scholarship</option>
|
||||||
<option>exemption</option>
|
<option>exemption</option>
|
||||||
|
<option>unregister</option>
|
||||||
</select>
|
</select>
|
||||||
<span style="margin-left: 5%">
|
<span style="margin-left: 5%">
|
||||||
Filter :
|
Filter :
|
||||||
@ -90,6 +95,14 @@
|
|||||||
<div class="reqState">{{item.state}}</div>
|
<div class="reqState">{{item.state}}</div>
|
||||||
<div class="infos"><button>More infos</button></div>
|
<div class="infos"><button>More infos</button></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="container" v-if="requestType === 'unregister'" style="grid-template-columns:17% 15% 12% 15%;grid-template-areas:'date reqState regno studentfirstname studentlastname infos';">
|
||||||
|
<div class="date" v-if="item.date != undefined">{{item.date.slice(0,10)}}</div>
|
||||||
|
<div class="studentfirstname">{{item.firstName}}</div>
|
||||||
|
<div class="studentlastname">{{item.lastName}}</div>
|
||||||
|
<div class="regno">id : {{item.regNo}}</div>
|
||||||
|
<div class="reqState">{{item.state}}</div>
|
||||||
|
<div class="infos"><button>More infos</button></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -158,6 +171,10 @@
|
|||||||
align-self:center;
|
align-self:center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.regno{
|
||||||
|
grid-area: regno;
|
||||||
|
align-self: center;
|
||||||
|
}
|
||||||
.state{
|
.state{
|
||||||
grid-area:state;
|
grid-area:state;
|
||||||
margin-left:40px;
|
margin-left:40px;
|
||||||
|
@ -21,7 +21,7 @@ export async function editEquivalenceState(id, newstate){
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function addUninscReq(userId, reason){
|
export async function addUninscReq(userId, reason){
|
||||||
return restPost("/uninscriptionreq", {"userId" : userId, "reason" : reason})
|
return restPost("/unregister", {"userId" : userId, "reason" : reason})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function editScholarshipReq(body){
|
export async function editScholarshipReq(body){
|
||||||
@ -31,3 +31,7 @@ export async function editScholarshipReq(body){
|
|||||||
export async function getScholarshipReqById(id){
|
export async function getScholarshipReqById(id){
|
||||||
return restGet("/scholarshipreq/"+id)
|
return restGet("/scholarshipreq/"+id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getAllUnregisters(){
|
||||||
|
return restGet("/unregister")
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user