示例#1
0
def _send_message():
    contact_form = ContactForm()
    contact_form.setup()

    if contact_form.validate_on_submit():
        current_app.logger.info('send_message: %s, %s, %s, %s',
                                contact_form.contact_name.data,
                                contact_form.contact_email.data,
                                contact_form.contact_reasons.data,
                                contact_form.contact_message.data)
        try:
            resp = api_client.send_message(
                name=contact_form.contact_name.data,
                email=contact_form.contact_email.data,
                reason=contact_form.contact_reasons.data,
                message=contact_form.contact_message.data)
            if 'error' in session:
                error = session.pop('error')
                current_app.logger.error(error)
                tz = pytz.timezone("Europe/London")
                return jsonify({
                    'error':
                    'Problem sending message at {}, please try again later'.
                    format(datetime.now(tz).strftime('%H:%M:%S %d/%m/%y'))
                })
            else:
                return jsonify(resp)
        except HTTPError as e:
            return jsonify({'error': e.message})
    return jsonify({'errors': contact_form.errors})
def contact():

    form = ContactForm()

    if form.validate_on_submit():

        email_addr = form.email.data
        comment = form.comment.data
        name = form.name.data

        body_message = '''
        From: {} at {}, \n
        Comment: {}
        '''.format(name, email_addr, comment)

        msg = Message(subject="[NIP app] Contact Request",
                      body=body_message,
                      sender=app.config['ADMIN_EMAIL'],
                      recipients=app.config['ADMIN_RECIPIENTS'])

        thd = Thread(target=send_async_email, args=[app, msg])
        thd.start()

        flash("Thanks for your interest!".format(name))

        return redirect(url_for('main.contact'))

    return render_template('contact.html',
                           title="Contact Us",
                           main_header="Contact Us",
                           form=form)
示例#3
0
def index():
    form = ContactForm()
    if form.validate_on_submit():
        contact = Contact(name=form.name.data,
                          phone_no=form.phone_no.data,
                          email=form.email.data,
                          user_id=current_user.id)
        db.session.add(contact)
        db.session.commit()
        flash(_('Contact added sucessfully!'))
        return redirect(url_for('main.index'))
    return render_template('index.html', title=_('Home'), form=form)
示例#4
0
def contact():
    form = ContactForm()
    if form.validate_on_submit():
        cont = Contact(name=form.name.data, email=form.email.data, message=form.message.data)
        db.session.add(cont)
        db.session.commit()
        if send_contact_email(cont):
            flash('Message has been sent!')
        else:
            flash('Sorry system error')
        return redirect(url_for('main.index'))
    return render_template('main/contact.html', form=form)
示例#5
0
def index():
    form = ContactForm()
    if form.validate_on_submit():
        from_name = form.name.data
        email = form.email.data
        message_body = form.message.data
        phone = form.phone.data
        contact_me_email(from_name=from_name,
                         email=email,
                         message_body=message_body,
                         phone=phone)
        flash("Thanks for your email, I'll get back to you as soon as I can!")
    return render_template('index.html', form=form)
示例#6
0
def contact():
    form = ContactForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            send_email(subject=form.subject.data, sender=current_app.config['ADMINS'][0],
                       recipients=[current_app.config['ADMINS'][0]],
                       text_body=render_template('email/contact.txt', form=form),
                       html_body=render_template('email/contact.html', form=form))
            return render_template('contact.html', success=True)
        else:
            flash('All fields are required.')
            return render_template('contact.html', form=form)
    elif request.method == 'GET':
        return render_template('contact.html', form=form)
示例#7
0
文件: routes.py 项目: GaRi-MAK/WEB_EA
def edit_contacts_id(data_id):
    form = ContactForm()
    form.region.choices = [(s.id, s.region) for s in db.session.query(Region).all()]
    form.country.choices = [(s.id, s.country) for s in db.session.query(Country).all()]
    contact = Contact.query.filter_by(id=data_id).first()
    if form.validate_on_submit():
        filename = secure_filename(form.flag.data.filename)
        form.flag.data.save('/WEB_EA/app/static/img/' + filename)
        contact.region_id = form.region.data
        contact.country_id = form.country.data
        contact.phone = form.phone.data
        contact.email = form.email.data
        contact.flag = filename
        db.session.commit()
        flash(_('Updated'))
        return redirect(url_for('main.edit_contacts'))
    return render_template('edit_database/EditContacts.html', form=form, contact=contact, update=True)
示例#8
0
def contact():
    contact_html = db.session.query(Content).join(Page).filter(
        Page.name == 'contact', Content.name == 'content1').first()
    form = ContactForm()
    if form.validate_on_submit():
        contact = Contact(name=form.name.data, email=form.email.data, \
                        message=form.message.data)
        db.session.add(contact)
        db.session.commit()
        if send_contact_email(contact):
            flash('Message has been sent!', 'success')
        else:
            flash('Sorry system error', 'danger')
        return redirect(url_for('main.index'))
    return render_template('main/contact.html',
                           form=form,
                           contact_html=contact_html)
示例#9
0
文件: views.py 项目: revmic/rockyart
def contact():
    form = ContactForm()

    if form.validate_on_submit():
        try:
            mailer.send_email("Customer Inquiry", "inquiry")
        except Exception as e:
            flash("Something went wrong while sending your message. "
                  "Please email [email protected] with your question. "
                  "And if you're feeling generous with your time, "
                  "send [email protected] a message about this error. "
                  "Sorry about this!", "danger")
            print(e)
        else:
            flash("Your message was sent successfully. "
                  "I'll get back to you soon!", "success")
        return redirect(url_for('main.contact'))

    return render_template("contact.html", title='Contact', form=form)
示例#10
0
def project(project_id):

    form = ContactForm()

    if form.validate_on_submit():
        new_contact = Contact(project_id=project_id,
                              name=form.name.data,
                              link=form.link.data,
                              notes=form.notes.data,
                              in_contact=bool(form.in_contact.data),
                              active=bool(0))
        db_session.add(new_contact)
        db_session.commit()
        return redirect(url_for('main.project', project_id=project_id))

    contact_id = request.form.get('id')

    if request.form.get('update'):
        contact = db_session.query(Contact).get(contact_id)
        today = date.today()
        contact.checked = today
        db_session.commit()
    if request.form.get('edit'):
        return redirect(
            url_for('main.edit_contact',
                    contact_id=contact_id,
                    project_id=project_id))

    queued_contacts = (db_session.query(Contact).filter(
        Contact.project_id == project_id).filter(
            Contact.in_contact == 'false').all())
    current_contacts = (db_session.query(Contact).filter(
        Contact.project_id == project_id).filter(
            Contact.in_contact == 'true').all())
    project = (db_session.query(Project).filter(
        Project.project_id == project_id).first())
    return render_template('project.html',
                           queued_contacts=queued_contacts,
                           current_contacts=current_contacts,
                           project=project,
                           form=form)
示例#11
0
def contact():
    form = ContactForm()

    if request.method == 'POST':
        if form.validate_on_submit():

            data = {
                'name': form.name.data,
                'phone': form.phone.data,
                'email': form.email.data.strip(),
                'message': form.message.data
            }

            send_awsses_mail(
                subject='Formular de contact',
                text_body=f'{form.name.data} says {form.message.data}',
                html_body=render_template('flask-mail.html', data=data))

            flash(f'You sent the message successfully', 'success')
            return redirect(url_for('main.contact'))

    return render_template('contact.html', title='Contacteaza-ne', form=form)
示例#12
0
def edit_contact(project_id, contact_id):

    contact_obj = db_session.query(Contact).get(contact_id)

    form = ContactForm(obj=contact_obj)

    if form.validate_on_submit():
        form.populate_obj(contact_obj)
        contact_obj.name = form.name.data
        contact_obj.link = form.link.data
        contact_obj.notes = form.notes.data
        db_session.commit()
        return redirect(
            url_for('main.project',
                    project_id=project_id,
                    contact_id=contact_id))
    if request.form.get('delete'):
        db_session.query(Contact).filter(
            Contact.contact_id == contact_id).delete()
        db_session.commit()
        return redirect(url_for('main.project', project_id=project_id))

    return render_template('edit_contact.html', form=form)
示例#13
0
def contact():
    form = ContactForm()

    # update last seen
    if current_user.is_authenticated:
        current_user.update_last_seen()

    if request.method == 'POST' and form.validate_on_submit():
        # Erstellen eines Contact Dokument
        Contact(firstname=request.form['firstname'],
                lastname=request.form['lastname'],
                telephone=request.form['telephone'],
                message=request.form['message'],
                email=request.form['email']).save()

        # save in log
        user = User.objects.get(email=current_user.email)
        Log(user=user,
            category='contact',
            text='Hat eine Kontaktanfrage gesendet.').save()

        flash('Ihre Nachricht wurde erfolgreich übermittelt.')
    return render_template('main/contact.html', form=form)
示例#14
0
文件: routes.py 项目: GaRi-MAK/WEB_EA
def edit_contacts():
    form = ContactForm()
    form.region.choices = [(s.id, s.region) for s in db.session.query(Region).all()]
    form.country.choices = [(s.id, s.country) for s in db.session.query(Country).all()]
    contacts = Contact.query.all()
    if form.validate_on_submit():
        filename = secure_filename(form.flag.data.filename)
        form.flag.data.save('/WEB_EA/app/static/img/' + filename)
        contact = Contact(region_id=form.region.data, country_id=form.country.data, phone=form.phone.data,
                          email=form.email.data, flag=filename)
        db.session.add(contact)
        db.session.commit()
        flash(_('Added'))
        return redirect(url_for('main.edit_contacts'))
    if request.method == 'POST':
        del_form = request.form
        for ID in del_form.to_dict():
            record_id = ID
        del_contact = Contact.query.filter_by(id=record_id).first()
        db.session.delete(del_contact)
        db.session.commit()
        flash(_('Deleted'))
        return redirect(url_for('main.edit_contacts'))
    return render_template('edit_database/EditContacts.html', form=form, contacts=contacts)
示例#15
0
def index():
    form = ContactForm()
    if form.validate_on_submit():
        return redirect(url_for('main.index'))
    return render_template('home.html', form=form)
示例#16
0
def index():
    firstpage, = WebsiteFirstpage.search([], limit=1,
        order=[('date','DESC'),
        ('id','DESC')])
    courses = WebsiteCourseFirstPage.search([
        ('active','=',True)
        ],
        order=[('date','DESC'),
        ('id','DESC')])
    students = Subscription.search([])
    number_of_students = int(len(students)) + 1618
    form = ContactForm()
    if form.validate_on_submit():

        firstname = form.firstname.data
        email = form.email.data
        phone = form.phone.data
        city = form.city.data
        method = dict(form.method.choices).get(form.method.data)
        today = date.today()

        url = "https://app.verify-email.org/api/v1/BHCgLkl5zWE5txaMR2HJBg1OoJourpTumiNflw40wYQc4na0rw/verify/"#[email protected]"
        response = requests.get( url=url + email)
        response_content = response.json()

        if response_content['status'] == 1:
            party1, = Party.create([{
                'name': firstname,
                'is_student':False,
                'is_subscriber':False,
                }])

            ContactMechanism.create([{
                'party': party1.id,
                'type': 'email',
                'value': email,
                }])[0]
            if phone is not None:
                ContactMechanism.create([{
                    'party': party1.id,
                    'type': 'phone',
                    'value': phone,
                    }])[0]
            if city is not None:
                address1, = Address.create([{
                    'party': party1.id,
                    'city': city,
                    }])

            session['firstname'] = firstname

            curso = dict(form.course.choices).get(form.course.data)

            body = "Hemos recibido la siguiente informacion (IND): " + " \n " + \
                "Nombre: "+ firstname + "\n Email: "+ email + " \n Telefono: " + phone + \
                " \n  Ciudad: " + city + " \n  Curso: " + curso + \
                "\n Forma de contacto: " + method

            msg = Message('Contacto APIXela: '+\
                firstname, sender = '*****@*****.**', \
                recipients = [email, '*****@*****.**'])
            msg.body = "Contacto Fb Ads :: " + body
            mail.send(msg)

            params = {}
            params['api_key'] = current_app.config['NEWSLETTER_API']
            params['list'] = current_app.config['NEWSLETTER_LIST']
            params['boolean'] = 'true'
            params['name'] = firstname
            params['email'] = email
            headers  = {'Content-type':'application/x-www-form-urlencoded',
            'charset':'UTF-8'}
            try:
                subscribe_url = current_app.config['NEWSLETTER_URL']
                subscribe_response = requests.post( url=subscribe_url,
                    data=params, headers=headers)
            except Exception:
                pass

            return redirect(url_for('main.welcome'))
        else:
            flash('Tu correo no es válido o está inactivo, intenta de nuevo')
    if current_user.is_authenticated:
        user = User(current_user)
        return render_template('index.html',user=user,
            form=form, firstpage=firstpage, courses=courses,
            number_of_students=number_of_students)
    return render_template('index.html', form=form,
        firstpage=firstpage, courses=courses,
        number_of_students=number_of_students)
示例#17
0
def contact():

    form = ContactForm()
    if form.validate_on_submit():

        firstname = form.firstname.data
        email = form.email.data
        phone = form.phone.data
        city = form.city.data
        today = date.today()
        method = dict(form.method.choices).get(form.method.data)

        party1, = Party.create([{
            'name': firstname,
            'is_student':False,
            'is_subscriber':False,
            }])

        ContactMechanism.create([{
            'party': party1.id,
            'type': 'email',
            'value': email,
            }])[0]
        ContactMechanism.create([{
            'party': party1.id,
            'type': 'phone',
            'value': phone,
            }])[0]
        address1, = Address.create([{
            'party': party1.id,
            'city': city,
            }])

        session['firstname'] = firstname

        curso = dict(form.course.choices).get(form.course.data)
        body = "Hemos recibido la siguiente informacion: " + " \n " + \
            "Nombre: "+ firstname + "\n Email: "+ email + " \n Telefono: " + phone + \
            " \n  Ciudad: " + city + " \n  Curso: " + curso + \
            "\n Forma de contacto: " + method

        msg = Message('Contacto APIXela: '+firstname, sender = '*****@*****.**', recipients = [email, '*****@*****.**'])
        msg.body = "Contacto Fb Ads " + body
        mail.send(msg)

        params = {}
        params['api_key'] = current_app.config['NEWSLETTER_API']
        params['list'] = current_app.config['NEWSLETTER_LIST']
        params['boolean'] = 'true'
        params['name'] = firstname
        params['email'] = email
        headers  = {'Content-type':'application/x-www-form-urlencoded',
        'charset':'UTF-8'}

        try:
            subscribe_url = current_app.config['NEWSLETTER_URL']
            subscribe_response = requests.post( url=subscribe_url,
                data=params, headers=headers)
        except Exception:
            pass

        return redirect(url_for('main.welcome'))
    if current_user.is_authenticated:
        user = User(current_user)
        return render_template('contacto.html', user=user,
            form=form)
    return render_template('contacto.html', form=form,)
示例#18
0
def tours():
    form = ContactForm()
    if form.validate_on_submit():
        return redirect(url_for('main.tours'))
    return render_template('tours.html', form=form)