Exemplo n.º 1
0
Arquivo: views.py Projeto: gluker/jaot
def editPSet(pset_id):
    pset = db_session.query(ProblemSet).get(pset_id)
    course = db_session.query(Course).get(pset.course_id)
    if None in [pset,course]:
        abort(404)
    form = ProblemSetForm(request.form)
    if request.method == "POST" and form.validate():
        pset.title = form.title.data
        pset.opens = form.opens.data
        pset.due = form.due.data
        db_session.commit()
        return redirect(url_for('showPSet',course_id=course.id,pset_id=pset.id))
    return render_template("editpset.html",course=course,pset=pset)
Exemplo n.º 2
0
Arquivo: views.py Projeto: gluker/jaot
def newPSet(course_id):
    course = db_session.query(Course).get(course_id)
    if course is None:
        abort(404)
    form = ProblemSetForm(request.form)
    if request.method == "POST" and form.validate():
        pset = ProblemSet()
        pset.title = form.title.data
        pset.opens = form.opens.data
        pset.due = form.due.data
        pset.course_id=course.id
        course.problemsets.append(pset)
        db_session.commit()
        return redirect(url_for("showCourse", course_id=course.id))
    return render_template("newpset.html", course=course, form=form)