Beispiel #1
0
 def test_duplicate_emails(self):
     # Ensure emails are unique.
     email = Email('*****@*****.**')
     db.session.add(email)
     db.session.commit()
     with self.client:
         response = self.client.post('/',
                                     data=dict(email="*****@*****.**"),
                                     follow_redirects=True)
         self.assertIn('Sorry that email aleady exists!', response.data)
         self.assertTrue(response.status_code == 200)
Beispiel #2
0
def index():
    """Landing page for users to enter emails."""
    form = SignUpForm(request.form)
    if form.validate_on_submit():
        test = Email.query.filter_by(email=form.email.data).first()
        if test:
            flash('Sorry that email aleady exists!', 'danger')
        else:
            email = Email(email=form.email.data)
            db.session.add(email)
            db.session.commit()
            flash('Thank you for your interest!', 'success')
            return redirect(url_for('main.index'))
    return render_template('main/index.html', form=form)
Beispiel #3
0
def create_data():
    """Adds data to the email model."""
    db.session.add(Email(email="*****@*****.**"))
    db.session.add(Email(email="*****@*****.**"))
    db.session.add(Email(email="*****@*****.**"))
    db.session.commit()