Skip to content
Snippets Groups Projects
Commit 5fff3957 authored by Michael Drury's avatar Michael Drury
Browse files

adding email and mobile to the users

parent ae377312
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -7,11 +7,11 @@ if __name__ == '__main__':
with app.app_context():
db.create_all()
if User.query.filter_by(username='michael').first() is None:
User.register('michael', 'michael1')
User.register('michael', 'michael1', 'mpdrury15@gmail.com', '07874810762')
if User.query.filter_by(username='connor').first() is None:
User.register('connor', 'connor1')
User.register('connor', 'connor1', 'connor@gmail.com', '07700900606')
if User.query.filter_by(username='alex').first() is None:
User.register('alex', 'alex1')
User.register('alex', 'alex1', 'alex@gmail.com', '07700900328')
if product_table.query.filter_by(product_name = 'Fox 36').first() is None:
product_table.new_product('Fox 36', 1139.00, 0.7, 'fox36.jpg', 'fox', 'fork', 'A high-performance mountain bike suspension fork with 36mm stanchions')
if product_table.query.filter_by(product_name = 'Rockshox Pike').first() is None:
......
......@@ -11,6 +11,8 @@ class User(UserMixin, db.Model):
password_hash = db.Column(db.String(64))
cart = db.Column(db.String)
wishlist = db.Column(db.String)
email = db.Column(db.String)
mobile = db.Column(db.String)
def set_password(self, password):
self.password_hash = generate_password_hash(password)
......@@ -24,10 +26,18 @@ class User(UserMixin, db.Model):
def new_wishlist(self):
self.wishlist = ''
def set_mobile(self, mobile):
self.mobile = mobile
def set_email(self, email):
self.email = email
@staticmethod
def register(username, password):
def register(username, password, email, mobile):
user = User(username=username)
user.set_password(password)
user.set_mobile(mobile)
user.set_email(email)
user.new_cart()
user.new_wishlist()
db.session.add(user)
......
......@@ -13,6 +13,8 @@ class SignupForm(FlaskForm):
username = StringField('Username', validators=[input_required(), Length(1, 16)])
password = PasswordField('Password', validators=[input_required()])
verifyPassword = PasswordField('Verify password', validators=[input_required(), EqualTo('password', message='Passwords must match')])
email = StringField('email', validators=[input_required(), Length(1, 16)])
mobile = StringField('mobile', validators=[input_required(), Length(11, 11)])
submit = SubmitField('Submit')
class orderByForm(FlaskForm):
......
......@@ -36,8 +36,10 @@ def signup():
if form.validate_on_submit():
password_in = str(form.password.data)
username_in = str(form.username.data)
email_in = str(form.email.data)
mobile_in = str(form.mobile.data)
if User.query.filter_by(username=username_in).first() is None:
User.register(username_in, password_in)
User.register(username_in, password_in, email_in, mobile_in)
return redirect(url_for('login'))
return render_template('signup.html', form=form)
......
......@@ -313,7 +313,7 @@ li {
.signin_box {
width: 50%;
border: 3px solid black;
transform: translate(50%, 30%);
transform: translate(50%, 10%);
}
.login_field {
......@@ -565,5 +565,5 @@ li {
.user_page_username {
text-align: center;
font-family: Andale Mono, monospace;
font-size: 400%;
font-size: 300%;
}
\ No newline at end of file
......@@ -44,7 +44,7 @@
<li><div class = "navbar_box"><a class = "navbar_item" href="{{ url_for('cart') }}">Cart</a></div></li>
<li><div class = "navbar_box"><a class = "navbar_item" href="{{ url_for('wishlist') }}">Wishlist</a></div></li>
{% if current_user.is_authenticated %}
<li class = "navbar_far_right"><div class = "navbar_box"><a class="navbar_item" href="{{ url_for('user_page') }}">{{current_user.username.upper()}} <img class = "avatar_img" src = "{{ url_for('static', filename='images/Logged_in.png') }}" alt="logged_in_avatar"></a></div></li>
<li class = "navbar_far_right"><div class = "navbar_box"><a class="navbar_item" href="{{ url_for('user_page') }}">{{current_user.username.upper()}}</a></div></li>
<li class = "navbar_right"><div class = "navbar_box"><a class="navbar_item" href="{{ url_for('logout') }}">Logout</a></div></li>
{% else %}
......
......@@ -11,6 +11,12 @@
<p class="login_field">
{{ form.username.label }} {{ form.username(class = "input_field") }}
</p>
<p class="login_field">
{{ form.email.label }} {{ form.email(class = "input_field") }}
</p>
<p class="login_field">
{{ form.mobile.label }} {{ form.mobile(class = "input_field") }}
</p>
<p class="login_field">
{{ form.password.label }} {{ form.password(class = "input_field") }}
</p>
......
......@@ -8,6 +8,8 @@
<h1 class = "home_title" >User Page</h1>
<h1 class = "user_page_username"> Current User: {{current_user.username}}</h1>
<h1 class = "user_page_username"> e-mail: {{current_user.email}}</h1>
<h1 class = "user_page_username"> mobile: {{current_user.mobile}}</h1>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment