Add the unregistration of a specific cursus only
This commit is contained in:
parent
058c53dbbc
commit
1be7b4cdbe
@ -103,7 +103,15 @@ public class RequestsController {
|
||||
@PostMapping(value = "/unregister")
|
||||
public ResponseEntity<String> postUnregReq(@RequestBody Map<String,Object> 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){
|
||||
if (unregisterRequest.getCurriculum() == null){
|
||||
ArrayList<UserCurriculum> 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);
|
||||
}
|
||||
}
|
||||
|
||||
unregisterRequestRepository.save(unregisterRequest);
|
||||
|
@ -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);
|
||||
|
@ -14,4 +14,5 @@ public interface UserCurriculumRepository extends CrudRepository<UserCurriculum,
|
||||
Curriculum findByUser(User student);
|
||||
|
||||
ArrayList<UserCurriculum> findByUserOrderByCurriculum(User student);
|
||||
UserCurriculum findByUserAndCurriculumAndActual(User user, Curriculum curriculum, boolean actual);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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 @@
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="windowState === 9" class="infosContainer">
|
||||
<div v-if="sure !== 2">Please enter the reason you leave the university</div>
|
||||
<div v-if="sure !== 2">Please enter the reason you leave</div>
|
||||
<textarea v-if="sure !== 2" v-model="uninscriptionData.reason"></textarea>
|
||||
<div v-if="sure !== 2">
|
||||
I only want to unregister from a specific cursus
|
||||
<input type="checkbox" v-model="isChecked">
|
||||
</div>
|
||||
<div v-if="sure !== 2 && isChecked">
|
||||
Please select that cursus
|
||||
<select v-model="uninscriptionData.curriculumId">
|
||||
<option v-for="item in getActualCurriculumList()" :value="item.curriculumId">Bac {{item.year}} {{item.option}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-if="sure !== 2">
|
||||
<button @click="sure++">Submit</button>
|
||||
</div>
|
||||
<div v-if="sure==1">
|
||||
Are you sure that you want to unregister ?
|
||||
<button @click="addUninscReq(uninscriptionData.userId, uninscriptionData.reason);sure++">Yes</button>
|
||||
<button @click="addUninscReq(uninscriptionData.userId, uninscriptionData.reason, uninscriptionData.curriculumId);sure++">Yes</button>
|
||||
<button @click="sure=0">No</button>
|
||||
</div>
|
||||
<p v-if="sure==2">You request has been send !</p>
|
||||
|
@ -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){
|
||||
|
Loading…
Reference in New Issue
Block a user