Compare commits
2 Commits
Leo/Backen
...
Leo/Inscri
Author | SHA1 | Date | |
---|---|---|---|
67fa630ecf | |||
ad0e7b3e35 |
@ -15,7 +15,7 @@ import java.util.Date;
|
|||||||
|
|
||||||
public class MockController {
|
public class MockController {
|
||||||
private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||||
public final UserService userService;
|
|
||||||
public final UserRepository userRepo;
|
public final UserRepository userRepo;
|
||||||
public final TokenRepository tokenRepo;
|
public final TokenRepository tokenRepo;
|
||||||
public final TokenService tokenService;
|
public final TokenService tokenService;
|
||||||
@ -27,8 +27,7 @@ public class MockController {
|
|||||||
ArrayList<User> mockUsers;
|
ArrayList<User> mockUsers;
|
||||||
|
|
||||||
|
|
||||||
public MockController(UserService userService, UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, InscriptionService inscriptionService){
|
public MockController(UserRepository userRepo, TokenRepository tokenRepo, TokenService tokenService, CurriculumCourseService CurriculumCourseService, CurriculumService curriculumService, CourseService courseService, InscriptionService inscriptionService){
|
||||||
this.userService = userService;
|
|
||||||
this.tokenRepo = tokenRepo;
|
this.tokenRepo = tokenRepo;
|
||||||
this.userRepo = userRepo;
|
this.userRepo = userRepo;
|
||||||
this.tokenService = tokenService;
|
this.tokenService = tokenService;
|
||||||
@ -46,21 +45,21 @@ public class MockController {
|
|||||||
|
|
||||||
@PostMapping("/mock")
|
@PostMapping("/mock")
|
||||||
public void postMock(){
|
public void postMock(){
|
||||||
|
|
||||||
// user part
|
// user part
|
||||||
|
|
||||||
|
|
||||||
User herobrine = new User("brine","hero","admin@admin.com","behind","ShadowsLand",new Date(0), null,Role.Admin,passwordEncoder.encode("admin"));
|
User herobrine = new User("brine","hero","admin@admin.com","behind","ShadowsLand",new Date(0), null,Role.Admin,passwordEncoder.encode("admin"));
|
||||||
User joe = new User("Mama","Joe","student@student.com","roundabout","England",new Date(0), null,Role.Student,passwordEncoder.encode("student"));
|
User joe = new User("Mama","Joe","student@student.com","roundabout","England",new Date(0), null,Role.Student,passwordEncoder.encode("student"));
|
||||||
User meh = new User("Polo","Marco","secretary@secretary.com","a Box","Monaco",new Date(0), null,Role.Secretary,passwordEncoder.encode("secretary"));
|
User meh = new User("Polo","Marco","secretary@secretary.com","a Box","Monaco",new Date(0), null,Role.Secretary,passwordEncoder.encode("secretary"));
|
||||||
User joke = new User("Gaillard","Corentin","teacher@teacher.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher"));
|
User joke = new User("Gaillard","Corentin","teacher@teacher.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher"));
|
||||||
User jojo = new User("Bridoux","Justin","teacher2@teacher2.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher"));
|
User jojo = new User("Bridoux","Justin","teacher2@teacher2.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher"));
|
||||||
User lena = new User("Louille","Lena","inscriptionService@InscriptionService.com","no","yes",new Date(0), null,Role.InscriptionService,passwordEncoder.encode("inscriptionService"));
|
User lena = new User("Louille","Lena","inscriptionService@InscriptionService.com","no","yes",new Date(0), null,Role.InscriptionService,passwordEncoder.encode("inscriptionService"));
|
||||||
|
mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke,lena,jojo));
|
||||||
|
|
||||||
mockUsers = new ArrayList<>(Arrays.asList(joke, herobrine, joe, meh, jojo));
|
userRepo.saveAll(mockUsers);
|
||||||
userService.saveAll(mockUsers);
|
|
||||||
userService.save(lena);
|
|
||||||
|
|
||||||
|
// Course / Curriculum part
|
||||||
//Course / Curriculum part
|
|
||||||
|
|
||||||
Curriculum infoBab1 = new Curriculum(1,"info");
|
Curriculum infoBab1 = new Curriculum(1,"info");
|
||||||
Curriculum chemistryBab1 = new Curriculum(1,"chemistry");
|
Curriculum chemistryBab1 = new Curriculum(1,"chemistry");
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
package ovh.herisson.Clyde;
|
|
||||||
|
|
||||||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
|
||||||
import org.hibernate.id.IdentifierGenerator;
|
|
||||||
|
|
||||||
import java.sql.*;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
|
|
||||||
public class RegNoGenerator implements IdentifierGenerator {
|
|
||||||
private static int count = 0;
|
|
||||||
@Override
|
|
||||||
public Object generate(SharedSessionContractImplementor session, Object object) {
|
|
||||||
try{
|
|
||||||
JdbcConnectionAccess jdbccon = session.getJdbcConnectionAccess();
|
|
||||||
Connection conn = jdbccon.obtainConnection();
|
|
||||||
|
|
||||||
Statement statement = conn.createStatement();
|
|
||||||
|
|
||||||
Calendar c = new GregorianCalendar();
|
|
||||||
int y = c.get(Calendar.YEAR);
|
|
||||||
String query = "select count(reg_no) + "+count+" from Users where reg_no/10000 = " + y%1000;
|
|
||||||
|
|
||||||
ResultSet set = statement.executeQuery(query);
|
|
||||||
long resp = 0;
|
|
||||||
if(set.next()){
|
|
||||||
resp = set.getLong(1)+((y%1000)*10000);
|
|
||||||
count += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
conn.close();
|
|
||||||
statement.close();
|
|
||||||
|
|
||||||
return resp;
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void resetCount(){
|
|
||||||
count = 0;
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,10 +5,13 @@ import org.springframework.data.repository.CrudRepository;
|
|||||||
import ovh.herisson.Clyde.Tables.User;
|
import ovh.herisson.Clyde.Tables.User;
|
||||||
|
|
||||||
public interface UserRepository extends CrudRepository<User, Long> {
|
public interface UserRepository extends CrudRepository<User, Long> {
|
||||||
|
|
||||||
User findById(long id);
|
User findById(long id);
|
||||||
|
|
||||||
User findByEmail(String email);
|
User findByEmail(String email);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Query("select u from User u where u.role = ovh.herisson.Clyde.Tables.Role.Teacher")
|
@Query("select u from User u where u.role = ovh.herisson.Clyde.Tables.Role.Teacher")
|
||||||
Iterable<User> findAllTeachers();
|
Iterable<User> findAllTeachers();
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ public class InscriptionService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
userRepo.save(userFromRequest);
|
userRepo.save(userFromRequest);
|
||||||
userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId())));
|
userCurriculumRepo.save(new UserCurriculum(userFromRequest, curriculumRepo.findById(inscrRequest.getCurriculumId()),0));
|
||||||
}
|
}
|
||||||
inscrRequest.setState(requestState);
|
inscrRequest.setState(requestState);
|
||||||
save(inscrRequest);
|
save(inscrRequest);
|
||||||
|
@ -2,17 +2,16 @@ package ovh.herisson.Clyde.Services;
|
|||||||
|
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import ovh.herisson.Clyde.RegNoGenerator;
|
|
||||||
import ovh.herisson.Clyde.Repositories.UserRepository;
|
import ovh.herisson.Clyde.Repositories.UserRepository;
|
||||||
import ovh.herisson.Clyde.Tables.Role;
|
import ovh.herisson.Clyde.Tables.Role;
|
||||||
import ovh.herisson.Clyde.Tables.User;
|
import ovh.herisson.Clyde.Tables.User;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class UserService {
|
public class UserService {
|
||||||
private final UserRepository userRepo;
|
private final UserRepository userRepo;
|
||||||
private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||||
|
|
||||||
public UserService(UserRepository userRepo){
|
public UserService(UserRepository userRepo){
|
||||||
this.userRepo = userRepo;
|
this.userRepo = userRepo;
|
||||||
}
|
}
|
||||||
@ -107,19 +106,10 @@ public class UserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public User save(User user){
|
public User save(User user){
|
||||||
RegNoGenerator.resetCount();
|
|
||||||
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
user.setPassword(passwordEncoder.encode(user.getPassword()));
|
||||||
return userRepo.save(user);
|
return userRepo.save(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveAll(ArrayList<User> list){
|
|
||||||
//S'assure que le compteur est bien a 0
|
|
||||||
RegNoGenerator.resetCount();
|
|
||||||
userRepo.saveAll(list);
|
|
||||||
//Reset le compteur a zero pour les futurs ajouts
|
|
||||||
RegNoGenerator.resetCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Iterable<User> getAll(){
|
public Iterable<User> getAll(){
|
||||||
return userRepo.findAll();
|
return userRepo.findAll();
|
||||||
}
|
}
|
||||||
@ -141,5 +131,4 @@ public class UserService {
|
|||||||
public void delete(User user) {
|
public void delete(User user) {
|
||||||
userRepo.delete(user);
|
userRepo.delete(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,66 @@
|
|||||||
|
package ovh.herisson.Clyde.Tables;
|
||||||
|
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class ExemptionsRequest {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "Users")
|
||||||
|
private User user;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "Course")
|
||||||
|
private Course course;
|
||||||
|
private String justifDocument;
|
||||||
|
|
||||||
|
private RequestState state;
|
||||||
|
|
||||||
|
|
||||||
|
public ExemptionsRequest(User user, Course course, String justifDocument, RequestState state){
|
||||||
|
this.user = user;
|
||||||
|
this.course = course;
|
||||||
|
this.justifDocument = justifDocument;
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ExemptionsRequest(){}
|
||||||
|
|
||||||
|
public User getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Course getCourse() {
|
||||||
|
return course;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCourse(Course course) {
|
||||||
|
this.course = course;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJustifDocument() {
|
||||||
|
return justifDocument;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJustifDocument(String justifDocument) {
|
||||||
|
this.justifDocument = justifDocument;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public RequestState getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(RequestState state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package ovh.herisson.Clyde.Tables;
|
||||||
|
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class ScholarshipRequest {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "Users")
|
||||||
|
private User user;
|
||||||
|
private RequestState state;
|
||||||
|
private String requestForm;
|
||||||
|
private int amount;
|
||||||
|
|
||||||
|
|
||||||
|
public ScholarshipRequest(User user, RequestState state, String requestForm, int amount){
|
||||||
|
this.user = user;
|
||||||
|
this.state = state;
|
||||||
|
this.requestForm = requestForm;
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScholarshipRequest(){}
|
||||||
|
|
||||||
|
public User getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RequestState getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(RequestState state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRequestForm() {
|
||||||
|
return requestForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequestForm(String requestForm) {
|
||||||
|
this.requestForm = requestForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAmount() {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAmount(int amount) {
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package ovh.herisson.Clyde.Tables;
|
||||||
|
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class UninscriptionRequest {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private int id;
|
||||||
|
private RequestState state;
|
||||||
|
|
||||||
|
public UninscriptionRequest(RequestState state){
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UninscriptionRequest(){}
|
||||||
|
|
||||||
|
public RequestState getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(RequestState state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,6 @@
|
|||||||
package ovh.herisson.Clyde.Tables;
|
package ovh.herisson.Clyde.Tables;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
@ -10,8 +8,7 @@ import java.util.Date;
|
|||||||
@Table(name = "Users")
|
@Table(name = "Users")
|
||||||
public class User {
|
public class User {
|
||||||
@Id
|
@Id
|
||||||
@GenericGenerator(name = "userGen", type = ovh.herisson.Clyde.RegNoGenerator.class)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
@GeneratedValue(generator = "userGen")
|
|
||||||
private Long regNo;
|
private Long regNo;
|
||||||
private String lastName;
|
private String lastName;
|
||||||
private String firstName;
|
private String firstName;
|
||||||
|
@ -21,9 +21,12 @@ public class UserCurriculum {
|
|||||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||||
private Curriculum curriculum;
|
private Curriculum curriculum;
|
||||||
|
|
||||||
public UserCurriculum(User user, Curriculum curriculum){
|
private int year;
|
||||||
|
|
||||||
|
public UserCurriculum(User user, Curriculum curriculum, int year){
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.curriculum = curriculum;
|
this.curriculum = curriculum;
|
||||||
|
this.year = year;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserCurriculum() {}
|
public UserCurriculum() {}
|
||||||
@ -47,4 +50,12 @@ public class UserCurriculum {
|
|||||||
public void setCurriculum(Curriculum curriculum) {
|
public void setCurriculum(Curriculum curriculum) {
|
||||||
this.curriculum = curriculum;
|
this.curriculum = curriculum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getYear() {
|
||||||
|
return year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setYear(int year) {
|
||||||
|
this.year = year;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
spring.jpa.hibernate.ddl-auto=create-drop
|
spring.jpa.hibernate.ddl-auto=create-drop
|
||||||
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
|
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
|
||||||
|
spring.sql.init.mode=always
|
@ -23,7 +23,6 @@ import ovh.herisson.Clyde.Repositories.TokenRepository;
|
|||||||
import ovh.herisson.Clyde.Repositories.UserRepository;
|
import ovh.herisson.Clyde.Repositories.UserRepository;
|
||||||
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
import ovh.herisson.Clyde.Responses.UnauthorizedResponse;
|
||||||
import ovh.herisson.Clyde.Services.TokenService;
|
import ovh.herisson.Clyde.Services.TokenService;
|
||||||
import ovh.herisson.Clyde.Services.UserService;
|
|
||||||
import ovh.herisson.Clyde.Tables.Role;
|
import ovh.herisson.Clyde.Tables.Role;
|
||||||
import ovh.herisson.Clyde.Tables.Token;
|
import ovh.herisson.Clyde.Tables.Token;
|
||||||
import ovh.herisson.Clyde.Tables.User;
|
import ovh.herisson.Clyde.Tables.User;
|
||||||
@ -48,8 +47,6 @@ public class UserControllerTest {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TokenService tokenService;
|
private TokenService tokenService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserRepository userRepository;
|
private UserRepository userRepository;
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -82,13 +79,12 @@ public class UserControllerTest {
|
|||||||
tokenRepository.deleteAll();
|
tokenRepository.deleteAll();
|
||||||
userRepository.deleteAll();
|
userRepository.deleteAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
//Verifie qu'un user qui n'a pas les permissions admin ou secretaire ne peut pas post
|
//Verifie qu'un user qui n'a pas les permissions admin ou secretaire ne peut pas post
|
||||||
public void userPostTest(){
|
public void userPostTest(){
|
||||||
User god = new User("god","god","admin@admin.com","everywhere","every",new Date(0), null, Role.Admin,"goddoesntneedpassword");
|
User god = new User("god","god","admin@admin.com","everywhere","every",new Date(0), null, Role.Admin,"goddoesntneedpassword");
|
||||||
Token godToken = new Token(god, tokenService.generateNewToken(), new Date());
|
Token godToken = new Token(god, tokenService.generateNewToken(), new Date());
|
||||||
userService.save(god);
|
userRepository.save(god);
|
||||||
tokenService.saveToken(godToken);
|
tokenService.saveToken(godToken);
|
||||||
|
|
||||||
//Can god post herobrine himself ?
|
//Can god post herobrine himself ?
|
||||||
@ -101,7 +97,7 @@ public class UserControllerTest {
|
|||||||
//Can noob post herobrine without authorizations (no)
|
//Can noob post herobrine without authorizations (no)
|
||||||
User noob = new User("boon","noob","noob@student.com","everywhere","every",new Date(0), null, Role.Student,"noob");
|
User noob = new User("boon","noob","noob@student.com","everywhere","every",new Date(0), null, Role.Student,"noob");
|
||||||
Token noobToken = new Token(noob, tokenService.generateNewToken(), new Date());
|
Token noobToken = new Token(noob, tokenService.generateNewToken(), new Date());
|
||||||
userService.save(noob);
|
userRepository.save(noob);
|
||||||
tokenService.saveToken(noobToken);
|
tokenService.saveToken(noobToken);
|
||||||
|
|
||||||
with().body(herobrine).contentType(ContentType.JSON).header("Authorization", noobToken.getToken()).when().request("POST", "/user").then().statusCode(401);
|
with().body(herobrine).contentType(ContentType.JSON).header("Authorization", noobToken.getToken()).when().request("POST", "/user").then().statusCode(401);
|
||||||
|
@ -7,7 +7,6 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||||
import org.springframework.test.context.TestPropertySource;
|
import org.springframework.test.context.TestPropertySource;
|
||||||
import ovh.herisson.Clyde.Services.UserService;
|
|
||||||
import ovh.herisson.Clyde.Tables.Role;
|
import ovh.herisson.Clyde.Tables.Role;
|
||||||
import ovh.herisson.Clyde.Tables.User;
|
import ovh.herisson.Clyde.Tables.User;
|
||||||
|
|
||||||
@ -25,7 +24,6 @@ public class UserRepoTest {
|
|||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setup(){
|
public void setup(){
|
||||||
userRepo.deleteAll();
|
|
||||||
User herobrine = new User("brine","hero","admin@admin.com","in your WalLs","ShadowsLand", new GregorianCalendar(2005, 4, 3).getTime(), null, Role.Admin,"admin");
|
User herobrine = new User("brine","hero","admin@admin.com","in your WalLs","ShadowsLand", new GregorianCalendar(2005, 4, 3).getTime(), null, Role.Admin,"admin");
|
||||||
userRepo.save(herobrine);
|
userRepo.save(herobrine);
|
||||||
}
|
}
|
||||||
@ -36,8 +34,8 @@ public class UserRepoTest {
|
|||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void usertest(){
|
public void usertest(){
|
||||||
Assert.assertEquals("brine", userRepo.findByEmail("admin@admin.com").getLastName());
|
Assert.assertEquals("brine", userRepo.findById(1).getLastName());
|
||||||
Assert.assertTrue(new GregorianCalendar(2005, 4, 3).getTime().equals(userRepo.findByEmail("admin@admin.com").getBirthDate()));
|
Assert.assertTrue(new GregorianCalendar(2005, 4, 3).getTime().equals(userRepo.findById(1).getBirthDate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
82
frontend/src/Apps/AboutStudent.vue
Normal file
82
frontend/src/Apps/AboutStudent.vue
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<script setup>
|
||||||
|
import i18n from "@/i18n.js"
|
||||||
|
import {getSelf, getUser} from '../rest/Users.js'
|
||||||
|
import {ref} from "vue";
|
||||||
|
|
||||||
|
const user = await getSelf();
|
||||||
|
|
||||||
|
function getPP(){
|
||||||
|
if(user.value.profilePictureUrl === null){
|
||||||
|
return "/Clyde.png"
|
||||||
|
}
|
||||||
|
return user.profilePictureUrl
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="body">
|
||||||
|
<div class="container">
|
||||||
|
<div class="profilPic">
|
||||||
|
<img class="subContainter" :src=getPP()>
|
||||||
|
</div>
|
||||||
|
<div class = "globalInfos">
|
||||||
|
<div class="infosContainer">
|
||||||
|
<div>
|
||||||
|
{{user.firstName}} {{user.lastName}}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
E-mail: {{user.email}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.container{
|
||||||
|
|
||||||
|
display:grid;
|
||||||
|
grid-template-columns:200px 900px;
|
||||||
|
grid-template-rows:200px auto;
|
||||||
|
column-gap:30px;
|
||||||
|
row-gap:45px;
|
||||||
|
grid-template-areas:
|
||||||
|
"profilPic globalInfos"
|
||||||
|
"minfos minfos";
|
||||||
|
}
|
||||||
|
|
||||||
|
.profilPic{
|
||||||
|
grid-area:profilPic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.globalInfos {
|
||||||
|
grid-area:globalInfos;
|
||||||
|
align-self :center;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.body {
|
||||||
|
width:100%;
|
||||||
|
margin-bottom:10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subContainter{
|
||||||
|
width:100%;
|
||||||
|
background-color:rgb(50,50,50);
|
||||||
|
border-radius:20px;
|
||||||
|
border:4px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.infosContainer {
|
||||||
|
padding-bottom:50px;
|
||||||
|
border:2px solid black;
|
||||||
|
font-size:25px;
|
||||||
|
color:white;
|
||||||
|
padding:20px;
|
||||||
|
background-color:rgb(50,50,50);
|
||||||
|
border-radius:20px;
|
||||||
|
}
|
||||||
|
</style>
|
@ -9,6 +9,7 @@ import Profil from "@/Apps/Profil.vue"
|
|||||||
import Courses from "@/Apps/ManageCourses.vue"
|
import Courses from "@/Apps/ManageCourses.vue"
|
||||||
import Users from "@/Apps/UsersList.vue"
|
import Users from "@/Apps/UsersList.vue"
|
||||||
import Students from "@/Apps/StudentsList.vue"
|
import Students from "@/Apps/StudentsList.vue"
|
||||||
|
import AboutStudent from "@/Apps/AboutStudent.vue";
|
||||||
|
|
||||||
const apps = {
|
const apps = {
|
||||||
'/login': LoginPage,
|
'/login': LoginPage,
|
||||||
@ -17,6 +18,7 @@ const apps = {
|
|||||||
'/manage-courses' : Courses,
|
'/manage-courses' : Courses,
|
||||||
'/users-list' : Users,
|
'/users-list' : Users,
|
||||||
'/students-list' : Students,
|
'/students-list' : Students,
|
||||||
|
'/about-students': AboutStudent
|
||||||
}
|
}
|
||||||
|
|
||||||
const appsList = {
|
const appsList = {
|
||||||
@ -28,6 +30,7 @@ const appsList = {
|
|||||||
'ManageCourses': { path: '#/manage-courses', icon: 'fa-book', text: i18n("app.manage.courses") },
|
'ManageCourses': { path: '#/manage-courses', icon: 'fa-book', text: i18n("app.manage.courses") },
|
||||||
'StudentsList':{ path: '#/students-list',icon: 'fa-users',text: i18n("app.studentList")},
|
'StudentsList':{ path: '#/students-list',icon: 'fa-users',text: i18n("app.studentList")},
|
||||||
'UsersList':{ path: '#/users-list',icon: 'fa-users',text: i18n("app.users")},
|
'UsersList':{ path: '#/users-list',icon: 'fa-users',text: i18n("app.users")},
|
||||||
|
'AboutStudent':{ path: '#/about-users', icon: 'fa-users', text:i18n("app.aboutStudent")}
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentPath = ref(window.location.hash)
|
const currentPath = ref(window.location.hash)
|
||||||
|
Reference in New Issue
Block a user