Ignore:
Timestamp:
10/07/21 20:22:23 (3 years ago)
Author:
NikolaCenevski <cenevskinikola@…>
Branches:
master
Children:
ee0e297
Parents:
276a8b6
Message:

Moderator pagination

Location:
src/main/java/it/finki/charitable/controller
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/it/finki/charitable/controller/DonationPostController.java

    r276a8b6 r0c37625  
    127127                        @RequestParam String sort,
    128128                        @RequestParam(required = false,defaultValue = "") String order) {
    129         Page<DonationPost> postList = donationPostService.findPaginated(page,6, sort, order);
     129        Page<DonationPost> postList = donationPostService.findPaginated(page,6, sort, order, true);
    130130        if (postList.getSize() == 0) {
    131131            model.addAttribute("noPosts", true);
     
    204204        reasonService.save(reason);
    205205        reportPost.getReasons().add(reason);
     206        reportPost.setNumReports(reportPost.getNumReports() + 1);
    206207        reportPostService.save(reportPost);
    207208        return String.format("redirect:/post?postid=%d", postid);
  • src/main/java/it/finki/charitable/controller/ModeratorController.java

    r276a8b6 r0c37625  
    66import it.finki.charitable.services.ReasonService;
    77import it.finki.charitable.services.ReportPostService;
     8import org.springframework.data.domain.Page;
    89import org.springframework.security.core.context.SecurityContextHolder;
    910import org.springframework.stereotype.Controller;
     
    3334
    3435    @RequestMapping("moderator/approval")
    35     public String approval(Model model) {
    36         List<DonationPost> postList = donationPostService.findAllByApproved(false);
    37         if (postList.size() == 0) {
     36    public String approval(Model model,
     37                           @RequestParam int page,
     38                           @RequestParam String sort,
     39                           @RequestParam(required = false,defaultValue = "") String order) {
     40        Page<DonationPost> postList = donationPostService.findPaginated(page, 6, sort, order, false);
     41        if (postList.getSize() == 0) {
    3842            model.addAttribute("noPosts", true);
    3943            return "postApproval";
    4044        }
     45        model.addAttribute("totalPages", postList.getTotalPages());
    4146        model.addAttribute("postList", postList);
    4247        return "postApproval";
     
    9297
    9398    @RequestMapping("/moderator/report")
    94     public String reportedPosts(Model model) {
    95         List<ReportPost> postList = reportPostService.findAll();
    96         if (postList.size() == 0) {
     99    public String reportedPosts(Model model,
     100                                @RequestParam int page,
     101                                @RequestParam String sort,
     102                                @RequestParam(required = false,defaultValue = "") String order) {
     103        Page<ReportPost> postList = reportPostService.findAll(page, 6, sort, order);
     104        if (postList.getSize() == 0) {
    97105            model.addAttribute("noPosts", true);
    98106            return "reportedPosts";
Note: See TracChangeset for help on using the changeset viewer.