From fae8ddb6d3ff28ac4d384c124972332becdedd2e Mon Sep 17 00:00:00 2001 From: 3err0 Date: Wed, 22 Jan 2025 08:33:57 +0800 Subject: [PATCH] new dashboard --- routes.py | 6 ++- templates/dashboard.html | 89 ++++++++++++++++++++++++++++++++-------- 2 files changed, 77 insertions(+), 18 deletions(-) diff --git a/routes.py b/routes.py index cc5fdb9..b43b597 100644 --- a/routes.py +++ b/routes.py @@ -84,12 +84,14 @@ def verify_document(document_id): return redirect(url_for('dashboard')) return redirect(url_for('home')) -@app.route('/dashboard') +@app.route('/dashboard', methods=['GET', 'POST']) @login_required def dashboard(): if current_user.is_host: listings = Listing.query.filter_by(host_id=current_user.id).all() - return render_template('dashboard.html', listings=listings) + users = User.query.all() + documents = {doc.user_id: doc for doc in Document.query.all()} + return render_template('dashboard.html', listings=listings, users=users, documents=documents) return redirect(url_for('home')) @app.route('/create-listing', methods=['GET', 'POST']) diff --git a/templates/dashboard.html b/templates/dashboard.html index ae34c26..afd7899 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -1,20 +1,77 @@ {% extends 'base.html' %} {% block title %}Dashboard{% endblock %} + {% block content %} -

Your Listings

-
- {% for listing in listings %} -
-
- ... -
-
{{ listing.title }}
-

{{ listing.description }}

- Edit - Delete -
-
-
- {% endfor %} +
+

Host Dashboard

+
+

Your Listings

+
+ + + + + + + + + + + + {% for listing in listings %} + + + + + + + + {% endfor %} + +
IDTitleLocationProperty TypeActions
{{ listing.id }}{{ listing.title }}{{ listing.location }}{{ listing.property_type }} + Edit + Delete +
+
-{% endblock %} \ No newline at end of file +
+

Registered Users

+
+ + + + + + + + + + + + {% for user in users %} + + + + + + + + {% endfor %} + +
IDEmailPhoneDocumentActions
{{ user.id }}{{ user.email }}{{ user.phone }} + {% if user.id in documents %} + View Document + {% else %} + Not Verified + {% endif %} + + {% if user.id in documents and not documents[user.id].verified %} +
+ +
+ {% endif %} +
+
+
+
+{% endblock %}