Ejemplo n.º 1
0
def edit(contact_id=None):
    """Create or edit a contact, frontend."""
    if not ModuleAPI.can_read('contact'):
        return abort(403)

    if contact_id:
        contact = Contact.query.get(contact_id)
    else:
        contact = Contact()

    form = ContactForm(request.form, contact)

    locations = Location.query.order_by('address').order_by('city')
    form.location_id.choices = \
        [(l.id, '%s, %s' % (l.address, l.city)) for l in locations]

    if form.validate_on_submit():
        if not contact.id and Contact.query.filter(
                Contact.email == form.email.data).count():
            flash(_('Contact email "%s" is already in use.' %
                    form.email.data), 'danger')
            return render_template('contact/edit.htm', contact=contact,
                                   form=form)
        form.populate_obj(contact)
        db.session.add(contact)
        db.session.commit()
        flash(_('Contact person saved.'), 'success')
        return redirect(url_for('contact.edit', contact_id=contact.id))
    else:
        flash_form_errors(form)

    return render_template('contact/edit.htm', contact=contact, form=form)
Ejemplo n.º 2
0
    def contact(self):
        form = ContactForm()
        if form.validate_on_submit():
            try:
                template = """
                              This is a contact form submission from Guildbit.com/contact \n
                              Email: %s \n
                              Comment/Question: %s \n
                           """ % (form.email.data, form.message.data)

                msg = Message(
                    form.subject.data,
                    sender=settings.DEFAULT_MAIL_SENDER,
                    recipients=settings.EMAIL_RECIPIENTS)

                msg.body = template
                mail.send(msg)
            except:
                import traceback

                traceback.print_exc()
                flash("Something went wrong!")
                return redirect('/contact')

            return render_template('contact_thankyou.html')
        return render_template('contact.html', form=form)
Ejemplo n.º 3
0
def contact():
    form = ContactForm()
    if form.validate_on_submit():
        send_contact_form_email(form.username.data, form.email.data,
                                form.text.data)
        flash('Your message sended. Wait for an answer!')
        return redirect(url_for('index'))
    return render_template('contact.html', form=form)
Ejemplo n.º 4
0
def contact():
    form = ContactForm()
    cookie_name = session.get("name")
    cookie_email = session.get("email")
    print(cookie_email, cookie_name)
    if request.method == 'POST':
        if cookie_name is None and cookie_email is None:  # якщо кукі не встановлено, тобто ми перший раз відкрили сторінку
            if form.validate_on_submit():
                name = form.name.data
                email = form.email.data
                body = form.body.data
                session['name'] = name
                session['email'] = email
                with open('data.json', 'a') as outfile:
                    json_string = json.dumps({
                        'name': session.get("name"),
                        'email': session.get("email"),
                        'body': body
                    })
                    json.dump(json_string, outfile)
                    outfile.write('\n')
                flash(message='Повідомлення надіслано успішно!')
                return redirect(url_for('contact_form_bp_in.contact'))
            else:
                flash(message='Помилка відправки повідомлення!')
        else:  # якщо вхід на сторіку здійснено повторно
            form.name.data = cookie_name  # встановлюємо значення для форми name та email
            form.email.data = cookie_email
            if form.validate_on_submit():
                body = form.body.data
                with open('data.json', 'a') as outfile:
                    json.dump(
                        {
                            'name': session.get("name"),
                            'email': session.get("email"),
                            'body': body
                        }, outfile)
                    outfile.write('\n')
                flash(message='Повідомлення надіслано успішно!')
                return redirect(url_for('contact_form_bp_in.contact'))
            else:
                flash(message='Помилка відправки повідомлення!')
    return render_template('contact_form.html',
                           form=form,
                           cookie_name=session.get("name"),
                           cookie_email=session.get("email"))
Ejemplo n.º 5
0
def contact():
    form = ContactForm()
    if form.validate_on_submit():
        email = form.email.data
        message = form.message.data
        send_email_to_admin(email,message)
        flash('Your email has been sent!','info')
    return render_template('contact.html',title='Contact us', form = form)
Ejemplo n.º 6
0
def contact():
    form = ContactForm()
    if form.validate_on_submit():
        msg = Message("Hey bro", sender=(request.form['name'], request.form['email']),recipients=[request.form['subject']]) 
        msg.body = request.form['message']
        mail.send(msg)
        return redirect('/home')
    return render_template('contact.html', form=form)
Ejemplo n.º 7
0
def index():
    admin = db.session.query(Administrator).count()
    track = db.session.query(Active).get(1)
    posts = db.session.query(Post).order_by(Post.id.desc()).limit(4)
    shows = Show.query.filter(Show.timestamp >= date.today()).order_by(
        Show.timestamp.desc()).limit(4)
    photos = db.session.query(Photo).order_by(Photo.timestamp.desc()).limit(4)
    form = ContactForm()
    rsvp = RSVPForm()

    if admin == 0:
        return redirect(url_for('admin_welcome'))

    admin_settings = db.session.query(Administrator).get(1)

    if form.validate_on_submit():
        contact = Contact()
        contact.name = form.name.data
        contact.email = form.email.data
        contact.phone = form.phone.data
        contact.subject = form.subject.data
        contact.message = form.message.data

        db.session.add(contact)
        db.session.commit()

        message = Markup(
            '<div class="alert alert-success alert-dismissible"><button type="button" class="close" data-dismiss="alert">&times;</button> Thank you! Jubuc will be in touch with you shortly.</div>'
        )
        flash(message, category='info')
        return redirect(url_for('index'))

    if rsvp.validate_on_submit():
        attendee = RSVP()
        attendee.name = rsvp.name.data
        attendee.phone = rsvp.phone.data
        attendee.email = rsvp.email.data
        attendee.request = rsvp.request.data
        attendee.shows.append(
            db.session.query(Show).filter_by(id=rsvp.show.data).first())

        db.session.add(attendee)
        db.session.commit()

        message = Markup(
            '<div class="alert alert-success alert-dismissible"><button type="button" class="close" data-dismiss="alert">&times;</button> Thank you for RSVPing. See you at the show!</div>'
        )
        flash(message, category='info')
        return redirect(url_for('index'))

    return render_template('index.html',
                           form=form,
                           track=track,
                           posts=posts,
                           shows=shows,
                           photos=photos,
                           admin_settings=admin_settings,
                           rsvp=rsvp)
Ejemplo n.º 8
0
def contact():
    form=ContactForm()
    if form.validate_on_submit():
        msg = Message(request.form['subject'], sender=(request.form['name'],request.form['email']),recipients=["*****@*****.**"])
        msg.body = request.form['message']
        mail.send(msg)
        flash('Message sent')
        return redirect(url_for('home'))
    return render_template('contact.html', form=form)
Ejemplo n.º 9
0
def contact_us():
    form_params = request.form.to_dict(flat=True)
    form = ContactForm()
    if form.validate_on_submit():
        result = send_contact_message(form_params)
        print(result)
        flash('Thank you, your message has been sent.')
        return redirect(url_for('contact_us'))
    return render_template("contact_us.html", form=form)
Ejemplo n.º 10
0
def contact():
    form = ContactForm()

    if form.validate_on_submit():
        flash(f'Thanks {form.name.data}, your message has been received. We have sent a copy of the submission to {form.email.data}. Message: {form.message.data}')

        return redirect(url_for('index'))

    return render_template('form.html', form=form, title='Contact Us')
Ejemplo n.º 11
0
def contact():
    form = ContactForm()
    if form.validate_on_submit():
        p = Contact(title=form.type.data, body=form.body.data)
        db.session.add(p)
        db.session.commit()
        return redirect('/contact')
    contact = Contact.query.all()
    return render_template('contact.html', form=form, contact=contact)
Ejemplo n.º 12
0
def contactme():
    form = ContactForm()
    if form.validate_on_submit():
        flash("Ваше сообщение успешно отправлено!")
        return redirect(url_for('contactme'))

    return render_template('contacts.html',
                           title='Связаться со мной',
                           form=form)
Ejemplo n.º 13
0
def contact(): #Send email through contact page. Config in config.py
    form = ContactForm()
    if form.validate_on_submit():
        html_body = '<p>' + form.message.data + '</p>'
        send_email(form.subject.data, form.email.data, app.config['ADMINS'],
            form.message.data, html_body)
        flash('Your message has been sent.')
        return redirect(url_for('index'))
    return render_template('contact.html', title='Contact', form=form)
Ejemplo n.º 14
0
def contact():
    """Render the website's contact page."""
    form = ContactForm()
    if form.validate_on_submit():
        msg = Message(subject=request.form['subject'], sender = request.form['name'], recipients = ['*****@*****.**'])
        msg.body = request.form['textarea']
        mail.send(msg)
        flash('Your email was successfully sent from' + request.form['email'])
        return redirect('/')
    return render_template('contact.html', form = form)
Ejemplo n.º 15
0
def contact():
    form = ContactForm()
    if form.validate_on_submit():
        msg = Message(request.form['subject'],
                      sender=(request.form['name'], request.form['email']),
                      recipients=['*****@*****.**'])
        msg.body = request.form['message']
        mail.send(msg)
        flash('Your Message Was Sent!')
        return redirect('/')
    return render_template("contact.html", form=form)
Ejemplo n.º 16
0
def contact():
    form = ContactForm()
    if form.validate_on_submit():
      send_email('NM Trip - Feedback', sender='{}'.format(form.email.data),
      recipient='*****@*****.**', text_body="""
      From: {} <{}>
      {}
      """.format(form.name.data, form.email.data, form.text.data))
      flash('Thank you for your input, {}!'.format(form.name.data))
      return redirect(url_for('contact'))
    return render_template('contact.html', title='Contact', form=form)
Ejemplo n.º 17
0
def contact():
    form= ContactForm()
    if form.validate_on_submit():
        msg = Message(form.subject.data,
                      sender=(form.name.data , form.email.data),
                      recipients=["j.bravo@gmail"])
        msg.body = form.area.data
        mail.send(msg)
        flash(u'Message was successfully sent!')
        return redirect('/')
    return render_template('contact.html', form=form)
Ejemplo n.º 18
0
def contact():
    """Render the website's contact us page"""
    form = ContactForm()
    if form.validate_on_submit():
        msg = Message(request.form['subject'], sender=(request.form['name'], request.form['email']), \
            recipients=['*****@*****.**'])
        msg.body = request.form['message']
        mail.send(msg)
        flash('Message sent.')
        return redirect(url_for('home'))
    return render_template('contact.html', form=form)
Ejemplo n.º 19
0
def contact():
	form = ContactForm()
	news_form = Newsletter()
	if form.validate_on_submit():
		send('*****@*****.**', 'send', form=form)
		flash("Thank you! We'll get to you shortly.", "success")
		return redirect(url_for('index', _anchor='contact'))
	else:
		flash("Enter correct data.", 'danger')

	return render_template("metamova.html", form=form, news_form=news_form)
Ejemplo n.º 20
0
def contact():
    form = ContactForm()

    if form.validate_on_submit():
        msg = Message(form.subject.data, recipients=['*****@*****.**'])
        msg.body = f"""From: {form.name.data} <{form.email.data}>
                                        {form.message.data}"""
        mail.send(msg)
        return render_template('contact.html', success=True)

    return render_template('contact.html', form=form)
Ejemplo n.º 21
0
def contact():
    myform= ContactForm()
    if request.method == "POST":
        if myform.validate_on_submit():
            msg= Message("Your Subject", sender=("myform.name.data","myform.email.data"), recipients=["*****@*****.**"])
            msg.body= "The submitting of the form was successfully"
            mail.send(msg)
            flash('Form was submitted sucessfully')
            return redirect(url_for("home"))

    return render_template("contact.html", form=myform)
Ejemplo n.º 22
0
def contact():
    """Render the website's contact page."""
    form = ContactForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            msg = Message(request.form['subject'],sender=(request.form['name'],
            request.form['email']),recipients=['*****@*****.**'])
            msg.body = request.form['message']
            mail.send(msg)
            return redirect(url_for('home')),flash('Email sent Sucessfully','success')
    return render_template('contact.html',form=form)
Ejemplo n.º 23
0
def contact():
    form = ContactForm()
    if form.validate_on_submit():
        Msg = Message(request.form['subject'],
                      sender=(request.form['name'], request.form['email']),
                      recipients=['*****@*****.**'])
        Msg.body = request.form['message']
        mail.send(Msg)
        flash('Succesful! Message Sent.')
        return redirect(url_for('home'))
    return render_template("contact.html", form=form)
Ejemplo n.º 24
0
def contact():
    form = ContactForm()
    if form.validate_on_submit():
        msg = Message(request.form['subject'],
                      sender=(request.form['name'], request.form['email']),
                      recipients=[request.form['email']])
        msg.body = 'This is the body of the message'
        mail.send(msg)
        flash('You were successful!')
        return redirect(url_for('home'))
    return render_template('contact.html', form=form)
Ejemplo n.º 25
0
def contact():
    form = ContactForm()
    if form.validate_on_submit():
        msg = Message(form.subject.data,
                      sender=(form.username.data, form.email.data),
                      recipients=["*****@*****.**"])
        msg.body = form.message.data
        mail.send(msg)
        flash('Message Sent')
        return redirect(url_for('home'))
    return render_template('contact.html', form=form)
Ejemplo n.º 26
0
def contact():
    form = ContactForm()
    if form.validate_on_submit():
        msg = Message(request.form['subject'],
                      sender=(request.form['name'], request.form['email']),
                      recipients=['*****@*****.**'])
        msg.body = request.form['txt_area']
        mail.send(msg)
        flash('Message Sent!')
        return redirect(url_for('home'))
    return render_template('contact.html', form=form)
Ejemplo n.º 27
0
def index():
    """Render the index/home page."""
    form = ContactForm()
    if form.validate_on_submit():
        info = Contacts(Name=form.name.data,
                        Email=form.email.data,
                        Enquiry=form.enquiry.data)
        db.session.add(info)
        db.session.commit()
        flash('Enquiry submitted successfully!!!')
        return redirect(url_for('index'))
    return render_template('index.html', title='Home', form=form)
Ejemplo n.º 28
0
def contact():
    """Render the website's contact page."""
    form = ContactForm()
    if form.validate_on_submit():
        msg = Message(request.form['subject'],
                      sender=(request.form['name'], request.form['email']),
                      recipients=['*****@*****.**'])
        msg.body = request.form['message']
        mail.send(msg)
        flash('Message was sent successfully.')
        return redirect(url_for('home'))
    return render_template('contact.html', form=form)
Ejemplo n.º 29
0
def contact():
    form = ContactForm()
    if (request.method == 'POST') and (form.validate_on_submit()):
        msg = Message(request.form['subject'],
                      sender=(request.form['email']),
                      recipients=['*****@*****.**'])
        msg.body = request.form['message']
        mail.send(msg)
        flash(
            'Message sent successfully! We will get back to you within a day',
            'success')
    return render_template("contactform.html", form=form)
Ejemplo n.º 30
0
def contact():
    """Render the website's contact page"""
    form = ContactForm()
    if form.validate_on_submit():
        msg = Message(form.subject.data,
                      sender=(form.name.data , form.email.data),
                      recipients=["*****@*****.**"])
        msg.body = form.message.data
        mail.send(msg)
        flash(u'Message was successfully sent!')
        return redirect('/')
    return render_template('contact.html', form=form)
Ejemplo n.º 31
0
def contact():
    form = ContactForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            msg = Message(request.form['subject'],
                          sender=(request.form['name'], request.form['email']),
                          recipients=["*****@*****.**"])
            msg.body = request.form['message']
            mail.send(msg)
            flash('Your message was delivered successfully!')
            return redirect(url_for('home'))
    return render_template('contact.html', form=form)
Ejemplo n.º 32
0
def contact():
    """Render the website's contact page."""
    form = ContactForm()
    if form.validate_on_submit():
        msg = Message(form.subject.data,
                      sender=(form.name.data, form.email.data),
                      recipients=['*****@*****.**'])
        msg.body = form.message_body.data
        mail.send(msg)
        flash('The message was successfully sent to the site developer!')
        return redirect(url_for('home'))
    return render_template('contact.html', form=form)
Ejemplo n.º 33
0
def contact():
    name = None
    pages = Page.query.all()
    social_icons = SocialIcon.query.all()
    form = ContactForm()
    if form.validate_on_submit():
        name = form.name.data
        email = form.email.data
        message = form.message.data
        send_email(MAIL_USERNAME, 'Contact', 'mail/contact',
                   name=name, email=email, message=message)
        flash('Your message has been sent!')
        return redirect(url_for('contact'))
    return render_template('contact.html', 
                            form=form, 
                            pages=pages, 
                            social_icons=social_icons)
Ejemplo n.º 34
0
def contact():
    form = ContactForm()
    if form.validate_on_submit():
        # Yes, I know this really isn't secure at all, but whatever, for now.
        # Please don't hack my server and make me spend 20 minutes restoring from backup.
        # That would be irritating.
    	# name = form.name.data
    	# email = form.email.data
    	# phone = form.phone.data
    	# msg = MIMEText('Name: ' + name + '\nEmail: ' + email + '\nPhone: ' + phone + '\n\n' + form.body.data)

     #    msg["From"] = email
     #    msg["To"] = "*****@*****.**"
     #    msg["Subject"] = "NEW EMAIL FROM CHRISARCAND.COM"
     #    p = Popen(["/usr/sbin/sendmail", "-t"], stdin=PIPE)
     #    p.communicate(msg.as_string())

        return render_template("content/contact.html", submitted=True)
    return render_template("content/contact.html", form=form)