Implements some files uploading in the inscription form and change inscriptionRequest and Curriculum for the cursus acceptance attestation feature

This commit is contained in:
LeoMoulin 2024-04-19 12:26:48 +02:00
parent 5a57fc78f3
commit 25575fa4e0
7 changed files with 80 additions and 22 deletions

View File

@ -83,13 +83,15 @@ public class MockController {
minervalRepository.save(minerval);
// Course / Curriculum part
Curriculum infoBab1 = new Curriculum(1,"info");
Curriculum chemistryBab1 = new Curriculum(1,"chemistry");
Curriculum psychologyBab1 = new Curriculum(1,"psychology");
Curriculum infoBab2 = new Curriculum(2,"info");
Curriculum masterinfo1 = new Curriculum(4, "info");
Curriculum masterinfo2 = new Curriculum(5, "info");
Curriculum chemistryBab2 = new Curriculum(2, "chemistry");
Curriculum infoBab1 = new Curriculum(1,"info", false);
Curriculum chemistryBab1 = new Curriculum(1,"chemistry", false);
Curriculum psychologyBab1 = new Curriculum(1,"psychology", false);
Curriculum infoBab2 = new Curriculum(2,"info", false);
Curriculum masterinfo1 = new Curriculum(4, "info", false);
Curriculum masterinfo2 = new Curriculum(5, "info", false);
Curriculum chemistryBab2 = new Curriculum(2, "chemistry", false);
Curriculum ingebab1 = new Curriculum(1, "ingénieur", true);
curriculumService.save(infoBab1);
curriculumService.save(chemistryBab1);
curriculumService.save(psychologyBab1);
@ -97,6 +99,7 @@ public class MockController {
curriculumService.save(masterinfo1);
curriculumService.save(masterinfo2);
curriculumService.save(chemistryBab2);
curriculumService.save(ingebab1);
ucr.save(new UserCurriculum(joe, infoBab1, 2022, false));
ucr.save(new UserCurriculum(joe, chemistryBab1, 2023, true));
@ -128,8 +131,7 @@ public class MockController {
CurriculumCourseService.save(new CurriculumCourse(chemistryBab1,commun));
CurriculumCourseService.save(new CurriculumCourse(chemistryBab1,chemistry1));
InscriptionRequest inscriptionRequest = new InscriptionRequest("helen","prenom","non","helen@gmail.com","america",new Date(),(long) 4,RequestState.Pending,"yes.png","password", null, new Date(), RequestState.Pending);
InscriptionRequest inscriptionRequest = new InscriptionRequest("helen","prenom","non","helen@gmail.com","america",new Date(),(long) 4,RequestState.Pending,"yes.png","password", null, new Date(), RequestState.Pending, null);
inscriptionService.save(inscriptionRequest);

View File

@ -46,7 +46,7 @@ public class CurriculumCourseService {
toReturn.put("curriculumId", curriculum.getCurriculumId());
toReturn.put("year", curriculum.getYear());
toReturn.put("option", curriculum.getOption());
toReturn.put("requireCertificate", curriculum.isRequireCertificate());
return toReturn;
}

View File

@ -12,9 +12,13 @@ public class Curriculum {
private int curriculumId;
private int year;
private String option;
public Curriculum(int year, String option){
//True if the curriculum need an entry exam
private boolean requireCertificate;
public Curriculum(int year, String option, boolean requireCertificate){
this.year = year;
this.option = option;
this.requireCertificate = requireCertificate;
}
public Curriculum() {}
@ -39,4 +43,11 @@ public class Curriculum {
this.option = option;
}
public void setRequireCertificate(boolean requireCertificate) {
this.requireCertificate = requireCertificate;
}
public boolean isRequireCertificate() {
return requireCertificate;
}
}

View File

@ -3,5 +3,6 @@ package ovh.herisson.Clyde.Tables;
public enum FileType {
ProfilePicture,
EducationCertificate,
JustificationDocument
JustificationDocument,
IdentityCard,
}

View File

@ -22,11 +22,12 @@ public class InscriptionRequest {
private String profilePicture;
private String password;
private String identityCard;
private String admissionDocUrl;
private Date submissionDate;
private RequestState equivalenceState;
public InscriptionRequest(){}
public InscriptionRequest(String lastName, String firstName, String address, String email, String country, Date birthDate,Long curriculumId, RequestState state, String profilePicture, String password, String identityCard, Date submissionDate, RequestState equivalenceState){
public InscriptionRequest(String lastName, String firstName, String address, String email, String country, Date birthDate,Long curriculumId, RequestState state, String profilePicture, String password, String identityCard, Date submissionDate, RequestState equivalenceState, String admissionDocUrl){
this.lastName = lastName;
this.firstName = firstName;
this.address = address;
@ -40,6 +41,7 @@ public class InscriptionRequest {
this.identityCard = identityCard;
this.submissionDate = submissionDate;
this.equivalenceState = equivalenceState;
this.admissionDocUrl = admissionDocUrl;
}
public int getId() {
@ -149,4 +151,12 @@ public class InscriptionRequest {
public void setEquivalenceState(RequestState equivalenceState) {
this.equivalenceState = equivalenceState;
}
public String getAdmissionDocUrl() {
return admissionDocUrl;
}
public void setAdmissionDocUrl(String admissionDocUrl) {
this.admissionDocUrl = admissionDocUrl;
}
}

View File

@ -3,7 +3,7 @@
import i18n from '@/i18n.js'
import {login, register, disconnect, isLogged} from '@/rest/Users.js'
import {getAllCurriculums, getcurriculum} from '@/rest/curriculum.js'
import { uploadProfilePicture } from '@/rest/uploads.js'
import {uploadFile, uploadProfilePicture} from '@/rest/uploads.js'
import {toast} from 'vue3-toastify'
import 'vue3-toastify/dist/index.css';
import {createExternalCurriculum} from "@/rest/externalCurriculum.js";
@ -45,10 +45,13 @@
const imageSaved = ref(false)
let ppData = ""
let requiredCertif = false
//Contains the id of the newly created request (useful to link the student's formations informations to the request)
let requestId = ""
const idcardfile = ref({})
const justifcardfile = ref({})
const curricula= await getAllCurriculums();
function goBackHome(){
@ -87,11 +90,28 @@
//Post the register request and return the id of the newly created request and also post the external curriculum list in the database
async function postRegisterReq(){
const val = await register(outputs.firstname, outputs.surname, outputs.birthday, outputs.password, outputs.email, outputs.address, outputs.country, outputs.curriculum, ppData, null, new Date(), outputs.equivalenceState);
//We upload the two files and we get their paths on the server
const identityCardFile = await uploadFile(idcardfile.value, "IdentityCard")
const justifFile = ref(null)
if (curricula[outputs.curriculum-1].requireCertificate){
justifFile.value = await uploadFile(justifcardfile.value, "JustificationDocument")
}
let justif;
if (justifFile.value !== null){
justif = justifFile.value.url
}else{
justif = null
}
const val = await register(outputs.firstname, outputs.surname, outputs.birthday, outputs.password, outputs.email, outputs.address, outputs.country, outputs.curriculum, ppData, identityCardFile.url, new Date(), outputs.equivalenceState, justif);
for (let item in externalCurrTab.value){
await createExternalCurriculum(val.id, externalCurrTab.value[item].school, externalCurrTab.value[item].formation, externalCurrTab.value[item].completion, externalCurrTab.value[item].startYear, externalCurrTab.value[item].endYear, externalCurrTab.value[item].justifdocUrl);
}
}
</script>
@ -203,10 +223,23 @@
</div>
</div>
<div v-if="page === 2">
<form novalidate enctype="multipart/form-data" class="inputBox">
Carte d'identité :
</form>
<button @click="page++">{{i18n("login.guest.nextpage")}}</button>
<p style="color:rgb(239,60,168);">Carte d'indentité :</p>
<label class="browser">
Parcourir . . .
<input type="file" @change="idcardfile = $event.target.files">
</label>
<div v-if="curricula[outputs.curriculum-1].requireCertificate === true" style="margin-top: 3%; margin-bottom: 4%">
<p style="color:rgb(239,60,168);">Ce cursus requiert une attestation de réussite d'un examen d'entrée</p>
<div style="margin-top: 2%">
<p style="color:rgb(239,60,168);">Attestation:</p>
<label class="browser">
Parcourir . . .
<input type="file" @change="justifcardfile = $event.target.files">
</label>
</div>
</div>
<button @click="page++;">{{i18n("login.guest.nextpage")}}</button>
</div>
<div v-if="page === 3">
<p>

View File

@ -26,7 +26,7 @@ export function disconnect(){
* @param curriculum
* @param imageId id of the image in database returned when uploaded
*/
export async function register(firstname, lastname, birthDate, password, email, address, country, curriculumId, imageId, identityCardId, submissionDate, equivalence){
export async function register(firstname, lastname, birthDate, password, email, address, country, curriculumId, imageId, identityCardId, submissionDate, equivalence,admissionDocUrl){
return restPost("/register", {
firstName: firstname,
lastName: lastname,
@ -39,7 +39,8 @@ export async function register(firstname, lastname, birthDate, password, email,
profilePicture: imageId,
identityCard : identityCardId,
submissionDate : submissionDate,
equivalenceState : equivalence
equivalenceState : equivalence,
admissionDocUrl: admissionDocUrl
});
}