Ejemplo n.º 1
0
def email_share_ajax():

    if not request.is_xhr:
        abort(400, _('Requisição inválida.'))

    form = forms.EmailShareForm(request.form)

    if form.validate():
        recipients = [
            email.strip() for email in form.data['recipients'].split(';')
            if email.strip() != ''
        ]

        sent, message = controllers.send_email_share(form.data['your_email'],
                                                     recipients,
                                                     form.data['share_url'],
                                                     form.data['subject'],
                                                     form.data['comment'])

        return jsonify({
            'sent': sent,
            'message': str(message),
            'fields': [key for key in form.data.keys()]
        })

    else:
        return jsonify({
            'sent': False,
            'message': form.errors,
            'fields': [key for key in form.data.keys()]
        })
Ejemplo n.º 2
0
def add_forms_to_g():
    setattr(g, 'email_share', forms.EmailShareForm())
    setattr(g, 'email_contact', forms.ContactForm())
    setattr(g, 'error', forms.ErrorForm())