Ignore:
Timestamp:
10/07/21 20:29:27 (3 years ago)
Author:
KostaFortumanov <kfortumanov@…>
Branches:
master
Children:
7888b17
Parents:
0c37625
Message:

bug fix

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

Legend:

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

    r0c37625 ree0e297  
    128128                        @RequestParam(required = false,defaultValue = "") String order) {
    129129        Page<DonationPost> postList = donationPostService.findPaginated(page,6, sort, order, true);
    130         if (postList.getSize() == 0) {
     130        if (postList.getTotalElements() == 0) {
    131131            model.addAttribute("noPosts", true);
    132132            return "album";
  • src/main/java/it/finki/charitable/controller/ModeratorController.java

    r0c37625 ree0e297  
    3939                           @RequestParam(required = false,defaultValue = "") String order) {
    4040        Page<DonationPost> postList = donationPostService.findPaginated(page, 6, sort, order, false);
    41         if (postList.getSize() == 0) {
     41        if (postList.getTotalElements() == 0) {
    4242            model.addAttribute("noPosts", true);
    4343            return "postApproval";
     
    7272        donationPostService.save(post);
    7373        emailService.sendApprovalEmail(post.getUser().getEmail(), "CharitAbleMk: " + post.getTitle() + " has been approved", postid);
    74         return "redirect:/moderator/approval";
     74        return "redirect:/moderator/approval?page=1&sort=id";
    7575    }
    7676
     
    8181        emailService.sendNoApprovalEmail(post.getUser().getEmail(), "CharitAbleMk: " + post.getTitle() + " has not been approved", description);
    8282        deleteDonationPost(post);
    83         return "redirect:/moderator/approval";
     83        return "redirect:/moderator/approval?page=1&sort=id";
    8484    }
    8585
    8686    @RequestMapping("/moderator/myApprovedPosts")
    87     public String myApprovedPosts(Model model) {
     87    public String myApprovedPosts(Model model,
     88                                  @RequestParam int page,
     89                                  @RequestParam String sort,
     90                                  @RequestParam(required = false,defaultValue = "") String order) {
    8891        Moderator moderator = (Moderator) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    89         List<DonationPost> postList = donationPostService.findAllByModerator(moderator);
    90         if (postList.size() == 0) {
     92        Page<DonationPost> postList = donationPostService.findAllByModerator(page, 6, sort, order, moderator);
     93        if (postList.getTotalElements() == 0) {
    9194            model.addAttribute("noPosts", true);
    9295            return "postApproval";
    9396        }
     97        model.addAttribute("totalPages", postList.getTotalPages());
    9498        model.addAttribute("postList", postList);
    9599        return "postApproval";
     
    102106                                @RequestParam(required = false,defaultValue = "") String order) {
    103107        Page<ReportPost> postList = reportPostService.findAll(page, 6, sort, order);
    104         if (postList.getSize() == 0) {
     108        if (postList.getTotalElements() == 0) {
    105109            model.addAttribute("noPosts", true);
    106110            return "reportedPosts";
    107111        }
     112        model.addAttribute("totalPages",postList.getTotalPages());
    108113        model.addAttribute("postList", postList);
    109114        return "reportedPosts";
     
    130135        ReportPost post = reportPostService.findById(postid);
    131136        deleteReportPost(post);
    132         return "redirect:/moderator/report";
     137        return "redirect:/moderator/report?page=1&sort=id";
    133138    }
    134139
     
    141146        deleteReportPost(post);
    142147        deleteDonationPost(donationPost);
    143         return "redirect:/moderator/approval";
     148        return "redirect:/moderator/approval?page=1&sort=id";
    144149    }
    145150
Note: See TracChangeset for help on using the changeset viewer.