From 25575fa4e08e96d6248fa083c7076ab9b11c6308 Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Fri, 19 Apr 2024 12:26:48 +0200 Subject: [PATCH] Implements some files uploading in the inscription form and change inscriptionRequest and Curriculum for the cursus acceptance attestation feature --- .../Clyde/EndPoints/MockController.java | 20 ++++---- .../Services/CurriculumCourseService.java | 2 +- .../ovh/herisson/Clyde/Tables/Curriculum.java | 13 ++++- .../ovh/herisson/Clyde/Tables/FileType.java | 3 +- .../Inscription/InscriptionRequest.java | 12 ++++- frontend/src/Apps/Login.vue | 47 ++++++++++++++++--- frontend/src/rest/Users.js | 5 +- 7 files changed, 80 insertions(+), 22 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java index 6ff0707..d9320a9 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -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); diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumCourseService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumCourseService.java index 19549d0..b522da3 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumCourseService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/CurriculumCourseService.java @@ -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; } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Curriculum.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Curriculum.java index 67075d1..4bcac40 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Curriculum.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Curriculum.java @@ -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; + } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java index e7a081b..ad5eab4 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/FileType.java @@ -3,5 +3,6 @@ package ovh.herisson.Clyde.Tables; public enum FileType { ProfilePicture, EducationCertificate, - JustificationDocument + JustificationDocument, + IdentityCard, } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/InscriptionRequest.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/InscriptionRequest.java index 07c720f..1d0271c 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/InscriptionRequest.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Inscription/InscriptionRequest.java @@ -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; + } } diff --git a/frontend/src/Apps/Login.vue b/frontend/src/Apps/Login.vue index bb83a18..531259b 100644 --- a/frontend/src/Apps/Login.vue +++ b/frontend/src/Apps/Login.vue @@ -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); } } + @@ -203,10 +223,23 @@
-
- Carte d'identité : -
- +

Carte d'indentité :

+ +
+

Ce cursus requiert une attestation de réussite d'un examen d'entrée

+
+

Attestation:

+ +
+
+ +

diff --git a/frontend/src/rest/Users.js b/frontend/src/rest/Users.js index 7daa99b..9efade4 100644 --- a/frontend/src/rest/Users.js +++ b/frontend/src/rest/Users.js @@ -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 }); }