new dashboard
This commit is contained in:
@@ -84,12 +84,14 @@ def verify_document(document_id):
|
|||||||
return redirect(url_for('dashboard'))
|
return redirect(url_for('dashboard'))
|
||||||
return redirect(url_for('home'))
|
return redirect(url_for('home'))
|
||||||
|
|
||||||
@app.route('/dashboard')
|
@app.route('/dashboard', methods=['GET', 'POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def dashboard():
|
def dashboard():
|
||||||
if current_user.is_host:
|
if current_user.is_host:
|
||||||
listings = Listing.query.filter_by(host_id=current_user.id).all()
|
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'))
|
return redirect(url_for('home'))
|
||||||
|
|
||||||
@app.route('/create-listing', methods=['GET', 'POST'])
|
@app.route('/create-listing', methods=['GET', 'POST'])
|
||||||
|
|||||||
+70
-13
@@ -1,20 +1,77 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
{% block title %}Dashboard{% endblock %}
|
{% block title %}Dashboard{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1 class="text-center">Your Listings</h1>
|
<div class="container mt-4">
|
||||||
<div class="row">
|
<h1 class="text-center">Host Dashboard</h1>
|
||||||
|
<div class="mt-4">
|
||||||
|
<h2>Your Listings</h2>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Title</th>
|
||||||
|
<th>Location</th>
|
||||||
|
<th>Property Type</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
{% for listing in listings %}
|
{% for listing in listings %}
|
||||||
<div class="col-md-4 mb-4">
|
<tr>
|
||||||
<div class="card h-100">
|
<td>{{ listing.id }}</td>
|
||||||
<img src="/static/images/default.jpg" class="card-img-top" alt="...">
|
<td>{{ listing.title }}</td>
|
||||||
<div class="card-body">
|
<td>{{ listing.location }}</td>
|
||||||
<h5 class="card-title">{{ listing.title }}</h5>
|
<td>{{ listing.property_type }}</td>
|
||||||
<p class="card-text">{{ listing.description }}</p>
|
<td>
|
||||||
<a href="/edit-listing/{{ listing.id }}" class="btn btn-warning">Edit</a>
|
<a href="/edit-listing/{{ listing.id }}" class="btn btn-warning btn-sm">Edit</a>
|
||||||
<a href="/delete-listing/{{ listing.id }}" class="btn btn-danger">Delete</a>
|
<a href="/delete-listing/{{ listing.id }}" class="btn btn-danger btn-sm">Delete</a>
|
||||||
</div>
|
</td>
|
||||||
</div>
|
</tr>
|
||||||
</div>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mt-5">
|
||||||
|
<h2>Registered Users</h2>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Email</th>
|
||||||
|
<th>Phone</th>
|
||||||
|
<th>Document</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for user in users %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ user.id }}</td>
|
||||||
|
<td>{{ user.email }}</td>
|
||||||
|
<td>{{ user.phone }}</td>
|
||||||
|
<td>
|
||||||
|
{% if user.id in documents %}
|
||||||
|
<a href="/uploads/documents/{{ documents[user.id].filename }}" target="_blank">View Document</a>
|
||||||
|
{% else %}
|
||||||
|
Not Verified
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if user.id in documents and not documents[user.id].verified %}
|
||||||
|
<form method="POST" action="/verify-document/{{ documents[user.id].id }}">
|
||||||
|
<button type="submit" class="btn btn-success btn-sm">Verify</button>
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user