コード例 #1
0
ファイル: views.py プロジェクト: DataViva/dataviva-site
def create():
    form = ContactForm()
    if form.validate() is False:
        for error_type in form.errors:
            if form.errors[error_type][0] in dictionary():
                form.errors[error_type][0] = dictionary()[form.errors[error_type][0]]
        return render_template('contact/index.html', form=form, action=url_for('contact.create'))
    else:
        contact = Form()
        contact.name = form.name.data
        contact.email = form.email.data
        contact.subject = form.subject.data
        contact.message = form.message.data
        contact.postage_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')

        message_tpl = render_template('contact/message_template.html', contact=contact)

        db.session.add(contact)
        db.session.commit()
        send_mail("Contato - DataViva", [admin_email], message_tpl)

        message = gettext("Your message has been sent successfully. We will soon get back to you.")
        flash(message, 'success')

        return redirect(url_for('contact.create'))
コード例 #2
0
def create():
    form = ContactForm()
    if form.validate() is False:
        return Response(status=400, mimetype='application/json')
    else:
        contact = Form()
        contact.name = form.name.data
        contact.email = form.email.data
        contact.subject = form.subject.data
        contact.message = form.message.data
        contact.postage_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')

        message_tpl = render_template('contact/message_template.html',
                                      contact=contact)

        db.session.add(contact)
        db.session.commit()
        send_mail("Mensagem recebida via página de Contato",
                  ["*****@*****.**"], message_tpl)

        message = gettext(
            "Your message has been sent successfully. We will soon get back to you."
        )

        return Response(message, status=200, mimetype='application/json')
コード例 #3
0
ファイル: views.py プロジェクト: MHordecki/poznanopen
def registration(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            model = Form()
            model.fullname = data['fullname']
            model.wcaid = data['wcaid']
            model.country = data['country']
            model.city = data['city']
            model.email = data['email']
            model.tshirt = data['tshirt']
            model.nick = data['nick']
            model.accomodation = data['accomodation']
            model.born = datetime.date(int(data['bornyear']), int(data['bornmonth']), int(data['bornday']))
            model.events = [str(ev) for ev in data if ev.startswith('ev_') and data[ev] == True]
            model.status = 1
            model.put()

            return HttpResponseRedirect('/thanks')
    else:
        form = RegistrationForm()

    return render_to_response('registration.html', {
        'form': form,
        'page': 'registration',
        'years': range(1900, 2009),
        'months': range(1, 13),
        'days': range(1, 32),
        })
コード例 #4
0
def create():
    form = ContactForm()
    if form.validate() is False:
        for error_type in form.errors:
            if form.errors[error_type][0] in dictionary():
                form.errors[error_type][0] = dictionary()[
                    form.errors[error_type][0]]
        return render_template('contact/index.html',
                               form=form,
                               action=url_for('contact.create'))
    else:
        contact = Form()
        contact.name = form.name.data
        contact.email = form.email.data
        contact.subject = form.subject.data
        contact.message = form.message.data
        contact.postage_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')

        message_tpl = render_template('contact/message_template.html',
                                      contact=contact)

        db.session.add(contact)
        db.session.commit()
        send_mail("Contato - DataViva", [admin_email], message_tpl)

        message = gettext(
            "Your message has been sent successfully. We will soon get back to you."
        )
        flash(message, 'success')

        return redirect(url_for('contact.create'))
コード例 #5
0
ファイル: views.py プロジェクト: jaotta/dataviva-site
def create():
    form = ContactForm()
    if form.validate() is False:
        return Response(status=400, mimetype='application/json')
    else:
        contact = Form()
        contact.name = form.name.data
        contact.email = form.email.data
        contact.subject = form.subject.data
        contact.message = form.message.data
        contact.postage_date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')

        message_tpl = render_template(
            'contact/message_template.html', contact=contact)

        db.session.add(contact)
        db.session.commit()
        send_mail("Mensagem recebida via página de Contato",
                  ["*****@*****.**"], message_tpl)

        message = gettext(
            "Your message has been sent successfully. We will soon get back to you.")

        return Response(message, status=200, mimetype='application/json')