1
0
forked from PGL/Clyde

Implements the possibility to ask for a scholarship for a student

This commit is contained in:
LeoMoulin 2024-04-09 15:58:10 +02:00
parent e6e147af26
commit 21a5dbdb22
6 changed files with 126 additions and 29 deletions

View File

@ -7,26 +7,42 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import ovh.herisson.Clyde.Repositories.ExemptionsRequestRepository; import ovh.herisson.Clyde.Repositories.ExemptionsRequestRepository;
import ovh.herisson.Clyde.Repositories.ScholarshipRequestRepository;
import ovh.herisson.Clyde.Tables.ExemptionsRequest; import ovh.herisson.Clyde.Tables.ExemptionsRequest;
import ovh.herisson.Clyde.Tables.RequestState; import ovh.herisson.Clyde.Tables.RequestState;
import ovh.herisson.Clyde.Tables.ScholarshipRequest;
@RestController @RestController
@CrossOrigin(originPatterns = "*", allowCredentials = "true") @CrossOrigin(originPatterns = "*", allowCredentials = "true")
public class RequestsController { public class RequestsController {
public final ExemptionsRequestRepository err; public final ExemptionsRequestRepository err;
public final ScholarshipRequestRepository srr;
public RequestsController(ExemptionsRequestRepository err) { public RequestsController(ExemptionsRequestRepository err, ScholarshipRequestRepository srr) {
this.err = err; this.err = err;
this.srr = srr;
} }
@PostMapping(value="/exemptionreq") @PostMapping(value="/exemptionreq")
public ResponseEntity<String> register(@RequestBody ExemptionsRequest exemptionsRequest){ public ResponseEntity<String> register(@RequestBody ExemptionsRequest exemptionsRequest){
//This line ensures that the request is sent in pending state not matter what
exemptionsRequest.setState(RequestState.Pending); exemptionsRequest.setState(RequestState.Pending);
err.save(exemptionsRequest); err.save(exemptionsRequest);
return new ResponseEntity<>(HttpStatus.CREATED); return new ResponseEntity<>(HttpStatus.CREATED);
} }
@PostMapping(value="/scholarshipreq")
public ResponseEntity<String> register(@RequestBody ScholarshipRequest scholarshipRequest){
//This line ensures that the request is sent in pending state not matter what
scholarshipRequest.setState(RequestState.Pending);
srr.save(scholarshipRequest);
return new ResponseEntity<>(HttpStatus.CREATED);
}
} }

View File

@ -0,0 +1,8 @@
package ovh.herisson.Clyde.Repositories;
import org.springframework.data.repository.CrudRepository;
import ovh.herisson.Clyde.Tables.ScholarshipRequest;
public interface ScholarshipRequestRepository extends CrudRepository<ScholarshipRequest, Long> {
}

View File

@ -2,35 +2,39 @@ package ovh.herisson.Clyde.Tables;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.util.Date;
@Entity @Entity
public class ScholarshipRequest { public class ScholarshipRequest {
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)
private int id; private long id;
@ManyToOne private long userId;
@JoinColumn(name = "Users")
private User user;
private RequestState state; private RequestState state;
private String requestForm; private Date date;
private int amount; private int amount;
private String taxDocUrl;
private String residencyDocUrl;
public ScholarshipRequest(User user, RequestState state, String requestForm, int amount){ public ScholarshipRequest(long userId, RequestState state, int amount, Date date, String taxDocUrl, String residencyDocUrl){
this.user = user; this.userId = userId;
this.state = state; this.state = state;
this.requestForm = requestForm;
this.amount = amount; this.amount = amount;
this.date = date;
this.taxDocUrl = taxDocUrl;
this.residencyDocUrl = residencyDocUrl;
} }
public ScholarshipRequest(){} public ScholarshipRequest(){}
public User getUser() { public Long getUserId() {
return user; return userId;
} }
public void setUser(User user) { public void setUserId(Long userId) {
this.user = user; this.userId = userId;
} }
public RequestState getState() { public RequestState getState() {
@ -41,14 +45,6 @@ public class ScholarshipRequest {
this.state = state; this.state = state;
} }
public String getRequestForm() {
return requestForm;
}
public void setRequestForm(String requestForm) {
this.requestForm = requestForm;
}
public int getAmount() { public int getAmount() {
return amount; return amount;
} }
@ -56,4 +52,32 @@ public class ScholarshipRequest {
public void setAmount(int amount) { public void setAmount(int amount) {
this.amount = amount; this.amount = amount;
} }
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public long getId() {
return id;
}
public String getResidencyDocUrl() {
return residencyDocUrl;
}
public void setResidencyDocUrl(String residencyDocUrl) {
this.residencyDocUrl = residencyDocUrl;
}
public String getTaxDocUrl() {
return taxDocUrl;
}
public void setTaxDocUrl(String taxDocUrl) {
this.taxDocUrl = taxDocUrl;
}
} }

View File

@ -20,11 +20,6 @@ async function updateCourseList(){
courseslist.value = await getcurriculum(selectedCurriculum.value.curriculumId) courseslist.value = await getcurriculum(selectedCurriculum.value.curriculumId)
} }
async function uploadfileandgetpath(file, type){
const a = await uploadFile(file, type);
exemptReq.justifDocument = a.url
}
async function postExemptionRequest(file, type){ async function postExemptionRequest(file, type){
const a = await uploadFile(file, type); const a = await uploadFile(file, type);
exemptReq.justifDocument = a.url exemptReq.justifDocument = a.url

View File

@ -4,10 +4,11 @@
import {getSelfCurriculum, getAllCurriculums, getSomeonesCurriculumList} from '../rest/curriculum.js' import {getSelfCurriculum, getAllCurriculums, getSomeonesCurriculumList} from '../rest/curriculum.js'
import {getCourses} from "../rest/courses.js" import {getCourses} from "../rest/courses.js"
import i18n from "@/i18n.js" import i18n from "@/i18n.js"
import { uploadProfilePicture } from '@/rest/uploads.js' import {uploadFile, uploadProfilePicture} from '@/rest/uploads.js'
import CourseList from "@/Apps/CourseList.vue"; import CourseList from "@/Apps/CourseList.vue";
import {editMinerval, getCurrentMinerval} from "@/rest/minerval.js"; import {editMinerval, getCurrentMinerval} from "@/rest/minerval.js";
import {postPayment} from "@/rest/payment.js"; import {postPayment} from "@/rest/payment.js";
import {createScholarshipRequest} from "@/rest/requests.js";
const user = ref(await getSelf()); const user = ref(await getSelf());
const UserCurriculum = ref(""); const UserCurriculum = ref("");
@ -27,6 +28,8 @@
const courseslist = ref(false); const courseslist = ref(false);
const minerval = ref(false); const minerval = ref(false);
const paymentPage = ref(false); const paymentPage = ref(false);
const scholarship = ref(false);
const scholarshipinfos = ref(false);
const pattern = { const pattern = {
profilPictureUrl:null, profilPictureUrl:null,
email:null, email:null,
@ -50,6 +53,17 @@
expDate:null, expDate:null,
amount: null amount: null
} }
//Used to modelize a scholarship request
const scholarshipData=reactive({
userId: user.value.regNo,
state:null,
date:null,
amount:0,
taxDocUrl : "",
residencyDocUrl : ""
})
const paymentAmount = ref(0); const paymentAmount = ref(0);
let toModify= Object.assign({}, pattern); let toModify= Object.assign({}, pattern);
let personnalInfos = Object.assign({}, patternInfos); let personnalInfos = Object.assign({}, patternInfos);
@ -121,6 +135,18 @@
} }
return actualCurriculumList return actualCurriculumList
} }
async function postScholarshipRequest(file1, type1, file2, type2){
const a = await uploadFile(file1, type1)
scholarshipData.taxDocUrl = a.url;
const b = await uploadFile(file2, type2)
scholarshipData.residencyDocUrl = b.url;
scholarshipData.date = Date.now();
await createScholarshipRequest(scholarshipData)
}
</script> </script>
<template> <template>
@ -130,7 +156,7 @@
<img class="subContainter" :src=getPP()> <img class="subContainter" :src=getPP()>
</div> </div>
<div class="globalInfos"> <div class="globalInfos">
<div v-if="modif==false && curric==false && reg==false && minerval==false && paymentPage == false" class="infosContainer"> <div v-if="modif==false && curric==false && reg==false && minerval==false && paymentPage == false && scholarship==false" class="infosContainer">
<div> <div>
{{user.firstName}} {{user.lastName}} {{user.firstName}} {{user.lastName}}
</div> </div>
@ -171,6 +197,30 @@
<div v-else> <div v-else>
Payment : School fees have already been paid this year Payment : School fees have already been paid this year
</div> </div>
<div>
<button @click="scholarship=!scholarship; minerval=!minerval">Ask for a scholarship</button>
</div>
</div>
<div v-else-if="scholarship && !scholarshipinfos" class="infosContainer">
<p>Please upload the required documents</p>
<div>
Tax justification document :
<input type="file" @change="scholarshipData.taxDocUrl = $event.target.files">
</div>
<div>
Residency justification document :
<input type="file" style="margin-top:2%" @change="scholarshipData.residencyDocUrl = $event.target.files">
</div>
<button style="margin-top: 5%" @click="scholarshipinfos = !scholarshipinfos;postScholarshipRequest(scholarshipData.taxDocUrl, 'JustificationDocument',scholarshipData.residencyDocUrl, 'JustificationDocument');">Submit scholarship request</button>
</div>
<div v-else-if="scholarship && scholarshipinfos" class="infosContainer">
<div>
Your request has been sent to the inscription service you will get notified when
the request is reviewed.
</div>
<button @click="scholarshipinfos=!scholarshipinfos; scholarship=!scholarship">
Go back to profile
</button>
</div> </div>
<div v-else-if="paymentPage" class="infosContainer"> <div v-else-if="paymentPage" class="infosContainer">
Proceed to payment of {{paymentAmount}} Proceed to payment of {{paymentAmount}}
@ -256,7 +306,7 @@
</div> </div>
</div> </div>
</div> </div>
<div v-if="modif==false && curric==false && reg==false && minerval==false"class="moreInfos"> <div v-if="modif==false && curric==false && reg==false && minerval==false && scholarship == false"class="moreInfos">
<div class = "oldcursus"> <div class = "oldcursus">
<div class="listTitle"> <div class="listTitle">
Anciens Cursus Anciens Cursus

View File

@ -3,3 +3,7 @@ import {restPost} from "@/rest/restConsumer.js";
export async function createExemptionsRequest(exempReq){ export async function createExemptionsRequest(exempReq){
return restPost("/exemptionreq", exempReq) return restPost("/exemptionreq", exempReq)
} }
export async function createScholarshipRequest(scholReq){
return restPost("/scholarshipreq", scholReq)
}