Beispiel #1
0
def save_problem(request, user):
    form = AddProblemForm(request.form)
    try:
        mission = Mission.load(request.session, id=form.mission_id.data)
    except NoResultFound:
        return {}, "notfound.phtml", 404

    title = form.title.data
    description = form.description.data

    try:
        Problem.load(request.session, title=title, mission_id=mission.id)
        return {"form": form, "mission": mission, "error": "Problem already reported"}, "admin/addproblem.phtml"
    except NoResultFound:
        Problem(title=title, mission=mission, description=description, created=datetime.utcnow())
        return redirect("/mission/%d" % mission.id)
Beispiel #2
0
def submit_form(request, problem_id):

    try:
        problem = Problem.load(request.session, id=problem_id)
    except NoResultFound:
        return {}, 'notfound.phtml', 404

    form = ProposalForm()
    form.problem_id.data = problem_id

    return {'form': form, 'problem': problem}, \
           'user/submit.phtml'
Beispiel #3
0
def save_proposal(request, user):
    form = ProposalForm(request.form)

    try:
        problem = Problem.load(request.session, id=form.problem_id.data)
    except NoResultFound:
        return {}, 'notfound.phtml', 404

    img = request.files['img'].stream.read().encode('base64')
    model = request.files['model'].stream.read().encode('base64')

    proposal = Proposal(problem=problem,
                        submiter=user,
                        submited=datetime.utcnow(),
                        title=form.title.data,
                        description=form.description.data,
                        img=img,
                        model=model)
    request.session.flush()

    return redirect('/proposal/%d' % proposal.id)