def funnel_edit(profile, workspace, proposal): if proposal.profile.userid != g.user.userid: abort(403) form = ProposalForm(obj=proposal) workspace_funnel = WorkspaceFunnel.query.filter_by(workspace=workspace).first() form.section_id.choices = [(item.id, item.name) for item in FunnelSpaceSection.query.filter_by(workspace_funnel=workspace_funnel, public=True).order_by('title')] if request.method == 'GET': form.is_speaking.data = proposal.profile == g.user if form.validate_on_submit(): form.populate_obj(proposal) if not proposal.name: proposal.make_name() db.session.commit() flash(u"Edited Proposal '%s'" % proposal.title, 'info') return render_redirect(proposal.url_for(), code=303) return render_form(form=form, title="Edit Proposal", submit=u"Save", cancel_url=workspace.url_for(), ajax=True)
def funnel_new(profile, workspace): if not (workspace.has_funnel and workspace.funnel.is_open()): abort(403) form = ProposalForm() if request.method == "GET": form.description.data = workspace.funnel.proposal_template if form.validate_on_submit(): proposal = Proposal(funnel=workspace.funnel) proposal.user = g.user form.populate_obj(proposal) if not proposal.name: proposal.make_name() proposal.make_id() proposal.votes.vote(g.user) db.session.add(proposal) db.session.commit() flash(u"Created Proposal '%s'" % proposal.title, 'success') return render_redirect(proposal.url_for(), code=303) return render_form(form=form, title="New Proposal", submit=u"Save", cancel_url=workspace.url_for(), ajax=True)