@RequestMapping(method = RequestMethod.GET) public AnnouncementsAdminView all( Model model, @PathVariable ExecutionCourse executionCourse, @RequestParam(required = false, defaultValue = "1") int page) { Professorship professorship = executionCourse.getProfessorship(AccessControl.getPerson()); AccessControl.check( person -> professorship != null && professorship.getPermissions().getAnnouncements()); List<Post> announcements = getAnnouncements(executionCourse.getSite()); model.addAttribute("executionCourse", executionCourse); int pages = IntMath.divide(announcements.size(), PER_PAGE, RoundingMode.CEILING); if (page < 1) { page = 1; } if (page > pages) { page = pages; } model.addAttribute("currentPage", page); model.addAttribute("pages", pages); model.addAttribute( "announcements", announcements .stream() .skip((page - 1) * PER_PAGE) .limit(PER_PAGE) .collect(Collectors.toList())); model.addAttribute("professorship", professorship); return new AnnouncementsAdminView(); }
private void createReportsGroup(CurricularCourseResumeResult courseResumeResult, HtmlMenu menu) { String calculatedUrl; HtmlMenuGroup reportsGroup = menu.createGroup( RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.inquiry.reports")); for (InquiryDelegateAnswer inquiryDelegateAnswer : courseResumeResult.getExecutionCourse().getInquiryDelegatesAnswersSet()) { if (inquiryDelegateAnswer.getExecutionDegree() == courseResumeResult.getExecutionDegree()) { String delegateInquiryParameters = buildParametersForDelegateInquiry(inquiryDelegateAnswer); HtmlLink delegateLink = new HtmlLink(); delegateLink.setEscapeAmpersand(false); delegateLink.setModule("/publico"); delegateLink.setUrl("/viewQUCInquiryAnswers.do?" + delegateInquiryParameters); calculatedUrl = delegateLink.calculateUrl(); HtmlMenuOption optionDelegate = reportsGroup.createOption(); optionDelegate.setText( RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.inquiry.delegate")); optionDelegate.setValue( calculatedUrl + "&_request_checksum_=" + GenericChecksumRewriter.calculateChecksum(calculatedUrl, getSession())); } } for (Professorship professorship : courseResumeResult.getExecutionCourse().getProfessorshipsSet()) { if (professorship.getInquiryTeacherAnswer() != null) { HtmlLink teacherLink = new HtmlLink(); teacherLink.setEscapeAmpersand(false); teacherLink.setModule("/publico"); teacherLink.setUrl( "/viewQUCInquiryAnswers.do?method=showTeacherInquiry&professorshipOID=" + professorship.getExternalId()); calculatedUrl = teacherLink.calculateUrl(); HtmlMenuOption optionTeacher = reportsGroup.createOption(); optionTeacher.setText( RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.teacher") + " (" + professorship.getPerson().getName() + ")"); optionTeacher.setValue( calculatedUrl + "&_request_checksum_=" + GenericChecksumRewriter.calculateChecksum(calculatedUrl, getSession())); } } for (Professorship professorship : courseResumeResult.getExecutionCourse().getProfessorshipsSet()) { if (professorship.getInquiryRegentAnswer() != null) { HtmlLink regentLink = new HtmlLink(); regentLink.setEscapeAmpersand(false); regentLink.setModule("/publico"); regentLink.setUrl( "/viewQUCInquiryAnswers.do?method=showRegentInquiry&professorshipOID=" + professorship.getExternalId()); calculatedUrl = regentLink.calculateUrl(); HtmlMenuOption optionRegent = reportsGroup.createOption(); optionRegent.setText( RenderUtils.getResourceString("INQUIRIES_RESOURCES", "label.inquiry.regent") + " (" + professorship.getPerson().getName() + ")"); optionRegent.setValue( calculatedUrl + "&_request_checksum_=" + GenericChecksumRewriter.calculateChecksum(calculatedUrl, getSession())); } } }