Esempio n. 1
0
File: views.py Progetto: nocko/cfmi
def list_edit(list_name):
    l = MailingList.query.filter_by(name=list_name).first()
    if not l: abort(404)
    form = MailingListForm(obj=l)
    if request.method == 'POST':
        if form.validate_on_submit():
            form.populate_obj(l)
            try:
                db.session.commit()
                flash("Sucess: Mailing List Modified")
                return redirect(request.url)
            except:
                flash("Failed to update database")
                db.session.rollback()
        return redirect(request.url)
    form = MailingListForm(obj=l)
    return render_template('list_edit.html', form=form, mailinglist=l)
Esempio n. 2
0
File: views.py Progetto: nocko/cfmi
def list_list():
    form = MailingListForm()
    l = MailingList()
    if request.method == 'POST':
        if form.validate_on_submit():
            form.populate_obj(l)
            try:
                db.session.add(l)
                db.session.commit()
                flash("Sucess: List Created")
                return redirect(request.url)
            except:
                flash("Failed to update database")
                db.session.rollback()
        return render_template('list_edit.html', form=form, mailinglist=l)
    lists = MailingList.query.order_by(MailingList.name)
    return render_template('list_list.html', lists=lists, form=form)