Skip to content
Snippets Groups Projects

Add selection overview

Closed
Sára Juhošovárequested to merge
selection-overview into development
5 open threads
4 files
+ 126
0
Compare changes
  • Side-by-side
  • Inline

Files

+ 64
0
/*
* Queue - A Queueing system that can be used to handle labs in higher education
* Copyright (C) 2016-2021 Delft University of Technology
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package nl.tudelft.queue.controller;
import nl.tudelft.labracore.lib.security.user.AuthenticatedPerson;
import nl.tudelft.labracore.lib.security.user.Person;
import nl.tudelft.queue.repository.SelectionRequestRepository;
import nl.tudelft.queue.service.RequestTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class SelectionController {
@Autowired
private SelectionRequestRepository repository;
    • Could you give this a more specific name? We'll surely add more repositories in the future. Either srr or selectionRequestRepository, personally more a fan of the shorthand.

Please register or sign in to reply
@Autowired
private RequestTableService rts;
/**
* Gets the view representing the request history of the currently authenticated student.
*
* @param user The currently authenticated user.
* @param model The model to fill out for Thymeleaf template resolution.
* @param pageable The pageable dictating what the page of student request should contain.
* @return The Thymeleaf template to resolve.
*/
@GetMapping("/selection")
public String getSelectionView(@AuthenticatedPerson Person user, Model model,
@PageableDefault(sort = "createdAt", direction = Sort.Direction.DESC, size = 25) Pageable pageable) {
model.addAttribute("page", "requests");
Please register or sign in to reply
model.addAttribute("requests", new PageImpl<>(
repository.findAllByRequester(user.getId(), pageable),
pageable,
repository.countByRequester(user.getId())));
return "selection/index";
}
}
Loading