1
0
forked from PGL/Clyde

Compare commits

..

No commits in common. "364f39c4bc71d0a60e06cb3e295e535a62379bb9" and "4d6387ca8b7ebb9c22f426698c43d41db2afcb58" have entirely different histories.

17 changed files with 43 additions and 92 deletions

View File

@ -12,8 +12,14 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
import ovh.herisson.Clyde.Services.*;
import ovh.herisson.Clyde.Tables.*;
import ovh.herisson.Clyde.Services.AuthenticatorService;
import ovh.herisson.Clyde.Services.LessonRequestService;
import ovh.herisson.Clyde.Services.LessonService;
import ovh.herisson.Clyde.Services.ProtectionService;
import ovh.herisson.Clyde.Tables.LessonChangesRequest;
import ovh.herisson.Clyde.Tables.RequestState;
import ovh.herisson.Clyde.Tables.Role;
import ovh.herisson.Clyde.Tables.User;
import java.util.Map;
@ -22,13 +28,11 @@ import java.util.Map;
public class LessonRequestsController {
private final LessonRequestService lessonRequestServ;
private final AuthenticatorService authServ;
private final UserService userServ;
private final LessonService lessonServ;
public LessonRequestsController(LessonRequestService lessonRequestServer, AuthenticatorService authServ, UserService userServ, LessonService lessonServ) {
public LessonRequestsController(LessonRequestService lessonRequestServer, AuthenticatorService authServ, LessonService lessonServ) {
this.lessonRequestServ = lessonRequestServer;
this.authServ = authServ;
this.userServ = userServ;
this.lessonServ = lessonServ;
}
/**
@ -109,7 +113,6 @@ public class LessonRequestsController {
if(lessonRequest.getRequestType() == 0 ) {
if (!lessonRequestServ.modifyCreateRequestState(lessonRequest, state, local))
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
userServ.Notify(lessonRequest.getUser(), new Notification("Request took in charge","Request"+ state + ":" + lessonRequest.getCourse().getTitle(), "#/manage-owned-lessons"));
}
else if(lessonRequest.getRequestType() == 1){
@ -119,14 +122,12 @@ public class LessonRequestsController {
if(!lessonRequestServ.modifyChangeRequestState(infos,lessonRequest.getLessonId(),state))
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
lessonRequest.setState(state);
userServ.Notify(lessonRequest.getUser(), new Notification("Request took in charge","Request"+ state + ":" + lessonServ.findById(lessonRequest.getLessonId()).getCourse().getTitle(), "#/manage-owned-lessons"));
}
else{
userServ.Notify(lessonRequest.getUser(), new Notification("Request took in charge","Request"+ state + ":" + lessonServ.findById(lessonRequest.getLessonId()).getCourse().getTitle(), "#/manage-owned-lessons"));
lessonRequestServ.modifyDeleteRequest(lessonRequest, state);
lessonRequest.setState(state);
}
lessonRequestServ.save(lessonRequest);
return new ResponseEntity<>(HttpStatus.OK);

View File

@ -44,7 +44,7 @@ public class UserController {
@GetMapping("/user/{id}")
public ResponseEntity<HashMap<String ,Object>> getUserById(@RequestHeader("Authorization") String token, @PathVariable Long id){
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService, Role.Teacher},token))
if (authServ.isNotIn(new Role[]{Role.Admin,Role.Secretary,Role.InscriptionService},token))
return new UnauthorizedResponse<>(null);
return new ResponseEntity<>(ProtectionService.userWithoutPassword(userService.getUserById(id)), HttpStatus.OK);

View File

@ -22,9 +22,6 @@ public interface ScheduleLessonRepository extends CrudRepository<ScheduleLesson,
@Query("select distinct sl.schedule from ScheduleLesson sl where sl.schedule.curriculum = ?1")
Schedule findScheduleByCurriculum(Curriculum curriculum);
@Query("select distinct sl from ScheduleLesson sl where sl.lesson = ?1")
ScheduleLesson findByLesson(Lesson lesson);
@Modifying
@Transactional
@Query("delete from ScheduleLesson sl where sl.lesson =?1")

View File

@ -13,11 +13,9 @@ public interface UserCurriculumRepository extends CrudRepository<UserCurriculum,
@Query("select uc.curriculum from UserCurriculum uc where uc.user = ?1")
Curriculum findByUser(User student);
@Query("select distinct uc.user from UserCurriculum uc where uc.curriculum = ?1")
Iterable<User> findUsersByCurriculum(Curriculum curriculum);
ArrayList<UserCurriculum> findByUserOrderByCurriculum(User student);
UserCurriculum findByUserAndCurriculumAndActual(User user, Curriculum curriculum, boolean actual);
ArrayList<UserCurriculum> findByUserAndActual(User user, boolean actual);
}

View File

@ -7,7 +7,10 @@ package ovh.herisson.Clyde.Services;
* @scope Extension Horaire
******************************************************/
import org.springframework.stereotype.Service;
import ovh.herisson.Clyde.Repositories.*;
import ovh.herisson.Clyde.Repositories.CourseRepository;
import ovh.herisson.Clyde.Repositories.CurriculumCourseRepository;
import ovh.herisson.Clyde.Repositories.LessonRepository;
import ovh.herisson.Clyde.Repositories.UserCurriculumRepository;
import ovh.herisson.Clyde.Tables.*;
import java.util.ArrayList;
@ -16,17 +19,12 @@ import java.util.Map;
@Service
public class LessonService {
private final LessonRepository lessonRepo;
private final ScheduleLessonRepository scheduleLessonRepo;
private final UserCurriculumRepository userCurriculumRepo;
private final UserService userServ;
private final CourseRepository courseRepo;
private final CurriculumCourseRepository curriculumCourseRepo;
public LessonService(LessonRepository lessonRepo, ScheduleLessonRepository scheduleLessonRepo, UserCurriculumRepository userCurriculumRepo, UserService userServ, CourseRepository courseRepo, CurriculumCourseRepository curriculumCourseRepo){
public LessonService(LessonRepository lessonRepo, UserCurriculumRepository userCurriculumRepo, CourseRepository courseRepo, CurriculumCourseRepository curriculumCourseRepo){
this.lessonRepo = lessonRepo;
this.scheduleLessonRepo = scheduleLessonRepo;
this.userCurriculumRepo = userCurriculumRepo;
this.userServ = userServ;
this.courseRepo = courseRepo;
this.curriculumCourseRepo = curriculumCourseRepo;
}
@ -138,12 +136,7 @@ public class LessonService {
break;
}
}
Lesson lesson = lessonRepo.save(target);
ScheduleLesson scheduleLesson = scheduleLessonRepo.findByLesson(lesson);
Iterable<User> users = userCurriculumRepo.findUsersByCurriculum(scheduleLesson.getSchedule().getCurriculum());
for(User user: users){
userServ.Notify(user, new Notification("Course modified in the schedule", "Course Modified " + lesson.getCourse().getTitle() , "/#/schedule"));
}
lessonRepo.save(target);
return true;
}
/**

View File

@ -6,9 +6,7 @@ import lombok.AllArgsConstructor;
import ovh.herisson.Clyde.Repositories.CourseRepository;
import ovh.herisson.Clyde.Repositories.Msg.ForumRepository;
import ovh.herisson.Clyde.Repositories.Msg.TopicRepository;
import ovh.herisson.Clyde.Services.UserService;
import ovh.herisson.Clyde.Tables.Course;
import ovh.herisson.Clyde.Tables.Notification;
import ovh.herisson.Clyde.Tables.User;
import ovh.herisson.Clyde.Tables.Msg.Answer;
import ovh.herisson.Clyde.Tables.Msg.Forum;
@ -18,24 +16,17 @@ import ovh.herisson.Clyde.Tables.Msg.Topic;
@AllArgsConstructor
public class ForumService {
private UserService userServ;
private CourseRepository courseRepo;
private ForumRepository forumRepo;
private TopicRepository topicRepo;
public void createForum(Course c, Forum f){
c.addForum(f);
for (User u: f.getRegister()) {
userServ.Notify(u, new Notification("forum.notification.forum.new", f.getName(), "/#/Forum"));
}
courseRepo.save(c);
}
public void createTopic(Forum f, Topic data) {
f.addTopic(data);
for (User u: f.getRegister()) {
userServ.Notify(u, new Notification("forum.notification.topic.new", data.getSubject(), "/#/Forum"));
}
forumRepo.save(f);
}

View File

@ -9,26 +9,22 @@ import org.springframework.stereotype.Service;
import ovh.herisson.Clyde.Repositories.LessonRepository;
import ovh.herisson.Clyde.Repositories.ScheduleLessonRepository;
import ovh.herisson.Clyde.Repositories.ScheduleRepository;
import ovh.herisson.Clyde.Repositories.UserCurriculumRepository;
import ovh.herisson.Clyde.Tables.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@Service
public class ScheduleLessonService {
private final ScheduleLessonRepository scheduleLessonRepo;
private final UserCurriculumRepository userCurriculumRepo;
private final UserService userServ;
private final LessonRepository lessonRepo;
private final ScheduleRepository scheduleRepo;
public ScheduleLessonService(ScheduleLessonRepository scheduleLessonRepo, UserCurriculumRepository userCurriculumRepo, UserService userServ, LessonRepository lessonRepo, ScheduleRepository scheduleRepo) {
public ScheduleLessonService(ScheduleLessonRepository scheduleLessonRepo, LessonRepository lessonRepo, ScheduleRepository scheduleRepo) {
this.scheduleLessonRepo = scheduleLessonRepo;
this.userCurriculumRepo = userCurriculumRepo;
this.userServ = userServ;
this.lessonRepo = lessonRepo;
this.scheduleRepo = scheduleRepo;
}
@ -36,22 +32,19 @@ public class ScheduleLessonService {
if(scheduleLesson == null)
return false;
scheduleLessonRepo.save(scheduleLesson);
Iterable<User> users = userCurriculumRepo.findUsersByCurriculum(scheduleLesson.getSchedule().getCurriculum());
for(User user: users){
userServ.Notify(user, new Notification("New course in the schedule", "Course added " + scheduleLesson.getLesson().getCourse().getTitle(), "/#/schedule"));
}
return true;
}
/**
* Save a lesson to all the schedule it is linked
*/
public void saveToAllSchedule(Lesson lesson){
public boolean saveToAllSchedule(Lesson lesson){
Iterable<Schedule> schedules = scheduleRepo.findAllLessonSchedule(lesson.getCourse());
if(schedules == null)
return;
return false;
for (Schedule schedule : schedules){
save(new ScheduleLesson(schedule, lesson));
}
return true;
}
/**
* Delete a scheduleLesson via its lesson
@ -59,11 +52,6 @@ public class ScheduleLessonService {
public boolean delete(long lessonId){
if(lessonId == 0)
return false;
ScheduleLesson scheduleLesson = scheduleLessonRepo.findByLesson(lessonRepo.findById(lessonId));
Iterable<User> users = userCurriculumRepo.findUsersByCurriculum(scheduleLesson.getSchedule().getCurriculum());
for(User user: users){
userServ.Notify(user, new Notification("Course deleted in the schedule","Course deleted " + scheduleLesson.getLesson().getCourse().getTitle(), "/#/schedule"));
}
scheduleLessonRepo.delete(lessonRepo.findById(lessonId));
return true;
}

View File

@ -12,7 +12,6 @@ import ovh.herisson.Clyde.Tables.Msg.Discussion;
import ovh.herisson.Clyde.Tables.Msg.Message;
import ovh.herisson.Clyde.Tables.Notification.Status;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -42,7 +41,7 @@ public class User {
@JsonIgnore
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
private List<Notification> notifications = new ArrayList<>();
private List<Notification> notifications;
////// Extension Messagerie /////
@JsonIgnore

View File

@ -203,8 +203,6 @@ msg.notification.new=You have a new message
forum.create=Create forum
forum.create.name=New forum's name
forum.post.create.name=New post's title
forum.notification.topic.new=New topic created
forum.notification.forum.new=New Forum created
firstname/name=Firstname/Name
regNo=regNo
From=From
@ -284,7 +282,7 @@ rereg=Reregister in the next year of one of my cursus
reregsup=Register in a supplementary cursus
chcur=Change from a cursus to another
iwouldlike=I would like to :
newcurr=Actual curriculums
newcurr=New curriculum
cursusprereq=The cursus you selected has some prerequisites ensure that your external curriculum data is updated in your profile
imposecurriculum=Impose a curriculum
impose=Impose

View File

@ -201,8 +201,6 @@ msg.notification.new=Vous avez un nouveau message!
forum.create=Créer un forum
forum.create.name=Nom du forum
forum.post.create.name=Titre du post
forum.notification.topic.new=Nouveau Topic crée
forum.notification.forum.new=Nouveau forum crée
firstname/name=Prénom/Nom
regNo=Matricule
From=De
@ -282,7 +280,7 @@ rereg=Me réinscrire dans l'année supérieure
reregsup=M'inscrire dans un cursus supplémentaire
chcur=Changer d'un cursus vers un autre
iwouldlike=Je voudrais :
newcurr=Cursus actuels
newcurr=Nouveau cursus
cursusprereq=Le cursus que vous avez selectionné a des prérequis assurez vous que votre dossier de parcours est a jour dans votre profil
imposecurriculum=Imposer un cursusgotimposed
impose=Imposer

View File

@ -2,7 +2,7 @@
import { toast } from 'vue3-toastify';
import { ref } from 'vue'
import i18n, { setLang } from './i18n.js'
import { isLogged, getSelf } from '@/rest/Users.js'
import { isLogged } from '@/rest/Users.js'
import { notifications, fetchNotifications, archiveNotification } from '@/rest/notifications.js'
import { appList, currentView } from '@/rest/apps.js'
@ -14,11 +14,9 @@ window.onhashchange = function() {
currentURL = window.location.hash;
}
const Logged = ref(isLogged());
const user = ref();
if(Logged.value){
fetchNotifications();
getSelf().then(e => user.value = e);
}
window.addEventListener('hashchange', () => {
@ -77,7 +75,6 @@ window.addEventListener('hashchange', () => {
{{i18n("app.manage.profile")}}
</a>
</div>
<span v-if=Logged>RegNo - {{ user.regNo }}</span>
</div>
</a></li>
</ul>
@ -136,12 +133,10 @@ window.addEventListener('hashchange', () => {
.dropdown {
color:black;
margin-top:55px;
width:160px;
display: inline-block;
/* height:110px; */
text-align: center;
height:110px;
font-size: 13px;
position: absolute;
z-index: 1;
@ -167,12 +162,12 @@ window.addEventListener('hashchange', () => {
margin-top: var(--header-size);
top:0;
left:0;
padding: 25px 0;
padding: 25px 0 0;
width: 70px ;
background-color: rgb(53, 53, 53);
border-right:5px;
border-color:black;
height: calc( 95% - var(--header-size) ) ;
height: 100%;
position: fixed;
overflow: scroll;
transition-duration: .3s;
@ -242,7 +237,8 @@ window.addEventListener('hashchange', () => {
.text {
right: 0%;
width: 0%;
display:none;
visibility: collapse;
opacity: 0;
color: white;
font-size: 1.2em;
font-weight: 600;
@ -251,7 +247,7 @@ window.addEventListener('hashchange', () => {
ul.vertical:hover .text {
opacity:1;
display: inline;
visibility:visible;
width: 60%;
transition-duration: .3s;
padding-left: 15px;

View File

@ -147,7 +147,8 @@ async function modify(){
column-gap:2.7%;
row-gap:45px;
grid-template-areas:
"profilPic globalInfos";
"profilPic globalInfos"
"minfos minfos";
}
.profilPic{
@ -166,8 +167,7 @@ async function modify(){
display:flex;
align-items:center;
justify-content:center;
margin-right: auto;
margin-left: auto;
margin-top:5%;
}
.subContainer{

View File

@ -32,9 +32,6 @@
<div>
{{ i18n("firstname/name") }} : {{user.firstName}} {{user.lastName}}
</div>
<div>
{{ i18n("regNo") }} : {{user.regNo}}
</div>
<div>
{{ i18n("login.guest.email") }}: {{user.email}}
</div>

View File

@ -80,7 +80,7 @@ function isExempted(course){
</div>
</div>
<div v-if="list === false">
<button @click="list=!list;submitted=false">{{ i18n("courses.back") }}</button>
<button @click="list=!list;submitted=!submitted">{{ i18n("courses.back") }}</button>
</div>
</template>

View File

@ -115,7 +115,7 @@
<div class="studentfirstname">{{item.user.firstName}}</div>
<div class="studentlastname">{{item.user.lastName}}</div>
<div class="reqState">{{ i18n("approval")}}{{item.state}}</div>
<div class="teacherApproval">{{ i18n("teacherapproval") }} {{item.teacherApprovalState}}</div>
<div class="teacherApproval">{{ i18n("teacherapproval") }} : {{item.teacherApprovalState}}</div>
<div class="infos"><button @click="windowsState=5;targetId=item.id">{{ i18n("request.moreInfos") }}</button></div>
</div>
</div>

View File

@ -192,10 +192,10 @@
<div>
{{ i18n("login.guest.email") }}: {{user.email}}
</div>
<div>
<div v-if="user.role==='Student'">
{{ i18n("regNo") }} : {{user.regNo}}
</div>
<div>
<div v-else>
{{ i18n("role") }}: {{i18n((user.role))}}
</div>
<div>
@ -253,7 +253,7 @@
{{ i18n("alreadypaid") }}
</div>
<div>
<button @click="windowState=7" v-if="minerv.value.toPay >= 0">{{ i18n("askscholarship") }}</button>
<button @click="windowState=7" v-if="minerv.value.toPay <= 0">{{ i18n("askscholarship") }}</button>
</div>
</div>
<div v-if="windowState === 5">
@ -369,7 +369,7 @@
</div>
</div>
</div>
<div v-if="windowState === 0 && user.role==='Student'" class="moreInfos">
<div v-if="windowState === 0" class="moreInfos">
<div class = "oldcursus">
<div class="listTitle">
{{ i18n("oldcursus") }}

View File

@ -2,14 +2,9 @@ import { ref } from 'vue'
import { restGet, restPost } from '@/rest/restConsumer.js'
export const notifications = ref([]);
let timerSet = false
export function fetchNotifications(){
restGet("/notifications").then( e => notifications.value = e );
if(!timerSet){
timerSet = true;
setTimeout(() => {timerSet = false; fetchNotifications()}, 5000);
}
}
export function archiveNotification(id){