def new_notice(): if request.method == 'GET': return render_template('admin/edit_notice.html') else: logi('new notice') try: validate_notice() except ValueError, e: logi('new notice: validation error') return render_template('admin/edit_notice.html', errors=e.errors) n = notices.make_obj(request.form) notices.insert(n['title'], n['begin_show'], n['end_show'], n['body']) return redirect(url_for('admin.notice'))
def edit_notice(id): if request.method == 'GET': notice = notices.find_by_id(id) return render_template('admin/edit_notice.html', notice=notice) else: logi('edit notice') try: validate_notice() except ValueError, e: logi('edit notice: validation error errors=%s', e.errors.keys()) notice = notices.find_by_id(id) return render_template('admin/edit_notice.html', notice=notice, errors=e.errors) n = notices.make_obj(request.form) logi('edit notice: update id=%d, begin_show=%s, end_show=%s', id, n['begin_show'], n['end_show']) notices.update(id, n['title'], n['begin_show'], n['end_show'], n['body']) return redirect(url_for('admin.notice'))