Beispiel #1
0
  // @Post("/projects/create")
  public static void doCreate(Project project) {
    User user = getLoggedin();
    List<ProjectTemplate> templates = ProjectTemplate.getTemplates(user, false);
    if (params.get("project.deadline") == "") {
      project.deadline = null;
    }

    Validation.valid("Project", project);
    if (Validation.hasErrors()) {
      displayValidationMessage();
      render("projects/create.html", project, templates);
    }

    ActionResult res;
    res = project.createAndGetResult(user);

    if (!res.isSuccess()) {
      displayError(res.getMessage(), "save-project");
      render("projects/create.html", project, templates);
    }

    res = project.assignCreator(user, null);
    if (!res.isSuccess()) {
      displayError(res.getMessage(), "set-creator-when-save-project");
      render("projects/create.html", project, templates);
    }
    project.copyFromTemplate(user, project.fromTemplate);

    if (!res.isSuccess()) {
      displayWarning(res.getMessage(), "save-activity-when-create-project");
    }
    structure(project.id);
  }
Beispiel #2
0
 public static void createTemplate(
     Long project_id,
     @Required(message = "A Project template need at least 1 listing") Long[] listings,
     @Required(message = "Template Name is required") String name) {
   if (Validation.hasErrors()) {
     displayValidationMessage();
     List<ProjectTemplate> templates = ProjectTemplate.getTemplates(getLoggedin(), true);
     render("projects/templates.html", templates);
   }
   User u = getLoggedin();
   ProjectTemplate pt =
       ProjectTemplate.createFromProject(getActiveProject(), name, listings, u, params);
   pt.save();
   flash.put("success", "Project Template created!");
   templates(project_id);
 }
Beispiel #3
0
 public static void create() {
   Project project = new Project();
   List<ProjectTemplate> templates = ProjectTemplate.getTemplates(getLoggedin(), false);
   render(project, templates);
 }
Beispiel #4
0
 public static void templates(Long project_id) {
   List<ProjectTemplate> templates = ProjectTemplate.getTemplates(getLoggedin(), true);
   render(templates);
 }