From 6e2ada617e900d875d82ae45aa78480edec57aca Mon Sep 17 00:00:00 2001 From: b4-sharp <Bradley2.Sharp@live.uwe.ac.uk> Date: Sun, 16 Apr 2023 03:09:58 +0100 Subject: [PATCH] Update account page --- store/routes.py | 16 ++++----- store/templates/index.html | 2 +- store/templates/userContent/account.html | 12 ------- .../templates/userContent/accountDetails.html | 34 ------------------ store/templates/userContent/admin.html | 13 ------- store/templates/userContent/user.html | 36 +++++++++++++++---- 6 files changed, 36 insertions(+), 77 deletions(-) delete mode 100644 store/templates/userContent/account.html delete mode 100644 store/templates/userContent/accountDetails.html delete mode 100644 store/templates/userContent/admin.html diff --git a/store/routes.py b/store/routes.py index 900bece..7d0bfc9 100644 --- a/store/routes.py +++ b/store/routes.py @@ -300,14 +300,6 @@ def account(): return redirect(url_for("index")) -@app.route("/accountDetails") -@login_required -def accountDetails(): - a = get_user_id() - user = User.query.filter_by(user_id=a).first() - return render_template("userContent/accountDetails.html", user=user) - - @app.route("/standardUser") @login_required def standardUser(): @@ -315,7 +307,9 @@ def standardUser(): flash("Unauthorized access no admins allowed please create a standard account") return redirect(url_for("home")) else: - return render_template("userContent/user.html") + return render_template( + "userContent/user.html", user=current_user, userType=current_user.userType + ) @app.route("/admin") @@ -325,7 +319,9 @@ def admin(): flash("Unauthorized access") return redirect(url_for("home")) else: - return render_template("userContent/admin.html") + return render_template( + "userContent/user.html", user=current_user, userType=current_user.userType + ) @app.route("/database_management", methods=["GET", "POST"]) diff --git a/store/templates/index.html b/store/templates/index.html index 363ac45..7efed29 100644 --- a/store/templates/index.html +++ b/store/templates/index.html @@ -2,7 +2,7 @@ {% block title %} Welcome! {% endblock %} {% block content %} <div class="container"> - <p class="my-4"> + <p class="my-2"> Antique's Online maintains a large collection of antiques and collectables stored in various repositories around the world. Our business sells these items through its online store and also through a variety of online auction diff --git a/store/templates/userContent/account.html b/store/templates/userContent/account.html deleted file mode 100644 index b97dd74..0000000 --- a/store/templates/userContent/account.html +++ /dev/null @@ -1,12 +0,0 @@ -{%extends 'base.html' %} - -{% block content %} -{% block title %} Account{% endblock %} -<h1>account Information</h1> -<ul> - <li><a href="{{ url_for('accountDetails', user_id=current_user.id)}}">View my Account details</a></li> - <li><a href="{{ url_for('orders', user_id=current_user.id)}}">View Orders</a></li> - <li><a href="{{ url_for('addresses', user_id=current_user.id)}}">View shipping address</a></li> - <li><a href="{{ url_for('Payment', user_id=current_user.id)}}">View your payment method</a></li> -</ul> -{% endblock %} \ No newline at end of file diff --git a/store/templates/userContent/accountDetails.html b/store/templates/userContent/accountDetails.html deleted file mode 100644 index b1645cb..0000000 --- a/store/templates/userContent/accountDetails.html +++ /dev/null @@ -1,34 +0,0 @@ -{%extends 'base.html' %} - -{% block content %} -<h1>Account Details</h1> -<h1>Welcome, {{ user.username }}</h1> -<table style="width:100%"> - <tr> - <th>Your username is:</th> - <th>{{ user.username }}</th> - <th><a href="{{ url_for('ChangeUsername')}}">change your username</a></th> - - </tr> - <tr> - <td>Your email address is:</td> - <td>{{ user.email }}</td> - <td><a href="{{ url_for('ChangeEmail')}}">Change email address</a></td> - </tr> - <tr> - <th>Your Phone Number is:</th> - <td>{{ user.phone_number }}</td> - <td><a href="{{ url_for('ChangePhNumber')}}">change phone number</a></td> - </tr> -</table> -{% endblock %} - -<!-- - {% block title %} Account{% endblock %} - <h1>Account Details</h1> - <h1>Welcome, {{ user.username }}</h1> - <p>Your email address is: {{ user.email }}</p> - <p>Your Phone Number is: {{ user.phone_number }}</p> - - - --> \ No newline at end of file diff --git a/store/templates/userContent/admin.html b/store/templates/userContent/admin.html deleted file mode 100644 index 35187f8..0000000 --- a/store/templates/userContent/admin.html +++ /dev/null @@ -1,13 +0,0 @@ -{%extends 'base.html' %} - -{% block content %} -{% block title %} Account{% endblock %} -<h1>Admin usertype account Information</h1> -<ul> - <li><a href="{{ url_for('accountDetails')}}">View my Account details</a></li> - <li><a href="{{ url_for('view_address')}}">View my shipping address</a></li> - <li><a href="{{ url_for('database_management')}}">Edit existing entries</a></li> - <li><a href="{{ url_for('database_management_add')}}">Add new entries</a></li> - -</ul> -{% endblock %} \ No newline at end of file diff --git a/store/templates/userContent/user.html b/store/templates/userContent/user.html index eb4a4c7..0ac2d7f 100644 --- a/store/templates/userContent/user.html +++ b/store/templates/userContent/user.html @@ -1,10 +1,32 @@ {%extends 'base.html' %} -{% block content %} {% block title %} Account{% endblock %} -<h1>Standard usertype account Information</h1> -<ul> - <li><a href="{{ url_for('accountDetails', user_id=current_user.id)}}">View my Account details</a></li> - <li><a href="{{ url_for('addAdress', user_id=current_user.id)}}">Add shipping address</a></li> - <li><a href="{{ url_for('view_address', user_id=current_user.id)}}">View your shipping address</a></li> -</ul> +{% block content %} +<div class="container text-center"> + <h1>Account Information</h1> + <div class="p-1"> + Username: {{ user.username }} + <a class="btn btn-primary" href="{{ url_for('ChangeUsername')}}">Change your username</a> + </div> + <div class="p-1"> + Email: {{ user.email }} + <a class="btn btn-primary" href="{{ url_for('ChangeEmail')}}">Change email address</a> + </div> + <div class="p-1"> + Phone Number: {{ user.phone_number }} + <a class="btn btn-primary" href="{{ url_for('ChangePhNumber')}}">Change phone number</a> + </div> + {% if userType == "standard" %} + <div class="p-1"> + <a class="mx-auto btn btn-primary" href="{{ url_for('addAdress', user_id=current_user.id)}}">Add shipping + address</a> + <a class="mx-auto btn btn-primary" href="{{ url_for('view_address', user_id=current_user.id)}}">View shipping + address</a> + </div> + {% else %} + <div class="p-1"> + <a class="mx-auto btn btn-primary" href="{{ url_for('database_management')}}">Edit database entries</a> + <a class="mx-auto btn btn-primary" href="{{ url_for('database_management_add')}}">Add database entries</a> + </div> + {% endif %} +</div> {% endblock %} \ No newline at end of file -- GitLab