@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();
 }
 protected ExternalEnrolment() {
   super();
   setRootDomainObject(Bennu.getInstance());
   setCreationDateDateTime(new DateTime());
   if (AccessControl.getPerson() != null) {
     setCreatedBy(AccessControl.getPerson().getUsername());
   }
 }
Ejemplo n.º 3
0
  public ActionForward uploadFile(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    IViewState viewState = RenderUtils.getViewState("upload");
    if (viewState == null) {
      return prepareFileUpload(mapping, form, request, response);
    }

    UnitFileUploadBean bean = (UnitFileUploadBean) viewState.getMetaObject().getObject();
    RenderUtils.invalidateViewState();

    if (!bean.getUnit().getAllowedPeopleToUploadFilesSet().contains(AccessControl.getPerson())) {
      return manageFiles(mapping, form, request, response);
    }

    try (InputStream stream = bean.getUploadFile()) {
      CreateUnitFile.run(
          ByteStreams.toByteArray(stream),
          bean.getFileName(),
          bean.getName(),
          bean.getDescription(),
          bean.getTags(),
          bean.getGroup(),
          getUnit(request),
          getLoggedPerson(request));
    } catch (DomainException | IOException e) {
      addActionMessage(request, e.getMessage());
    }
    return manageFiles(mapping, form, request, response);
  }
 protected Teacher getLoggedTeacher() {
   final Person person = AccessControl.getPerson();
   if (person != null) {
     final Teacher teacher = person.getTeacher();
     return teacher;
   }
   return null;
 }
  public ActionForward viewStudentLog(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response) {

    Person person = AccessControl.getPerson();

    Collection<PersonInformationLog> logsList = person.getPersonInformationLogsSet();
    request.setAttribute("person", person);
    request.setAttribute("logsList", logsList);
    return mapping.findForward("viewStudentLogChanges");
  }
Ejemplo n.º 6
0
  public ActionForward deleteFile(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    UnitFile file = getUnitFile(request);
    if (file != null
        && file.getUnit().getAllowedPeopleToUploadFilesSet().contains(AccessControl.getPerson())) {
      DeleteUnitFile.run(file);
    }
    return manageFiles(mapping, form, request, response);
  }
  @EntryPoint
  public ActionForward showThesisList(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {

    final Person person = AccessControl.getPerson();
    if (person != null) {
      final ThesisPresentationWrapperSet orientedTheses =
          new ThesisPresentationWrapperSet(person, ThesisParticipationType.ORIENTATOR);
      request.setAttribute("orientedTheses", orientedTheses);
      final ThesisPresentationWrapperSet coorientedTheses =
          new ThesisPresentationWrapperSet(person, ThesisParticipationType.COORIENTATOR);
      request.setAttribute("coorientedTheses", coorientedTheses);
    }

    return mapping.findForward("showThesisList");
  }
 protected Party getParty(final HttpServletRequest request) {
   return AccessControl.getPerson();
 }