def project_new(profile, event, form=None): participant = Participant.get(user=g.user, event=event) if participant == None: abort(403) if participant.status != PARTICIPANT_STATUS.CONFIRMED: abort(403) form = ProjectForm() if form.validate_on_submit(): project = Project(participant=participant, event=event) form.populate_obj(project) project.make_name() db.session.add(project) project.votes.vote(g.user) project_member = ProjectMember(project=project, participant=participant) db.session.add(project_member) db.session.commit() flash("Project saved") return render_redirect( url_for('project_view', profile=profile.name, event=event.name, project=project.url_name)) return render_form(form=form, title=u"New Project", submit=u"Save", cancel_url=url_for('event_view', profile=profile.name, event=event.name), ajax=False)
def project_edit(profile, project, event): if g.user not in project.users: abort(403) else: form = ProjectForm(obj=project) if request.method == 'GET': form.participating.data = str(int(project.participating)) if form.validate_on_submit(): form.populate_obj(project) project.make_name() db.session.commit() flash(u"Your changes have been saved", 'success') return render_redirect(project.url_for(), code=303) return render_form(form=form, title=u"Edit project", submit=u"Save", cancel_url=project.url_for(), ajax=False)
def project_new(profile, event, form=None): participant = Participant.get(user=g.user, event=event) if participant == None: abort(403) if participant.status != PARTICIPANT_STATUS.CONFIRMED: abort(403) form = ProjectForm() if form.validate_on_submit(): project = Project(participant=participant, event=event) form.populate_obj(project) project.make_name() db.session.add(project) project.votes.vote(g.user) project_member = ProjectMember(project=project, participant=participant) db.session.add(project_member) db.session.commit() flash("Project saved") return render_redirect(url_for('project_view', profile=profile.name, event=event.name, project=project.url_name)) return render_form(form=form, title=u"New Project", submit=u"Save", cancel_url=url_for('event_view', profile=profile.name, event=event.name), ajax=False)