diff --git a/seed_database.py b/seed_database.py index b9771680a488a827c5111799846a2c600639baa3..372a5fdbc09c4bdfd1af0a387b7462322c68c6e1 100644 --- a/seed_database.py +++ b/seed_database.py @@ -87,7 +87,7 @@ with app.app_context(): username="admin", email="admin@admin.com", phone_number="1234567890", - password_hash = password_hash1, # + password_hash = password_hash1, securityQ1="red", userType="admin", ) diff --git a/store/routes.py b/store/routes.py index 8949f975096dbce268eff163f0813ae18880e4a0..117272e122c0606ca97acc97d20bf727fa824969 100644 --- a/store/routes.py +++ b/store/routes.py @@ -1,6 +1,7 @@ from store import app, db from flask import render_template, request, flash, redirect, url_for, Flask, session from store.utility import * + # Official flask-login doc free liecense # https://flask-login.readthedocs.io/en/latest/ @@ -338,6 +339,22 @@ def ChangePhNumber(): return render_template('userContent/ChangePhNumber.html') + + + +@app.route('/view_address', methods=['GET']) +@login_required +def view_address(): + user_id = current_user.user_id + addresses = Adresses.query.filter_by(user_id=user_id).all() + + if not addresses: + flash("You don't have any saved addresses. you can add here") + return redirect(url_for('addAdress', user_id=user_id)) + else: + return render_template('userContent/view_address.html', addresses=addresses) + + @app.route("/addAdress", methods=['GET', 'POST']) @login_required diff --git a/store/templates/userContent/admin.html b/store/templates/userContent/admin.html index 771dbcb0bd0650bb0c355ef301d884b826e704db..164081783bdf12c550f14aa529839795b97b7b13 100644 --- a/store/templates/userContent/admin.html +++ b/store/templates/userContent/admin.html @@ -5,6 +5,6 @@ <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> </ul> {% endblock %} \ No newline at end of file diff --git a/store/templates/userContent/view_address.html b/store/templates/userContent/view_address.html new file mode 100644 index 0000000000000000000000000000000000000000..3abc3f25a6485c83f90e71cb5b755c432d493a6b --- /dev/null +++ b/store/templates/userContent/view_address.html @@ -0,0 +1,27 @@ +{% extends 'base.html' %} + +{% block content %} + <h1>Saved Addresses</h1> + <table class="table"> + <thead> + <tr> + <th>Street</th> + <th>City</th> + <th>State</th> + <th>Postal Code</th> + <th>Country</th> + </tr> + </thead> + <tbody> + {% for address in addresses %} + <tr> + <td>{{ address.street }}</td> + <td>{{ address.city }}</td> + <td>{{ address.state }}</td> + <td>{{ address.postal_code }}</td> + <td>{{ address.country }}</td> + </tr> + {% endfor %} + </tbody> + </table> +{% endblock %} \ No newline at end of file