public static void update(Time entity) {
    entity.Milestone = Milestone.findById(entity.Task.Milestone.id);

    validation.valid(entity);
    if (validation.hasErrors()) {
      flash.error(Messages.get("scaffold.validation"));
      render("@edit", entity);
    }

    entity = entity.merge();
    entity.save();
    flash.success(Messages.get("scaffold.updated", "Time"));
    index();
  }
  public static void save(Time entity) {
    entity.createdBy = User.find("byUserName", Security.connected()).<User>first();

    if (entity.Task != null) {
      entity.Milestone = Milestone.findById(entity.Task.Milestone.id);
    } else if (entity.Issue != null) {
      entity.Milestone = Milestone.findById(entity.Issue.Milestone.id);
    }

    validation.valid(entity);
    if (validation.hasErrors()) {
      flash.error(Messages.get("scaffold.validation"));
      render("@create", entity);
    }
    entity.save();
    flash.success(Messages.get("scaffold.created", "Time"));

    if (entity.Task != null) {
      Tasks.show(entity.Task.id);
    } else {
      Issues.show(entity.Issue.id);
    }
  }
Exemple #3
0
 private static void collectDatum(
     List<Project> projects,
     List<Posting> postings,
     List<Issue> issues,
     List<PullRequest> pullRequests,
     List<Milestone> milestones,
     int daysAgo) {
   // collect all postings, issues, pullrequests and milesotnes that are contained in the projects.
   for (Project project : projects) {
     if (AccessControl.isAllowed(UserApp.currentUser(), project.asResource(), Operation.READ)) {
       postings.addAll(Posting.findRecentlyCreatedByDaysAgo(project, daysAgo));
       issues.addAll(Issue.findRecentlyOpendIssuesByDaysAgo(project, daysAgo));
       pullRequests.addAll(PullRequest.findOpendPullRequestsByDaysAgo(project, daysAgo));
       milestones.addAll(Milestone.findOpenMilestones(project.id));
     }
   }
 }
 public Result addMilestone() {
   Milestone milestone = Form.form(Milestone.class).bindFromRequest().get();
   milestone.save();
   return redirect(routes.ProjectController.show(milestone.project.id));
 }