Beispiel #1
0
def edit_tag(t_id):
    tag = get_tag(t_id)
    form = TagForm(tag=tag['tag'], parent=tag['parent'])

    form.set_choices()

    if form.validate_on_submit():
        d = _to_dict(form)
        update_tag(d, t_id)
        return redirect(url_for('table_tags'))

    return render_template(form.template, form=form, name='Редактировать тег')
Beispiel #2
0
def add_tag():
    form = TagForm()

    form.set_choices()
    if form.validate_on_submit():
        d = _to_dict(form)
        try:
            form.add(d)
        except:
            flash("Что-то пошло не так. Вероятно, такой тег уже существует")
            return redirect(url_for('add_tag'))
        return redirect(url_for('table_tags'))

    return render_template(form.template, form=form, name="Add tag")