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('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'])
|
||||
|
||||
+73
-16
@@ -1,20 +1,77 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block title %}Dashboard{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1 class="text-center">Your Listings</h1>
|
||||
<div class="row">
|
||||
{% for listing in listings %}
|
||||
<div class="col-md-4 mb-4">
|
||||
<div class="card h-100">
|
||||
<img src="/static/images/default.jpg" class="card-img-top" alt="...">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{ listing.title }}</h5>
|
||||
<p class="card-text">{{ listing.description }}</p>
|
||||
<a href="/edit-listing/{{ listing.id }}" class="btn btn-warning">Edit</a>
|
||||
<a href="/delete-listing/{{ listing.id }}" class="btn btn-danger">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="container mt-4">
|
||||
<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 %}
|
||||
<tr>
|
||||
<td>{{ listing.id }}</td>
|
||||
<td>{{ listing.title }}</td>
|
||||
<td>{{ listing.location }}</td>
|
||||
<td>{{ listing.property_type }}</td>
|
||||
<td>
|
||||
<a href="/edit-listing/{{ listing.id }}" class="btn btn-warning btn-sm">Edit</a>
|
||||
<a href="/delete-listing/{{ listing.id }}" class="btn btn-danger btn-sm">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
<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>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user