Example #1
0
def add():
    form = ContactForm()
    if form.validate_on_submit():
        new_contact = Contact()
        form.populate_obj(new_contact)
        set_geo(form, new_contact)
        new_contact.put()
        return redirect(url_for('admin.contact.index'))
    return render_template('admin/contact/add.html', form=form)
Example #2
0
def add():
    form = ContactForm()
    if form.validate_on_submit():
        new_contact = Contact()
        form.populate_obj(new_contact)
        set_geo(form, new_contact)
        new_contact.put()
        return redirect(url_for('admin.contact.index'))
    return render_template(
        'admin/contact/add.html',
        form=form
    )
Example #3
0
def edit(key_id):
    contact = Contact.retrieve_by_id(key_id)
    if not contact:
        flash(u'Не удалось найти указанный контакт "%s"' % key_id,
              category='error')
        return redirect(url_for('admin.contact.index'))
    if request.method == 'POST' and 'delete_contact' in request.form:
        contact.key.delete()
        flash(u'Контакт удален')
        return redirect(url_for('admin.contact.index'))
    form = ContactForm(obj=contact)
    if request.method == 'GET':
        get_geo(contact, form)
    if form.validate_on_submit():
        form.populate_obj(contact)
        set_geo(form, contact)
        contact.put()
        flash(u'Контакт обновлен', category='success')
        return redirect(url_for('admin.contact.index'))
    return render_template('admin/contact/edit.html', form=form)
Example #4
0
def edit(key_id):
    contact = Contact.retrieve_by_id(key_id)
    if not contact:
        flash(u'Не удалось найти указанный контакт "%s"' % key_id, category='error')
        return redirect(url_for('admin.contact.index'))
    if request.method == 'POST' and 'delete_contact' in request.form:
        contact.key.delete()
        flash(u'Контакт удален')
        return redirect(url_for('admin.contact.index'))
    form = ContactForm(obj=contact)
    if request.method == 'GET':
        get_geo(contact, form)
    if form.validate_on_submit():
        form.populate_obj(contact)
        set_geo(form, contact)
        contact.put()
        flash(u'Контакт обновлен', category='success')
        return redirect(url_for('admin.contact.index'))
    return render_template(
        'admin/contact/edit.html',
        form=form
    )