Leo/InscriptionDesEtudiants #156
@ -2,10 +2,7 @@ package ovh.herisson.Clyde.EndPoints;
|
||||
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ovh.herisson.Clyde.Repositories.MinervalRepository;
|
||||
import ovh.herisson.Clyde.Repositories.TokenRepository;
|
||||
import ovh.herisson.Clyde.Repositories.UserCurriculumRepository;
|
||||
import ovh.herisson.Clyde.Repositories.UserRepository;
|
||||
import ovh.herisson.Clyde.Repositories.*;
|
||||
import ovh.herisson.Clyde.Services.*;
|
||||
import ovh.herisson.Clyde.Tables.*;
|
||||
import java.util.ArrayList;
|
||||
@ -32,7 +29,9 @@ public class MockController {
|
||||
|
||||
public final MinervalRepository minervalRepository;
|
||||
|
||||
public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, InscriptionService inscriptionService, UserCurriculumRepository ucr, MinervalRepository minervalRepository){
|
||||
public final ScholarshipRequestRepository scholarshipRequestRepository;
|
||||
|
||||
public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, InscriptionService inscriptionService, UserCurriculumRepository ucr, MinervalRepository minervalRepository, ScholarshipRequestRepository scholarshipRequestRepository){
|
||||
this.tokenRepo = tokenRepo;
|
||||
this.userRepo = userRepo;
|
||||
this.tokenService = tokenService;
|
||||
@ -42,6 +41,7 @@ public class MockController {
|
||||
this.inscriptionService = inscriptionService;
|
||||
this.ucr = ucr;
|
||||
this.minervalRepository = minervalRepository;
|
||||
this.scholarshipRequestRepository = scholarshipRequestRepository;
|
||||
}
|
||||
|
||||
/** Saves an example of each user type by :
|
||||
@ -100,6 +100,8 @@ public class MockController {
|
||||
courseService.save(psycho1);
|
||||
courseService.save(commun);
|
||||
|
||||
ScholarshipRequest ssr1 = new ScholarshipRequest(joe, RequestState.Pending, 0, new Date(), "test", "test");
|
||||
scholarshipRequestRepository.save(ssr1);
|
||||
|
||||
CurriculumCourseService.save(new CurriculumCourse(infoBab1,progra1));
|
||||
CurriculumCourseService.save(new CurriculumCourse(infoBab1,commun));
|
||||
|
@ -2,15 +2,18 @@ package ovh.herisson.Clyde.EndPoints;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ovh.herisson.Clyde.Repositories.CourseRepository;
|
||||
import ovh.herisson.Clyde.Repositories.ExemptionsRequestRepository;
|
||||
import ovh.herisson.Clyde.Repositories.ScholarshipRequestRepository;
|
||||
import ovh.herisson.Clyde.Tables.ExemptionsRequest;
|
||||
import ovh.herisson.Clyde.Tables.RequestState;
|
||||
import ovh.herisson.Clyde.Tables.ScholarshipRequest;
|
||||
import ovh.herisson.Clyde.Repositories.UserRepository;
|
||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||
import ovh.herisson.Clyde.Tables.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
|
||||
@ -18,17 +21,25 @@ public class RequestsController {
|
||||
|
||||
public final ExemptionsRequestRepository err;
|
||||
public final ScholarshipRequestRepository srr;
|
||||
public final UserRepository userRepository;
|
||||
public final AuthenticatorService authServ;
|
||||
|
||||
public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr) {
|
||||
public final CourseRepository courseRepository;
|
||||
|
||||
public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr, UserRepository userRepository, AuthenticatorService authServ, CourseRepository courseRepository) {
|
||||
this.err = err;
|
||||
this.srr = srr;
|
||||
this.userRepository = userRepository;
|
||||
this.authServ = authServ;
|
||||
this.courseRepository = courseRepository;
|
||||
}
|
||||
|
||||
@PostMapping(value="/exemptionreq")
|
||||
public ResponseEntity<String> register(@RequestBody ExemptionsRequest exemptionsRequest){
|
||||
public ResponseEntity<String> createExemptionReq(@RequestBody Map<String, Object> exemptionsRequestInfo){
|
||||
User user = userRepository.findById((Integer) exemptionsRequestInfo.get("userRegNo"));
|
||||
Course course = courseRepository.findById((Integer) exemptionsRequestInfo.get("courseId"));
|
||||
|
||||
//This line ensures that the request is sent in pending state not matter what
|
||||
exemptionsRequest.setState(RequestState.Pending);
|
||||
ExemptionsRequest exemptionsRequest = new ExemptionsRequest(user, course, (String) exemptionsRequestInfo.get("justifDocument"), RequestState.Pending, new Date());
|
||||
|
||||
err.save(exemptionsRequest);
|
||||
|
||||
@ -36,13 +47,38 @@ public class RequestsController {
|
||||
}
|
||||
|
||||
@PostMapping(value="/scholarshipreq")
|
||||
public ResponseEntity<String> register(@RequestBody ScholarshipRequest scholarshipRequest){
|
||||
public ResponseEntity<String> createScholarshipReq(@RequestBody Map<String, Object> scholarshipRequestInfo){
|
||||
User user = userRepository.findById((Integer)scholarshipRequestInfo.get("userId"));
|
||||
ScholarshipRequest toCreate = new ScholarshipRequest(user, RequestState.Pending, 0, new Date(), (String) scholarshipRequestInfo.get("taxDocUrl"), (String) scholarshipRequestInfo.get("residencyDocUrl"));
|
||||
|
||||
//This line ensures that the request is sent in pending state not matter what
|
||||
scholarshipRequest.setState(RequestState.Pending);
|
||||
|
||||
srr.save(scholarshipRequest);
|
||||
srr.save(toCreate);
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
//Get all the exemptions Request
|
||||
@GetMapping(value = "/exemptionsreq")
|
||||
public ResponseEntity<ArrayList<ExemptionsRequest>> getAllExemptionsRequests(@RequestHeader("Authorization") String token){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
ArrayList<ExemptionsRequest> toReturn = new ArrayList<>();
|
||||
|
||||
err.findAll().forEach(toReturn::add);
|
||||
|
||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||
}
|
||||
|
||||
//Get all the scholarships requests
|
||||
@GetMapping(value = "/scholarshipreq")
|
||||
public ResponseEntity<ArrayList<ScholarshipRequest>> getAllScholarshipRequests(@RequestHeader("Authorization") String token){
|
||||
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
ArrayList<ScholarshipRequest> toReturn = new ArrayList<>();
|
||||
|
||||
srr.findAll().forEach(toReturn::add);
|
||||
|
||||
return new ResponseEntity<>(toReturn, HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,10 @@ package ovh.herisson.Clyde.Tables;
|
||||
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
public class ExemptionsRequest {
|
||||
@ -9,37 +13,44 @@ public class ExemptionsRequest {
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private int id;
|
||||
|
||||
private long userRegNo;
|
||||
private long courseId;
|
||||
@JoinColumn(name = "Users")
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
private User user;
|
||||
|
||||
@JoinColumn(name = "Course")
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
private Course course;
|
||||
private String justifDocument;
|
||||
|
||||
private RequestState state;
|
||||
|
||||
private Date date;
|
||||
|
||||
public ExemptionsRequest(Long userRegNo, long courseId, String justifDocument, RequestState state){
|
||||
this.userRegNo = userRegNo;
|
||||
this.courseId = courseId;
|
||||
public ExemptionsRequest(User user, Course course, String justifDocument, RequestState state, Date date){
|
||||
this.user = user;
|
||||
this.course = course;
|
||||
this.justifDocument = justifDocument;
|
||||
this.state = state;
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
|
||||
public ExemptionsRequest(){}
|
||||
|
||||
public Long getUserRegNo() {
|
||||
return userRegNo;
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUserRegNo(Long userRegNo) {
|
||||
this.userRegNo = userRegNo;
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public long getCourseId() {
|
||||
return courseId;
|
||||
public Course getCourse() {
|
||||
return course;
|
||||
}
|
||||
|
||||
public void setCourseId(long courseId) {
|
||||
this.courseId = courseId;
|
||||
public void setCourse(Course course) {
|
||||
this.course = course;
|
||||
}
|
||||
|
||||
public String getJustifDocument() {
|
||||
@ -58,4 +69,12 @@ public class ExemptionsRequest {
|
||||
public void setState(RequestState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package ovh.herisson.Clyde.Tables;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ -10,16 +12,17 @@ public class ScholarshipRequest {
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long id;
|
||||
|
||||
private long userId;
|
||||
@JoinColumn(name="Users")
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
private User user;
|
||||
private RequestState state;
|
||||
private Date date;
|
||||
private int amount;
|
||||
|
||||
private String taxDocUrl;
|
||||
private String residencyDocUrl;
|
||||
|
||||
public ScholarshipRequest(long userId, RequestState state, int amount, Date date, String taxDocUrl, String residencyDocUrl){
|
||||
this.userId = userId;
|
||||
public ScholarshipRequest(User user, RequestState state, int amount, Date date, String taxDocUrl, String residencyDocUrl){
|
||||
this.user = user;
|
||||
this.state = state;
|
||||
this.amount = amount;
|
||||
this.date = date;
|
||||
@ -29,12 +32,12 @@ public class ScholarshipRequest {
|
||||
|
||||
public ScholarshipRequest(){}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public RequestState getState() {
|
||||
|
@ -28,8 +28,7 @@ async function postExemptionRequest(file, type){
|
||||
const exemptReq = reactive({
|
||||
userRegNo : user.regNo,
|
||||
courseId : null,
|
||||
justifDocument : "e",
|
||||
state : null
|
||||
justifDocument : "",
|
||||
})
|
||||
</script>
|
||||
|
||||
|
@ -3,10 +3,14 @@
|
||||
import {ref} from 'vue'
|
||||
import {validateRegister, getAllRegisters } from '@/rest/ServiceInscription.js'
|
||||
import AboutRequest from "@/Apps/AboutRequest.vue";
|
||||
import {getAllExemptionsRequest, getAllScholarShipsRequest} from "@/rest/requests.js";
|
||||
|
||||
const requests = ref(await getAllRegisters());
|
||||
let targetId = "";
|
||||
|
||||
const requestType = ref("inscription");
|
||||
const filterType = ref("None");
|
||||
|
||||
//0 = liste, 1 = détails, 2 = sure?
|
||||
let windowsState = ref(0);
|
||||
|
||||
@ -17,6 +21,18 @@
|
||||
}
|
||||
requests.value = await getAllRegisters();
|
||||
}
|
||||
|
||||
async function loadRequests(){
|
||||
if (requestType.value === "inscription"){
|
||||
requests.value = await getAllRegisters();
|
||||
}
|
||||
if (requestType.value === "scholarship"){
|
||||
requests.value = await getAllScholarShipsRequest();
|
||||
}
|
||||
if(requestType.value === "exemption"){
|
||||
requests.value = await getAllExemptionsRequest();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -27,18 +43,55 @@
|
||||
<button style="background-color:rgb(105,05,105);margin-left: 30%" @click="windowsState=0;">Retour</button>
|
||||
</div>
|
||||
<div v-if="windowsState === 0">
|
||||
<div style="margin-top: 2%;margin-left: 2%">
|
||||
<span>Request type : </span>
|
||||
<select v-model="requestType" @change="loadRequests()">
|
||||
<option>inscription</option>
|
||||
<option>scholarship</option>
|
||||
<option>exemption</option>
|
||||
</select>
|
||||
<span style="margin-left: 5%">
|
||||
Filter :
|
||||
<select v-model="filterType">
|
||||
<option>None</option>
|
||||
<option>Pending</option>
|
||||
<option>Accepted</option>
|
||||
<option>Refused</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
<div style='display:flex; justify-content:center; min-width:1140px;' v-for="item of requests">
|
||||
<div class="bodu">
|
||||
<div class="container">
|
||||
<div class="date">{{item.submissionDate.slice(0, 10)}}</div>
|
||||
<div class="state">{{item.state}}</div>
|
||||
<div class="surname">{{item.lastName}}</div>
|
||||
<div class="firstname">{{item.firstName}}</div>
|
||||
<div class="accept" v-if="item.state === 'Pending'"><button @click="windowsState=2;targetId=item.id;" style="background-color:rgb(0,105,50);">{{i18n("request.accept")}}</button></div>
|
||||
<div class="refuse" v-if="item.state === 'Pending'"><button @click="upPage(item.id,'Refused')" style="background-color:rgb(105,0,0);">{{i18n("request.refuse")}}</button></div>
|
||||
<div class="infos"><button style="background-color:rgb(105,05,105);" @click="targetId=item.id;windowsState=1;">{{i18n("request.moreInfos")}}</button></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bodu" v-if="filterType == 'None' || filterType == item.state">
|
||||
<div class="container" style="grid-template-columns:15% 15% 10% 14.2% 14.2% 14.2% 14.2%;grid-template-areas:'date state surname firstname accept refuse infos';" v-if="requestType === 'inscription'">
|
||||
<!--
|
||||
The condition below avoids an error occuring because loadRequests() finishes after the vue refresh
|
||||
then submissionDate is undefined an it triggers an error in the console despite the fact that it is working
|
||||
properly at the end.
|
||||
-->
|
||||
<div class="date" v-if="item.submissionDate !== undefined">{{item.submissionDate.slice(0, 10)}}</div>
|
||||
<div class="state">{{item.state}}</div>
|
||||
<div class="surname">{{item.lastName}}</div>
|
||||
<div class="firstname">{{item.firstName}}</div>
|
||||
<div class="accept" v-if="item.state === 'Pending'"><button @click="windowsState=2;targetId=item.id;" style="background-color:rgb(0,105,50);">{{i18n("request.accept")}}</button></div>
|
||||
<div class="refuse" v-if="item.state === 'Pending'"><button @click="upPage(item.id,'Refused')" style="background-color:rgb(105,0,0);">{{i18n("request.refuse")}}</button></div>
|
||||
<div class="infos"><button style="background-color:rgb(105,05,105);" @click="targetId=item.id;windowsState=1;">{{i18n("request.moreInfos")}}</button></div>
|
||||
</div>
|
||||
<div class="container" style="grid-template-columns:25% 15% 15% 25% 14.2%;grid-template-areas:'date reqState studentfirstname studentlastname infos';" v-if="requestType === 'scholarship'">
|
||||
<div class="date" v-if="item.date !== undefined"> {{item.date.slice(0,10)}}</div>
|
||||
<div class="studentfirstname">{{item.user.firstName}}</div>
|
||||
<div class="studentlastname">{{item.user.lastName}}</div>
|
||||
<div class="reqState">{{item.state}}</div>
|
||||
<div class="infos"><button>More infos</button></div>
|
||||
</div>
|
||||
<div class="container" style="grid-template-columns:17% 15% 12% 15% 25%;grid-template-areas:'date reqState studentfirstname studentlastname course infos';"v-if="requestType === 'exemption'">
|
||||
<div class="date" v-if="item.date != undefined">{{item.date.slice(0,10)}}</div>
|
||||
<div class="studentfirstname">{{item.user.firstName}}</div>
|
||||
<div class="studentlastname">{{item.user.lastName}}</div>
|
||||
<div class="course">{{item.course.title}}</div>
|
||||
<div class="reqState">{{item.state}}</div>
|
||||
<div class="infos"><button>More infos</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style='display:flex; justify-content:center; min-width:1140px;margin-top: 10%' v-if="windowsState === 2">
|
||||
@ -54,12 +107,27 @@
|
||||
height:100px;
|
||||
font-size:20px;
|
||||
display:grid;
|
||||
grid-template-columns:15% 15% 10% 14.2% 14.2% 14.2% 14.2%;
|
||||
grid-template-areas:
|
||||
"date state surname firstname accept refuse infos";
|
||||
column-gap:10px;
|
||||
}
|
||||
|
||||
|
||||
.studentfirstname{
|
||||
grid-area: studentfirstname;
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.studentlastname{
|
||||
grid-area: studentlastname;
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.course{
|
||||
grid-area: course;
|
||||
align-self: center;
|
||||
}
|
||||
.reqState{
|
||||
grid-area: reqState;
|
||||
align-self: center;
|
||||
}
|
||||
.infos {
|
||||
grid-area:infos;
|
||||
align-self:center;
|
||||
|
@ -306,8 +306,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="modif==false && curric==false && reg==false && minerval==false && scholarship == false"class="moreInfos">
|
||||
<div class = "oldcursus">
|
||||
<div v-if="user.role == 'Student' && modif==false && curric==false && reg==false && minerval==false && scholarship == false" class="moreInfos">
|
||||
<div class = "oldcursus">
|
||||
<div class="listTitle">
|
||||
Anciens Cursus
|
||||
</div>
|
||||
|
@ -1,9 +1,17 @@
|
||||
import {restPost} from "@/rest/restConsumer.js";
|
||||
import {restGet, restPost} from "@/rest/restConsumer.js";
|
||||
|
||||
export async function createExemptionsRequest(exempReq){
|
||||
return restPost("/exemptionreq", exempReq)
|
||||
}
|
||||
|
||||
export async function createScholarshipRequest(scholReq){
|
||||
return restPost("/scholarshipreq", scholReq)
|
||||
export async function createScholarshipRequest(reqInfo){
|
||||
return restPost("/scholarshipreq", reqInfo)
|
||||
}
|
||||
|
||||
export async function getAllScholarShipsRequest(){
|
||||
return restGet("/scholarshipreq")
|
||||
}
|
||||
|
||||
export async function getAllExemptionsRequest(){
|
||||
return restGet("/exemptionsreq")
|
||||
}
|
Loading…
Reference in New Issue
Block a user