diff --git a/instance/app.db b/instance/app.db index d771342ac6b6e07297493465b5bb529af221d1d2..a0bb521094a60d9b0848c589b5ab2a3ab07a2448 100644 Binary files a/instance/app.db and b/instance/app.db differ diff --git a/run.py b/run.py index 9d9183a319b6146e68e15266a78d037631e6e491..d54c4934b770bb88e448752993837c2953cc801d 100644 --- a/run.py +++ b/run.py @@ -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: diff --git a/shop/databases.py b/shop/databases.py index 3120cf2fbee9ece0666ddf325d784794da49b826..b20938fa83e20e58ca9e174cabfd01c7c55a7d6c 100644 --- a/shop/databases.py +++ b/shop/databases.py @@ -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) diff --git a/shop/forms.py b/shop/forms.py index 6a7911ff3dcea5b9ea53a66f706b4ba440b0f6aa..30d004473936fa9bbffc054e73c70269fdbfebed 100644 --- a/shop/forms.py +++ b/shop/forms.py @@ -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): diff --git a/shop/routes.py b/shop/routes.py index e8358de97b314a2c223075fcede31e51ba34cc27..9818a25cc02d1ff197e5ea8d2dc3c059649bfc61 100644 --- a/shop/routes.py +++ b/shop/routes.py @@ -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) diff --git a/shop/static/styles.css b/shop/static/styles.css index 6b0344a2c70a63839828990a68307c9812464ef4..33485ca56495999fc8d53dff27d68d5f094986f0 100644 --- a/shop/static/styles.css +++ b/shop/static/styles.css @@ -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 diff --git a/shop/templates/layout.html b/shop/templates/layout.html index 49f2cff7da53a79f733f031f5c341a961ec48124..01e9f1e04b2d7160c6407b0c75e235e0e4f6edb0 100644 --- a/shop/templates/layout.html +++ b/shop/templates/layout.html @@ -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 %} diff --git a/shop/templates/signup.html b/shop/templates/signup.html index 06bcdae68c265d7db3d86ce12f2875463e31e93f..64f88063bee7d6528aa644151b7543e5bca38417 100644 --- a/shop/templates/signup.html +++ b/shop/templates/signup.html @@ -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> diff --git a/shop/templates/user_page.html b/shop/templates/user_page.html index d0e2402f7254076ee663da80120859668e1d00e6..f61a83d4b153820ee978f102110c155163a19901 100644 --- a/shop/templates/user_page.html +++ b/shop/templates/user_page.html @@ -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>