From a82814eaef1b564597ff6d4d7dd3fb83d024a368 Mon Sep 17 00:00:00 2001 From: Ethan Clay <Ethan2.Clay@live.uwe.ac.uk> Date: Tue, 18 Feb 2025 10:57:36 +0000 Subject: [PATCH] Complete view booking route --- app/profile/routes.py | 6 ++- app/templates/profile/view_booking.html | 58 ++++++++++++++++--------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/app/profile/routes.py b/app/profile/routes.py index 1f41c87..d2d3560 100644 --- a/app/profile/routes.py +++ b/app/profile/routes.py @@ -4,6 +4,7 @@ from flask_principal import Identity, identity_changed from flask_login import login_user, logout_user, login_required, current_user from werkzeug.security import check_password_hash from app.profile import bp +from app.main.utils import pretty_time from app.models import User, Bookings, Listings from app.logger import auth_logger from app import db, permission_required, user_permission @@ -277,4 +278,7 @@ def cancel_booking(): @bp.route('/manage_bookings/view/<int:id>') def manage_profile_view_booking(id): - return render_template('profile/view_booking.html') + booking = Bookings.search_booking(id) + booking.listing.destination_time = pretty_time(booking.listing.destination_time) + booking.listing.depart_time = pretty_time(booking.listing.depart_time) + return render_template('profile/view_booking.html', booking=booking) diff --git a/app/templates/profile/view_booking.html b/app/templates/profile/view_booking.html index 8425a68..23e9fe2 100644 --- a/app/templates/profile/view_booking.html +++ b/app/templates/profile/view_booking.html @@ -1,28 +1,44 @@ {% extends 'base.html' %} {% block content %} -<div class="column is-4 is-offset-4"> - <div id="login-box" class="form_box_30" style="margin-top: 30px;"> - <div class="profile_form_background"> - <h2 class="form_header">Login</h2> - <form method="POST" action="{{ url_for('profile.login_post') }}"> - <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"> - <div class="mb-3"> - <label class="form-label" autofocus="">Username/Email</label> - <input type="text" class="form-control" name="username"> +<script src="{{ url_for('static', filename='generic.js') }}"></script> +<div class="container mt-5"> + <h2 class="mb-4 text-center">Booking Details</h2> + <div class="row justify-content-center"> + <div class="col-md-8"> + <div class="card mb-4 shadow-sm"> + <div class="card-body"> + <h3 class="card-title text-center mb-4">Summary</h3> + <div class="row"> + <div class="col-md-6"> + <p><strong>Departure Date:</strong> {{ booking.depart_date }}</p> + <p><strong>Departure Location:</strong> {{ booking.listing.depart_location }}</p> + <p><strong>Departure Time:</strong> {{ booking.listing.depart_time }}</p> + <p><strong>Seat Type:</strong> {{ booking.seat_type.capitalize() }}</p> + <p><strong>Total Cost:</strong> £{{ booking.amount_paid }}</p> + </div> + <div class="col-md-6"> + <p><strong>Destination Location:</strong> {{ booking.listing.destination_location }}</p> + <p><strong>Destination Time:</strong> {{ booking.listing.destination_time }}</p> + <p><strong>Number of Seats:</strong> {{ booking.num_seats }}</p> + <p><strong>Cost Per Person:</strong> £{{ booking.amount_paid / booking.num_seats }}</p> + <p><strong>Cancelled:</strong> {{ 'Yes' if booking.cancelled else 'No' }}</p> + </div> + </div> </div> - <div class="mb-3"> - <label for="exampleInputPassword1" class="form-label">Password</label> - <input type="password" class="form-control" name="password"> + </div> + <div class="card shadow-sm"> + <div class="card-body text-center"> + <h3 class="card-title mb-4">Re-Download Booking Details</h3> + <div class="d-flex justify-content-center"> + <form action="{{ url_for('bookings.generate_receipt', id=booking.id) }}" method="get" class="d-inline"> + <button type="submit" class="btn btn-success btn-lg mr-2" style="margin-right: 25px">Download Receipt</button> + </form> + <form action="{{ url_for('bookings.generate_ticket', id=booking.id) }}" method="get" class="d-inline"> + <button type="submit" class="btn btn-primary btn-lg">Download Plane Ticket</button> + </form> + </div> </div> - <div class="mb-3"> - <a class="clear-hyperlink" href="{{ url_for('profile.password_reset') }}">Forgot Password?</a> - </div> - <div class="mb-3 form-check"> - <input type="checkbox" class="form-check-input" id="remember" name="remember"> - <label class="form-check-label" for="remember">Remember me</label> - </div> - <button type="submit" class="btn btn-primary">Log In</button> - </form> + </div> </div> </div> </div> -- GitLab