예제 #1
0
  public static void groupsEdit(String gid) {

    // even if we should skip load for edition reason, we still need to load the real group for the
    // security check
    ProjectGroup group = BeanProvider.getGroupService().loadGroupById(gid, false);

    if (group == null || !group.isActive()) {
      // group does not exist!
      Application.index();
    } else {
      GroupPep pep = new GroupPep(group);
      if (!pep.isUserAllowedToEditGroup(getSessionWrapper().getLoggedInUserProfileId())) {
        // user not allowed to edit this group!
        Application.index();
      } else {

        if (!flash.contains(FLASH_SKIP_LOADING_GROUP)) {
          renderArgs.put("editedGroup", new EditedGroup(group));
        }

        Utils.addThemesToRenderArgs(getSessionWrapper(), renderArgs);
        Utils.addJsonThemesToRenderArgs(
            getSessionWrapper(), renderArgs, getSessionWrapper().getSelectedLg());
        flash.put(FLASH_GROUP_ID, gid);
        render();
      }
    }
  }
예제 #2
0
  public static void doEditGroup(EditedGroup editedGroup) {

    DabValidators.validateEditedGroup(editedGroup, validation, flash);

    if (Validation.hasErrors()) {
      params.flash();
      Validation.keep();

      flash.put(FLASH_SKIP_LOADING_GROUP, true);
      groupsEdit(flash.get(FLASH_GROUP_ID));
    } else {

      ProjectGroup updated =
          BeanProvider.getGroupService().loadGroupById(flash.get(FLASH_GROUP_ID), false);
      if (updated != null) {

        GroupPep pep = new GroupPep(updated);
        if (pep.isUserAllowedToEditGroup(getSessionWrapper().getLoggedInUserProfileId())) {
          editedGroup.applyToGroup(updated);
          BeanProvider.getGroupService().updateGroupData(updated);
          Utils.waitABit();
        }
      }

      ProfileHome.profileHome();
    }
  }
예제 #3
0
  public String getElapsedTimeSinceCreation() {

    long elapsedMillis = Utils.countElapsedMillisSince(creationDate);

    if (elapsedMillis < ONE_MINUTE_IN_MILLIS) {
      elapsedTimeUnit = ELAPSED_TIME_UNIT.SECONDS;
      elapsedTimeSinceCreation = "";
    } else if (elapsedMillis < ONE_HOUR_IN_MILLIS) {
      elapsedTimeUnit = ELAPSED_TIME_UNIT.MINUTES;
      elapsedTimeSinceCreation =
          Integer.toString((int) Math.floor(elapsedMillis / ONE_MINUTE_IN_MILLIS));
    } else if (elapsedMillis < ONE_HOUR_IN_MILLIS) {
      elapsedTimeUnit = ELAPSED_TIME_UNIT.HOURS;
      elapsedTimeSinceCreation =
          Integer.toString((int) Math.floor(elapsedMillis / ONE_HOUR_IN_MILLIS));
    } else {
      elapsedTimeUnit = ELAPSED_TIME_UNIT.NONE;
      elapsedTimeSinceCreation = Utils.formatDate(creationDate);
    }

    return elapsedTimeSinceCreation;
  }