예제 #1
0
def submit(request):
    if request.method == "POST":
        form = forms.SubmissionForm(request.form)
        if form.validate():
            submission = models.Submission(account=local.account,
                                           simultaneous=form.simultaneous.data,
                                           cover_letter=db.Text(utils.text_tidy(form.cover_letter.data)),
                                           title=utils.text_tidy(form.title.data),
                                           text_list=[db.Text(utils.text_tidy(form.text.data))],
                                           categories=form.categories.data)
            submission.put()
            flash("Your submission has been saved.")
            return redirect(url_for('home/preview', submission_id=submission.key().id()))
    else:
        form = forms.SubmissionForm()
    return render_response('submit.html', form=form)
예제 #2
0
def resubmit(request, submission_id):
    submission = models.Submission.get_by_id(submission_id)
    if submission is None or submission.account.key().id() != local.account.key().id():
        logging.warning('Attempt to resubmit submission "%s" by account "%s" with email "%s".' % (submission_id, local.account.key().id(), local.account.email))
        return redirect(url_for('main/index'))
    if request.method == "POST":
        form = forms.ResubmissionForm(request.form)
        if form.validate():
            submission.text_list.append(db.Text(utils.text_tidy(form.text.data)))
            submission.put()
            flash("Your submission has been updated.")
            return redirect(url_for('home/preview', submission_id=submission.key().id()))
    else:
        form = forms.ResubmissionForm(obj=submission)
    return render_response('resubmit.html', form=form, submission=submission)