def create_group(project_id): """Adds a new group to a project""" ps = ProjectService() project = ps.get(project_id) form = GroupService().get_form(project) if form.validate_on_submit() and project.id is int(form.project_id.data): group = GroupService().new(number=form.number.data, name=form.name.data) ps.add_group(project, group) flash("Successfully added a new group '%s'" % group, "success") return redirect(url_for("view_project", project_id=project.id)) if request.method == "POST": flash("Unable to add a new group", "danger") return CreateGroup(project).render(form)
def create_project(): """Creates a new project""" ps = ProjectService() form = ps.get_form() if form.validate_on_submit(): project = ps.create( name=form.name.data, description=form.description.data, sponsor_id=form.sponsor.data, species_id=form.species.data, ) flash("Successfully added a new project '%s'" % project.name, "success") return redirect(url_for("list_projects")) if request.method == "POST": flash("Unable to add a new project", "danger") return CreateProject().render(form)