Add the uninscription request submission
This commit is contained in:
parent
98c9d2d754
commit
05bff0fa77
@ -6,12 +6,14 @@ import org.springframework.web.bind.annotation.*;
|
||||
import ovh.herisson.Clyde.Repositories.CourseRepository;
|
||||
import ovh.herisson.Clyde.Repositories.Inscription.ExemptionsRequestRepository;
|
||||
import ovh.herisson.Clyde.Repositories.Inscription.ScholarshipRequestRepository;
|
||||
import ovh.herisson.Clyde.Repositories.Inscription.UninscriptionRequestRepository;
|
||||
import ovh.herisson.Clyde.Repositories.UserRepository;
|
||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||
import ovh.herisson.Clyde.Tables.*;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.ExemptionsRequest;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.ScholarshipRequest;
|
||||
import ovh.herisson.Clyde.Tables.Inscription.UninscriptionRequest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@ -25,14 +27,15 @@ public class RequestsController {
|
||||
public final ScholarshipRequestRepository srr;
|
||||
public final UserRepository userRepository;
|
||||
public final AuthenticatorService authServ;
|
||||
|
||||
public final UninscriptionRequestRepository uninscriptionRequestRepository;
|
||||
public final CourseRepository courseRepository;
|
||||
|
||||
public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, CourseRepository courseRepository) {
|
||||
public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, UninscriptionRequestRepository uninscriptionRequestRepository, CourseRepository courseRepository) {
|
||||
this.err = err;
|
||||
this.srr = srr;
|
||||
this.userRepository = userRepository;
|
||||
this.authServ = authServ;
|
||||
this.uninscriptionRequestRepository = uninscriptionRequestRepository;
|
||||
this.courseRepository = courseRepository;
|
||||
}
|
||||
|
||||
@ -83,4 +86,12 @@ public class RequestsController {
|
||||
|
||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/uninscriptionreq")
|
||||
public ResponseEntity<String> postUnregReq(@RequestBody Map<String,Object> uninscr){
|
||||
User u = userRepository.findById((int) uninscr.get("userId"));
|
||||
UninscriptionRequest ur = new UninscriptionRequest(RequestState.Pending, (String) uninscr.get("reason"), new Date(), u);
|
||||
uninscriptionRequestRepository.save(ur);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
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> {
|
||||
}
|
@ -1,20 +1,29 @@
|
||||
package ovh.herisson.Clyde.Tables.Inscription;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
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 int id;
|
||||
private long id;
|
||||
private RequestState state;
|
||||
private String reason;
|
||||
private Date date;
|
||||
|
||||
public UninscriptionRequest(RequestState state){
|
||||
@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(){}
|
||||
@ -26,4 +35,33 @@ public class UninscriptionRequest {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
import CourseList from "@/Apps/Inscription/CourseList.vue";
|
||||
import {editMinerval, getCurrentMinerval} from "@/rest/minerval.js";
|
||||
import {postPayment} from "@/rest/payment.js";
|
||||
import {createScholarshipRequest} from "@/rest/requests.js";
|
||||
import {addUninscReq, createScholarshipRequest} from "@/rest/requests.js";
|
||||
|
||||
const user = ref(await getSelf());
|
||||
const UserCurriculum = ref("");
|
||||
@ -30,6 +30,9 @@
|
||||
const paymentPage = ref(false);
|
||||
const scholarship = ref(false);
|
||||
const scholarshipinfos = ref(false);
|
||||
const uninscr = ref(false);
|
||||
const sure = ref(0);
|
||||
|
||||
const pattern = {
|
||||
profilPictureUrl:null,
|
||||
email:null,
|
||||
@ -64,6 +67,11 @@
|
||||
residencyDocUrl : ""
|
||||
})
|
||||
|
||||
//Used to post a uninscription request
|
||||
const uninscriptionData = reactive({
|
||||
reason : null,
|
||||
userId : user.value.regNo
|
||||
})
|
||||
const paymentAmount = ref(0);
|
||||
let toModify= Object.assign({}, pattern);
|
||||
let personnalInfos = Object.assign({}, patternInfos);
|
||||
@ -156,7 +164,7 @@
|
||||
<img class="subContainter" :src=getPP()>
|
||||
</div>
|
||||
<div class="globalInfos">
|
||||
<div v-if="modif==false && curric==false && reg==false && minerval==false && paymentPage == false && scholarship==false" class="infosContainer">
|
||||
<div v-if="modif==false && curric==false && reg==false && minerval==false && paymentPage == false && scholarship==false && uninscr == false" class="infosContainer">
|
||||
<div>
|
||||
{{user.firstName}} {{user.lastName}}
|
||||
</div>
|
||||
@ -174,7 +182,7 @@
|
||||
</div>
|
||||
<div v-if="(user.role==='Student')">
|
||||
<button @click="reg=!reg">{{i18n("profile.reRegister")}}</button>
|
||||
<button @click="unRegister()" style="float:right;background-color:rgb(150,0,0);">{{i18n("profile.unRegister")}}</button>
|
||||
<button @click="uninscr = !uninscr" style="float:right;background-color:rgb(150,0,0);">{{i18n("profile.unRegister")}}</button>
|
||||
</div>
|
||||
<div v-if="(user.role==='Student')">
|
||||
<button @click="curric=!curric">{{i18n("profile.change.curriculum")}}</button>
|
||||
@ -184,6 +192,19 @@
|
||||
<button @click="minerval = !minerval" style="margin-left: 2%">Manage minerval</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="uninscr" class="infosContainer">
|
||||
<div v-if="sure != 2">Please enter the reason you leave the university</div>
|
||||
<textarea v-if="sure != 2" v-model="uninscriptionData.reason"></textarea>
|
||||
<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="sure=0">No</button>
|
||||
</div>
|
||||
<p v-if="sure==2">You request has been send !</p>
|
||||
</div>
|
||||
<div v-else-if="minerval" class="infosContainer">
|
||||
<div v-if="minerv.value.toPay != 0">
|
||||
Payment : {{minerv.value.toPay}}€ left to pay
|
||||
@ -306,7 +327,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="user.role == 'Student' && modif==false && curric==false && reg==false && minerval==false && scholarship == false" class="moreInfos">
|
||||
<div v-if="user.role == 'Student' && modif==false && curric==false && reg==false && minerval==false && scholarship == false && uninscr == false" class="moreInfos">
|
||||
<div class = "oldcursus">
|
||||
<div class="listTitle">
|
||||
Anciens Cursus
|
||||
@ -405,7 +426,7 @@
|
||||
display:flex;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
margin-top:5%;
|
||||
margin-top:7%;
|
||||
}
|
||||
.containerElement{
|
||||
justify-content:center;
|
||||
|
@ -18,4 +18,8 @@ export async function getAllExemptionsRequest(){
|
||||
|
||||
export async function editEquivalenceState(id, newstate){
|
||||
return restPatch("/request/registerequiv/"+id+"/"+newstate)
|
||||
}
|
||||
|
||||
export async function addUninscReq(userId, reason){
|
||||
return restPost("/uninscriptionreq", {"userId" : userId, "reason" : reason})
|
||||
}
|
Loading…
Reference in New Issue
Block a user