From 5fff395747bbbeed6aeca26ee698ea62c9c8ee92 Mon Sep 17 00:00:00 2001 From: Michael Drury <mpdrury15@gmail.com> Date: Thu, 4 May 2023 13:13:31 +0100 Subject: [PATCH] adding email and mobile to the users --- instance/app.db | Bin 20480 -> 20480 bytes run.py | 6 +++--- shop/databases.py | 12 +++++++++++- shop/forms.py | 2 ++ shop/routes.py | 4 +++- shop/static/styles.css | 4 ++-- shop/templates/layout.html | 2 +- shop/templates/signup.html | 6 ++++++ shop/templates/user_page.html | 2 ++ 9 files changed, 30 insertions(+), 8 deletions(-) diff --git a/instance/app.db b/instance/app.db index d771342ac6b6e07297493465b5bb529af221d1d2..a0bb521094a60d9b0848c589b5ab2a3ab07a2448 100644 GIT binary patch delta 529 zcmZY6y=zlZ7zXfj6G3lHa$+%r(2@oc5WmX#{@4srB8U`&Xw6d2IrrQen%krSYm+4n z4z4X1oV$vHNd62#oZP!Q>y*U=7s2V>p7;0goL&T{7s1&^0M9pDB?z|nHuC_0E4c-L zcMIS0A9IT@v-i1qHIFl4C%9TJmxFiNbQgXo`^5D6wHM7!>v6MlueKH@1KaES^lPD# zF5vZRZ2)_PABFb(MokxTvs^X=rP-@|{&qe6RIN;T_t<u6_vsVbdh4D|jv8^Su{D%4 z#;J*<BRp~lMT7`#Vvmi8xe?wu87nOn#mX?JIFa59jl7Ob-=93#U!k_$AVE?hq!FS- z&5D^2R93I=*WKXoa4;I$gY?$c`jozWwEO%d!7=R|jd63*a2{KRZR8_qP{btD5)<tS zms}aGrC^LY<`JgEMnZ9AiRFZ2#F%#8v%m5GD+Cg=n?VRRRtj2AdhWIH{q%FSG(B$a z?5Hs%51BRXgUPU=Vqunc>a@ioTGhqKDoi+%l#!S?s+PwhL>#h6#F}`itn~tEEf8VJ tFdDrXjWPe1p(I<zNI}+?>t^94fS2$m{0+doSo^h=0mbD?-{JY$oj)#WlhFVG delta 610 zcmcJLy=zlp6vp2hD`}xOuNkgU63Q)PaMJhtqu^o?O9~Ex)J$^j`$0m|+?p1ePH7!G zDFx@!(b4=H{R8?}h|XPl3*GGMna+85;5pCl<RUq_NWQg`?0ct|W$5MSPKpp(NjDIF z-}swer5nrUlb`F$n{`@SdzI8%tyc2&^|{19&VS=)tCt9$;jD34nL3RHK11{N=^$<H zjoc8zWWN~u$hHoKz@*w@id56>?d<T$M>^}9^24#-^Ige>4#F`;y(JM;5e0awBLk_a zhp1iPoRew~HZo(CFNo8Q2CEb($7%lMQ5|KcgGHLcB+MU7)nYPdZah2M9lZP0FQLmR z2=0j~3aUa--Unr*g#gY4PpOsESW_6oD<gwQnQ}o|Q3VoDyeST9b@aUIn!0j2EoXP3 zi+{QvZ|{mJ-wwjQRsG(Z{VtIX2ytMQ)exfcAejN<i7LQQCJO+qsdFH$=8A==O^`w| zr=kQU>|s(zcZAc22oL@n;$QhnzFNcA2>-#?%VvIsUp%cnMr)hx(P4g6&c?xS-hb3c LD!thrj_&VU|3<0I diff --git a/run.py b/run.py index 9d9183a..d54c493 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 3120cf2..b20938f 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 6a7911f..30d0044 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 e8358de..9818a25 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 6b0344a..33485ca 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 49f2cff..01e9f1e 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 06bcdae..64f8806 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 d0e2402..f61a83d 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> -- GitLab