Skip to content
Snippets Groups Projects
Commit ef7ebd73 authored by Ethan2.Clay@live.uwe.ac.uk's avatar Ethan2.Clay@live.uwe.ac.uk
Browse files

Add CSS Slider, implement top 5 listings on core page, beginning work on...

Add CSS Slider, implement top 5 listings on core page, beginning work on uploading destination images
parent 1a17cf43
Branches
No related tags found
No related merge requests found
......@@ -12,5 +12,5 @@ def redirect_index():
@bp.route('/listings')
def listings():
all_listings = Listings.get_all_listings()
return render_template('bookings/listings.html', all_listings=all_listings)
top_listings = Listings.get_top_listings(5)
return render_template('bookings/listings.html', top_listings=top_listings)
......@@ -29,9 +29,17 @@ class Listings(db.Model):
business_tickets=business_tickets,
economy_tickets=economy_tickets)
# Add the new flight to the session and commit
# Add the new flight to the database and commit
db.session.add(new_flight)
db.session.commit()
return new_flight
#return cls.query.all()
@classmethod
def get_top_listings(cls, amount_of_listings = 5):
return cls.query.order_by(
cls.economy_tickets,
cls.business_tickets
).limit(amount_of_listings).all()
\ No newline at end of file
......@@ -40,10 +40,6 @@
</ul>
</li>
</ul>
<form class="d-flex">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</div>
</nav>
......
{% extends 'base.html' %}
# Implements CSS Slider from https://swiffyslider.com/docs/
{% block content %}
<head>
<!-- <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='listings.css')}}"> -->
<script src="https://cdn.jsdelivr.net/npm/swiffy-slider@1.6.0/dist/js/swiffy-slider.min.js" crossorigin="anonymous" defer></script>
<link href="https://cdn.jsdelivr.net/npm/swiffy-slider@1.6.0/dist/css/swiffy-slider.min.css" rel="stylesheet" crossorigin="anonymous">
</head>
<div class="content">
<div class="content">
<p>{{all_listings}}</p>
<h1>All Listings</h1>
<table border="1">
<thead>
<tr>
{% for column in column_names %}
<th>{{ column.replace('_', ' ').title() }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for listing in all_listings %}
<tr>
{% for column in column_names %}
<td>{{ getattr(listing, column) }}</td>
{% endfor %}
</tr>
{% else %}
<tr>
<td colspan="{{ column_names | length }}">No listings available.</td>
</tr>
<div class="swiffy-slider slider-item-show2 slider-item-reveal slider-nav-outside slider-nav-round slider-nav-visible slider-indicators-outside slider-indicators-round slider-indicators-dark slider-nav-animation slider-nav-animation-fadein slider-item-first-visible">
<ul class="slider-container py-4">
{% for listing in top_listings %}
<li class="slide-visible">
<div class="card shadow h-100">
<div class="ratio ratio-16x9">
<img src="../uploads/listing_images/{{listing.}}.jpg" class="card-img-top" loading="lazy" alt="...">
</div>
<div class="card-body p-3 p-xl-4">
<h3 class="card-title h5">{{listing.destination_location}}</h3>
<p class="card-text">Add Location description here once implemented</p>
<div><a href="#" class="btn btn-primary">Book now</a>
</div>
</div>
</div>
</li>
{% endfor %}
</tbody>
</table>
</ul>
<button type="button" class="slider-nav" aria-label="Go left"></button>
<button type="button" class="slider-nav slider-nav-next" aria-label="Go left"></button>
<div class="slider-indicators">
<button class="active" aria-label="Go to slide"></button>
<button aria-label="Go to slide" class=""></button>
<button aria-label="Go to slide" class=""></button>
<button aria-label="Go to slide" class=""></button>
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment