示例#1
0
def funnel_edit(profile, workspace):
    if profile.type != PROFILE_TYPE.ORGANIZATION:
        abort(403)
    form = FunnelSpaceForm(obj=workspace)
    workspace_funnel = WorkspaceFunnel.query.filter_by(workspace=workspace).first()
    form.proposal_template.data = workspace_funnel.proposal_template
    form.status.data = workspace_funnel.status
    if form.validate_on_submit():
        form.populate_obj(workspace)
        workspace_funnel.status = workspace.status
        workspace_funnel.proposal_template = workspace.proposal_template
        db.session.commit()
        flash(u"Edited Event '%s'" % workspace.title, 'success')
        return render_redirect(workspace.url_for(), code=303)
    return render_form(form=form, title="Edit Event", submit=u"Save",
        cancel_url=workspace.url_for(), ajax=True)
示例#2
0
def funnel_new(profile):
    form = FunnelSpaceForm()
    if profile.type != PROFILE_TYPE.ORGANIZATION:
        abort(403)
    if form.validate_on_submit():
        workspace = Workspace(profile=profile)
        workspace.enable_funnel()
        form.populate_obj(workspace)
        if not workspace.name:
            workspace.make_name()
        # workspace.status and workspace.proposal_template are temp variables that came from the form
        workspace.funnel.status = workspace.status
        workspace.funnel.proposal_template = workspace.proposal_template
        db.session.add(workspace)
        db.session.commit()
        flash(u"Created Event '%s'" % workspace.title, 'success')
        return render_redirect(workspace.url_for(), code=303)
    return render_form(form=form, title="New Workspace - Event", submit=u"Save",
        cancel_url=profile.url_for(), ajax=True)