Skip to content
Snippets Groups Projects
Commit 90212c25 authored by Ethan-clay03's avatar Ethan-clay03
Browse files

Adding checkout page

parent 31ec2a50
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ from app import db ...@@ -5,6 +5,7 @@ from app import db
from app.logger import error_logger from app.logger import error_logger
from app.main.utils import calculate_discount, pretty_time from app.main.utils import calculate_discount, pretty_time
import json import json
from datetime import datetime
@bp.route('/') @bp.route('/')
...@@ -69,9 +70,9 @@ def listing_apply_update(): ...@@ -69,9 +70,9 @@ def listing_apply_update():
def checkout(): def checkout():
if not session['checkout_cache']: if not session['checkout_cache']:
flash("Please select a booking", 'error') flash("Please select a booking", 'error')
depart_date = request.args.get('date') depart_date = session['checkout_cache']['depart_date']
num_seats = request.args.get('seats') num_seats = session['checkout_cache']['num_seats']
listing_id = request.args.get('listing_id') listing_id = session['checkout_cache']['listing_id']
session['checkout_cache'] = { session['checkout_cache'] = {
'depart_date': depart_date, 'depart_date': depart_date,
...@@ -79,7 +80,15 @@ def checkout(): ...@@ -79,7 +80,15 @@ def checkout():
'listing_id': listing_id 'listing_id': listing_id
} }
return redirect(url_for('bookings.checkout')) listing = Listings.search_listing(listing_id)
listing.depart_time = pretty_time(listing.depart_time)
listing.destination_time = pretty_time(listing.destination_time)
# Parse depart_date as a date object
depart_date_obj = datetime.strptime(depart_date, '%Y-%m-%d')
depart_date_formatted = depart_date_obj.strftime('%d-%m-%Y')
return render_template('bookings/checkout.html', listing=listing, num_seats=num_seats, depart_date=depart_date_formatted)
@bp.route('/payment') @bp.route('/payment')
def payment(): def payment():
......
{% extends 'base.html' %}
{% block content %}
<div class="container mt-5">
<h2 class="mb-4" style="text-align: center; margin-top: 40px;">Booking Details</h2>
<div class="row">
<div class="col-md-12">
<div class="card mb-4">
<div class="card-body">
<h2 class="card-title">Summary</h2>
<p><strong>Departure Date:</strong> {{ depart_date }}</p>
<p><strong>Number of Seats:</strong> {{ num_seats }}</p>
<p><strong>Departure Location:</strong> {{ listing.depart_location }}</p>
<p><strong>Departure Time:</strong> {{ listing.depart_time }}</p>
<p><strong>Destination Location:</strong> {{ listing.destination_location }}</p>
<p><strong>Destination Time:</strong> {{ listing.destination_time }}</p>
<p><strong>Total Cost:</strong> £{{ listing.fair_cost * num_seats|int }}</p>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment