From f3e60200f9169d002f45946fb2553cc60303bf0c Mon Sep 17 00:00:00 2001
From: pluja
Date: Mon, 24 Aug 2020 12:48:44 +0200
Subject: [PATCH] Remove email from register form
---
app/forms.py | 8 +-------
app/models.py | 4 +---
app/routes.py | 2 +-
app/templates/base.html | 2 +-
app/templates/register.html | 7 -------
5 files changed, 4 insertions(+), 19 deletions(-)
diff --git a/app/forms.py b/app/forms.py
index d920f4b..e41368d 100644
--- a/app/forms.py
+++ b/app/forms.py
@@ -1,6 +1,6 @@
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField
-from wtforms.validators import ValidationError, DataRequired, Email, EqualTo
+from wtforms.validators import ValidationError, DataRequired, EqualTo
from app.models import User
@@ -21,7 +21,6 @@ class ChannelForm(FlaskForm):
class RegistrationForm(FlaskForm):
username = StringField('Username', validators=[DataRequired()])
- email = StringField('Email', validators=[DataRequired(), Email()])
password = PasswordField('Password', validators=[DataRequired()])
password2 = PasswordField(
'Repeat Password', validators=[DataRequired(), EqualTo('password')])
@@ -32,10 +31,5 @@ class RegistrationForm(FlaskForm):
if user is not None:
raise ValidationError('Please use a different username.')
- def validate_email(self, email):
- user = User.query.filter_by(email=email.data).first()
- if user is not None:
- raise ValidationError('Please use a different email address.')
-
class EmptyForm(FlaskForm):
submit = SubmitField('Submit')
\ No newline at end of file
diff --git a/app/models.py b/app/models.py
index e765b9d..fc135a7 100644
--- a/app/models.py
+++ b/app/models.py
@@ -21,7 +21,6 @@ twitter_association = db.Table('twitter_association',
class User(UserMixin, db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(64), index=True, unique=True)
- email = db.Column(db.String(120), index=True, unique=True)
password_hash = db.Column(db.String(128))
posts = db.relationship('Post', backref='author', lazy='dynamic')
@@ -33,8 +32,7 @@ class User(UserMixin, db.Model):
def check_password(self, password):
return check_password_hash(self.password_hash, password)
-
- # TWITTER
+
def follow(self, user):
if not self.is_following(user):
self.followed.append(user)
diff --git a/app/routes.py b/app/routes.py
index 3e88b9b..559faec 100644
--- a/app/routes.py
+++ b/app/routes.py
@@ -435,7 +435,7 @@ def register():
if isTwitterUser(form.username.data):
flash('This is username is taken! Choose a different one.')
else:
- user = User(username=form.username.data, email=form.email.data)
+ user = User(username=form.username.data)
user.set_password(form.password.data)
db.session.add(user)
db.session.commit()
diff --git a/app/templates/base.html b/app/templates/base.html
index 6d4caf9..528c7f9 100644
--- a/app/templates/base.html
+++ b/app/templates/base.html
@@ -16,10 +16,10 @@
-
{% if current_user.is_anonymous %}
Login
{% else %}
+
Youtube
diff --git a/app/templates/register.html b/app/templates/register.html
index 25d4518..99212c8 100644
--- a/app/templates/register.html
+++ b/app/templates/register.html
@@ -12,13 +12,6 @@
[{{ error }}]
{% endfor %}
-
- {{ form.email.label }}
- {{ form.email(size=64) }}
- {% for error in form.email.errors %}
- [{{ error }}]
- {% endfor %}
-
{{ form.password.label }}
{{ form.password(size=32) }}