Fix the implementation of externalCurriculum upload
This commit is contained in:
parent
8442101c40
commit
648b73b585
@ -4,11 +4,11 @@ package ovh.herisson.Clyde.EndPoints;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ovh.herisson.Clyde.Repositories.ExternalCurriculumRepository;
|
||||
import ovh.herisson.Clyde.Repositories.InscriptionRepository;
|
||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||
import ovh.herisson.Clyde.Services.*;
|
||||
import ovh.herisson.Clyde.Tables.Curriculum;
|
||||
import ovh.herisson.Clyde.Tables.Role;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
import ovh.herisson.Clyde.Tables.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -23,15 +23,18 @@ public class CurriculumController {
|
||||
|
||||
private final UserCurriculumService userCurriculumServ;
|
||||
private final CurriculumCourseService curriculumCourseServ;
|
||||
|
||||
private final InscriptionRepository ir;
|
||||
private final UserService userServ;
|
||||
|
||||
public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, UserCurriculumService userCurriculumServ, CurriculumCourseService curriculumCourseServ, UserService userServ){
|
||||
private final ExternalCurriculumRepository ecr;
|
||||
public CurriculumController(CurriculumService curriculumServ, AuthenticatorService authServ, UserCurriculumService userCurriculumServ, CurriculumCourseService curriculumCourseServ, InscriptionRepository ir, UserService userServ, ExternalCurriculumRepository ecr){
|
||||
this.curriculumServ = curriculumServ;
|
||||
this.authServ = authServ;
|
||||
this.userCurriculumServ = userCurriculumServ;
|
||||
this.curriculumCourseServ = curriculumCourseServ;
|
||||
this.ir = ir;
|
||||
this.userServ = userServ;
|
||||
this.ecr = ecr;
|
||||
}
|
||||
|
||||
@GetMapping("/curriculum/{id}")
|
||||
@ -116,13 +119,12 @@ public class CurriculumController {
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/externalcurriculum/{userId}")
|
||||
public ResponseEntity<Map<String,Object>> getStudentsExternalCurriculum(@RequestHeader("Authorization") String token, @PathVariable String userId){
|
||||
@GetMapping("/externalcurriculum/{inscriptionRequestId}")
|
||||
public ResponseEntity<Map<String,Object>> getInscriptionRequestExternalCurriculum(@RequestHeader("Authorization") String token, @PathVariable String inscriptionRequestId){
|
||||
if (authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin, Role.Teacher},token))
|
||||
return new UnauthorizedResponse<>(null);
|
||||
|
||||
User u = userServ.getUserById(Long.parseLong(userId));
|
||||
HashMap<String,Object> toReturn = userCurriculumServ.findAllExternalCurriculumByStudent(u);
|
||||
HashMap<String,Object> toReturn = userCurriculumServ.findAllExternalCurriculumByInscriptionRequestId(Long.parseLong(inscriptionRequestId));
|
||||
|
||||
if (toReturn == null)
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
@ -131,4 +133,11 @@ public class CurriculumController {
|
||||
}
|
||||
|
||||
|
||||
//Note : everyone can post some externalcurriculums (the validity of the elements is assured by the inscription service)
|
||||
@PostMapping("/externalcurriculum")
|
||||
public ResponseEntity<ExternalCurriculum> postExternalCurriculum(@RequestBody ExternalCurriculum ec){
|
||||
ec.setState(RequestState.Pending);
|
||||
return new ResponseEntity<>(ecr.save(ec), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,10 +2,11 @@ package ovh.herisson.Clyde.Repositories;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import ovh.herisson.Clyde.Tables.ExternalCurriculum;
|
||||
import ovh.herisson.Clyde.Tables.InscriptionRequest;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface ExternalCurriculumRepository extends CrudRepository<ExternalCurriculum, Long> {
|
||||
ArrayList<ExternalCurriculum> getExternalCurriculumByUser(User user);
|
||||
ArrayList<ExternalCurriculum> getExternalCurriculumByInscriptionRequestId(Long id);
|
||||
}
|
||||
|
@ -4,10 +4,7 @@ import org.springframework.stereotype.Service;
|
||||
import ovh.herisson.Clyde.Repositories.CurriculumRepository;
|
||||
import ovh.herisson.Clyde.Repositories.ExternalCurriculumRepository;
|
||||
import ovh.herisson.Clyde.Repositories.UserCurriculumRepository;
|
||||
import ovh.herisson.Clyde.Tables.Curriculum;
|
||||
import ovh.herisson.Clyde.Tables.ExternalCurriculum;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
import ovh.herisson.Clyde.Tables.UserCurriculum;
|
||||
import ovh.herisson.Clyde.Tables.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -52,16 +49,16 @@ public class UserCurriculumService {
|
||||
}
|
||||
|
||||
|
||||
public HashMap<String,Object> findAllExternalCurriculumByStudent(User student) {
|
||||
ArrayList<ExternalCurriculum> list = externalCurriculumRepo.getExternalCurriculumByUser(student);
|
||||
public HashMap<String,Object> findAllExternalCurriculumByInscriptionRequestId(Long id) {
|
||||
ArrayList<ExternalCurriculum> list = externalCurriculumRepo.getExternalCurriculumByInscriptionRequestId(id);
|
||||
|
||||
ArrayList<HashMap<String, Object>> externalCurriculumList = new ArrayList<HashMap<String, Object>>();
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
HashMap<String, Object> element = new HashMap<>();
|
||||
element.put("id", list.get(0).getId());
|
||||
element.put("user", list.get(0).getUser());
|
||||
element.put("university", list.get(0).getUniversity());
|
||||
element.put("inscriptionRequestId", list.get(0).getInscriptionRequestId());
|
||||
element.put("school", list.get(0).getSchool());
|
||||
element.put("formation", list.get(0).getFormation());
|
||||
element.put("completion", list.get(0).getCompletion());
|
||||
element.put("startYear", list.get(0).getStartYear());
|
||||
|
@ -10,13 +10,9 @@ public class ExternalCurriculum {
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private int id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name="Users")
|
||||
private User user;
|
||||
private Long inscriptionRequestId;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name="University")
|
||||
private University university;
|
||||
private String school;
|
||||
|
||||
private String formation;
|
||||
|
||||
@ -32,9 +28,9 @@ public class ExternalCurriculum {
|
||||
|
||||
public ExternalCurriculum(){}
|
||||
|
||||
public ExternalCurriculum(User user, University university, String formation, String completion, int startYear, int endYear, String justifdocUrl, RequestState state){
|
||||
this.user = user;
|
||||
this.university = university;
|
||||
public ExternalCurriculum(Long ir, String school, String formation, String completion, int startYear, int endYear, String justifdocUrl, RequestState state){
|
||||
this.inscriptionRequestId = ir;
|
||||
this.school = school;
|
||||
this.formation = formation;
|
||||
this.completion = completion;
|
||||
this.startYear = startYear;
|
||||
@ -47,20 +43,20 @@ public class ExternalCurriculum {
|
||||
return id;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
public Long getInscriptionRequestId() {
|
||||
return inscriptionRequestId;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
public void setInscriptionRequest(Long inscriptionRequestId) {
|
||||
this.inscriptionRequestId = inscriptionRequestId;
|
||||
}
|
||||
|
||||
public University getUniversity() {
|
||||
return university;
|
||||
public String getSchool() {
|
||||
return school;
|
||||
}
|
||||
|
||||
public void setUniversity(University university) {
|
||||
this.university = university;
|
||||
public void setSchool(String school) {
|
||||
this.school = school;
|
||||
}
|
||||
|
||||
public String getFormation() {
|
||||
|
@ -15,7 +15,6 @@ public class InscriptionRequest {
|
||||
private String email;
|
||||
private String country;
|
||||
private Date birthDate;
|
||||
|
||||
private Long curriculumId;
|
||||
private RequestState state;
|
||||
private String profilePicture;
|
||||
|
@ -1,16 +1,15 @@
|
||||
<script setup>
|
||||
import {reactive, ref } from 'vue'
|
||||
import i18n from '@/i18n.js'
|
||||
import { login , register , disconnect, isLogged} from '@/rest/Users.js'
|
||||
import { getAllCurriculums } from '@/rest/curriculum.js'
|
||||
import {login, register, disconnect, isLogged} from '@/rest/Users.js'
|
||||
import {createExternalCurriculum, getAllCurriculums, getcurriculum} from '@/rest/curriculum.js'
|
||||
import { uploadProfilePicture } from '@/rest/uploads.js'
|
||||
import {toast} from 'vue3-toastify'
|
||||
import 'vue3-toastify/dist/index.css';
|
||||
|
||||
|
||||
const loginPage= ref(true)
|
||||
const page = ref(0)
|
||||
|
||||
|
||||
const outputs = reactive({
|
||||
surname:null,
|
||||
firstname:null,
|
||||
@ -22,12 +21,30 @@
|
||||
curriculum:null,
|
||||
})
|
||||
|
||||
const notcompletedCheck = ref(false);
|
||||
|
||||
const externalCurr = reactive({
|
||||
inscriptionRequestId : null,
|
||||
school:null,
|
||||
formation :null,
|
||||
completion : null,
|
||||
startYear : null,
|
||||
endYear: null,
|
||||
justifdocUrl : null
|
||||
})
|
||||
|
||||
//Stores some externalCurriculums in order to upload them all at the confirmation of the registration request
|
||||
const externalCurrTab = ref([]);
|
||||
|
||||
const submitValue= ref(i18n("login.guest.submit"))
|
||||
const passwordConfirm=ref("")
|
||||
|
||||
const imageSaved = ref(false)
|
||||
let ppData = ""
|
||||
|
||||
//Contains the id of the newly created request (useful to link the student's formations informations to the request)
|
||||
let requestId = ""
|
||||
|
||||
const curricula= await getAllCurriculums();
|
||||
|
||||
function goBackHome(){
|
||||
@ -69,6 +86,26 @@
|
||||
let id = cursus.substring(0, cursus.indexOf(" ")+1);
|
||||
return id;
|
||||
}
|
||||
|
||||
async function getCurriculumYear(curriculumId){
|
||||
const curriculum = await getcurriculum(curriculumId);
|
||||
return parseInt(curriculum.year);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//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, parseDecoratedCursus(outputs.curriculum), ppData, null, new Date());
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function deleteExtCursus(extcursus){
|
||||
externalCurrTab.value.splice(externalCurrTab.value.indexOf(extcursus),1)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -168,7 +205,7 @@
|
||||
changer de cursus/réinscription sinon continuez ici.
|
||||
</p>
|
||||
<div style="align-self:center;" class="inputBox">
|
||||
<button style="margin-top:25px;" @click="page++; register(outputs.firstname, outputs.surname, outputs.birthday, outputs.password, outputs.email, outputs.address, outputs.country, parseDecoratedCursus(outputs.curriculum), ppData, null, new Date());">
|
||||
<button style="margin-top:25px;" @click="page++;">
|
||||
{{i18n("login.guest.nextpage")}}
|
||||
</button>
|
||||
</div>
|
||||
@ -183,11 +220,65 @@
|
||||
<form novalidate enctype="multipart/form-data" class="inputBox">
|
||||
Carte d'identité :
|
||||
</form>
|
||||
<button @click="page++">{{i18n("login.guest.nextpage")}}</button>
|
||||
</div>
|
||||
<div v-if="page === 3">
|
||||
<p>
|
||||
Vous avez séléctionné un cursus qui possède des prérequis veuillez ajouter vos formations antérieures
|
||||
dans l'enseignement supérieur, votre dossier sera vérifié par un membre du service d'inscription.
|
||||
</p>
|
||||
<button @click="page++">Ajouter une formation</button>
|
||||
<button @click="postRegisterReq();">Envoyer la demande d'inscription</button>
|
||||
</div>
|
||||
<div v-if="page===4">
|
||||
<form @submit.prevent=""class="form">
|
||||
<div class="inputBox">
|
||||
<p>Ecole</p>
|
||||
<input type="text" v-model="externalCurr.school">
|
||||
</div>
|
||||
<div class="inputBox">
|
||||
<p>Formation</p>
|
||||
<input type="text" v-model="externalCurr.formation">
|
||||
</div>
|
||||
<div class="inputBox">
|
||||
<p>Cochez la case si vous n'avez terminé cette formation</p>
|
||||
<input v-model="notcompletedCheck" type="checkbox" id="checkboxformation">
|
||||
<div v-if="notcompletedCheck">
|
||||
<p>En quelle année de la formation vous êtes vous arrété (exemple: 3ème) ?</p>
|
||||
<input type="text" v-model="externalCurr.completion">
|
||||
</div>
|
||||
</div>
|
||||
<div class="inputBox">
|
||||
<p>Année de début</p>
|
||||
<input type="text" v-model="externalCurr.startYear">
|
||||
</div>
|
||||
<div class="inputBox">
|
||||
<p>Année de fin</p>
|
||||
<input type="text" v-model="externalCurr.endYear">
|
||||
</div>
|
||||
<div class="inputBox" style="margin-bottom:35px;">
|
||||
<input type="submit" v-model="submitValue" @click="externalCurrTab.push({inscriptionReqId:null, school:externalCurr.school, formation:externalCurr.formation, completion:externalCurr.completion, startYear:externalCurr.startYear, endYear:externalCurr.endYear, justifdocUrl:externalCurr.justifdocUrl});console.log(externalCurrTab);page--;">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:flex; justify-content:center; " v-for="item in externalCurrTab" v-if="page===3">
|
||||
<div class="bodu">
|
||||
<div class="container">
|
||||
<div class="school"><a style="margin-left:30px;">{{item.school}}</a></div>
|
||||
<div class="formation"><a>{{item.formation}}</a></div>
|
||||
<div class="edit">
|
||||
<button style="background-color:rgb(105,05,105);font-size:15px;height:50px;width:75%;border:none;border-radius:20px;" @click="externalCurr.school=item.school; externalCurr.completion=item.completion; externalCurr.formation=item.formation;externalCurr.endYear=item.endYear; externalCurr.startYear=item.startYear; externalCurr.justifdocUrl;page++;">Edit </button>
|
||||
</div>
|
||||
<div class="remove">
|
||||
<button style="background-color:rgb(105,05,105);font-size:15px;height:50px;width:75%;border:none;border-radius:20px;" @click="deleteExtCursus(item)">Remove </button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@ -196,9 +287,8 @@
|
||||
margin-left: auto;
|
||||
margin-right:auto;
|
||||
min-width:400px;
|
||||
|
||||
width:25%;
|
||||
height:60%;
|
||||
height:50%;
|
||||
}
|
||||
|
||||
|
||||
@ -251,6 +341,14 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.bodu {
|
||||
margin-top:2%;
|
||||
width:50%;
|
||||
border:2px solid black;
|
||||
border-radius:9px;
|
||||
background-color:rgb(50,50,50);
|
||||
}
|
||||
|
||||
.switchpage{
|
||||
width:100px;
|
||||
border: none;
|
||||
@ -290,11 +388,22 @@ input[type=file]{
|
||||
background:#FFFFFF;
|
||||
}
|
||||
|
||||
.container{
|
||||
margin-top: 2%;
|
||||
color:white;
|
||||
height:60px;
|
||||
font-size:30px;
|
||||
display:grid;
|
||||
grid-template-columns:30% 30% 20% 20%;
|
||||
grid-template-areas:
|
||||
"school formation completion edit remove";
|
||||
column-gap:10px;
|
||||
}
|
||||
|
||||
button:active ,.switchpage:active{
|
||||
opacity:0.8;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
|
@ -52,3 +52,15 @@ export async function getSelfCurriculum(){
|
||||
export async function getSomeonesCurriculumList(user){
|
||||
return restGet("/onescurriculum/"+user)
|
||||
}
|
||||
|
||||
export async function createExternalCurriculum(inscriptionRequestId,school, formation, completion, startYear, endYear, justifdocUrl){
|
||||
return restPost("/externalcurriculum", {
|
||||
inscriptionRequestId: inscriptionRequestId,
|
||||
school:school,
|
||||
formation :formation,
|
||||
completion : completion,
|
||||
startYear : startYear,
|
||||
endYear: endYear,
|
||||
justifdocUrl : justifdocUrl
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user