Skip to content
Snippets Groups Projects
Commit 2a893d51 authored by Liam Clark's avatar Liam Clark :speech_balloon:
Browse files

temp changes

parent 01268bd7
No related tags found
No related merge requests found
......@@ -505,6 +505,7 @@ public class CourseController {
@RequestMapping(value = "/course/create", method = RequestMethod.POST)
@PreAuthorize("hasRole('TEACHER')")
public String store(@AuthenticatedUser User user,
@RequestBody String requestBody,
@Valid Course course,
BindingResult bindingResult,
@RequestParam("teacherUsername") Optional<String> teacherUsername,
......
......@@ -68,12 +68,10 @@ public class HomeController {
*/
@RequestMapping("/")
public String index(Model model) {
if (SecurityContextHolder.getContext().getAuthentication() != null
&& SecurityContextHolder.getContext().getAuthentication().isAuthenticated()
&& !(SecurityContextHolder.getContext()
.getAuthentication() instanceof AnonymousAuthenticationToken)) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null
&& authentication.isAuthenticated()
&& !(authentication instanceof AnonymousAuthenticationToken)) {
UserPrincipal userPrincipal = (UserPrincipal) authentication.getPrincipal();
return dashboard(userRepository.findByUsername(userPrincipal.getUsername()), model);
......
......@@ -17,8 +17,11 @@ package nl.tudelft.ewi.queue.repository;
import java.util.List;
import com.querydsl.core.types.dsl.BooleanExpression;
import nl.tudelft.ewi.queue.model.Course;
import nl.tudelft.ewi.queue.model.QCourse;
import nl.tudelft.ewi.queue.model.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
......@@ -49,4 +52,12 @@ public interface CourseRepository
@Override
Page<Course> findAll(Predicate predicate, Pageable pageable);
default Page<Course> nonArchivedOrTaughtByUserCourses(Pageable pageable, User user) {
BooleanExpression archivedAndTeachingCourses = QCourse.course.isArchived.eq(false)
.or(QCourse.course.in(user.getTeaches()));
Page<Course> courses = this.findAll(archivedAndTeachingCourses, pageable);
return courses;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment