Ejemplo n.º 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)
Ejemplo n.º 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
    )
Ejemplo n.º 3
0
def contacts():
    contacts_obj = Contact.query(
        Contact.is_public == True).order(-Contact.order_id)
    managers = Manager.query(Manager.is_public == True)
    return flask.render_template('pages/contact.html',
                                 title=u'Контакты',
                                 contacts=contacts_obj,
                                 managers=managers)
Ejemplo n.º 4
0
def save(data, user):
    contact = Contact()

    if user.id is None:
        contact.contact_name = data['name']
        contact.contact_email = data['email']
    else:
        contact.author = user

    contact.subject = data['subject']
    contact.message = data['message']

    contact.save()
    return contact
Ejemplo n.º 5
0
def contacts():
    contacts_obj = Contact.query(Contact.is_public == True).order(-Contact.order_id)
    managers = Manager.query(Manager.is_public == True)
    return flask.render_template(
        'pages/contact.html',
        title=u'Контакты',
        contacts=contacts_obj,
        managers=managers
    )
Ejemplo n.º 6
0
 def create(self, validated_data):
     contacts = validated_data.pop('contacts', [])
     if contacts:
         with transaction.atomic():
             organization = Organization.objects.create(**validated_data)
             Contact.objects.bulk_create([
                 Contact(**each, organization=organization)
                 for each in contacts
             ])
     else:
         organization = Organization.objects.create(**validated_data)
     return organization
Ejemplo n.º 7
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)
Ejemplo n.º 8
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
    )
Ejemplo n.º 9
0
def index():
    contacts = Contact.query().order(-Contact.order_id)
    return render_template(
        'admin/contact/index.html',
        contacts=contacts
    )
Ejemplo n.º 10
0
def index():
    contacts = Contact.query().order(-Contact.order_id)
    return render_template('admin/contact/index.html', contacts=contacts)