示例#1
0
def jam_unregister(jam_slug):
    jam = Jam.query.filter_by(slug = jam_slug).first_or_404()

    if jam.getStatus().code > JamStatusCode.RUNNING:
        flash("You cannot unregister from a jam after it has finished.", "error")
        return redirect(jam.url())

    form = UnregisterJamForm()

    if form.validate_on_submit():
        current_user.leaveJam(jam)
        db.session.commit()
        flash("You are now unregistered from this jam.", "success")
        return redirect(jam.url())

    return render_template('jam/unregister.html', jam = jam, form = form)
示例#2
0
def jam_cancel_participation(jam_slug):
    jam = Jam.query.filter_by(slug = jam_slug).first_or_404()

    if jam.getStatus().code > JamStatusCode.PACKAGING:
        flash("You cannot unregister from a jam after it has finished or is in rating phase.", "error")
        return redirect(jam.url())

    form = CancelParticipationForm()

    if form.validate_on_submit():
        current_user.leaveJam(jam)
        db.session.commit()
        flash("You are now unregistered from this jam.", "success")
        return redirect(jam.url())

    return render_template('jam/cancel_participation.html', jam = jam, form = form)