From 657b51b2ec1ff44e434fc1bf068094aab01602e2 Mon Sep 17 00:00:00 2001 From: Ethan Clay <Ethan2.Clay@live.uwe.ac.uk> Date: Fri, 14 Mar 2025 09:36:27 +0000 Subject: [PATCH] Fix favicon for error page, add view bookings for admins which allows cancellation --- app/admin/routes.py | 24 +++++++++++++++++++++++- app/templates/errors/error.html | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/admin/routes.py b/app/admin/routes.py index 8d9259b..dcf3d07 100644 --- a/app/admin/routes.py +++ b/app/admin/routes.py @@ -3,7 +3,7 @@ from datetime import datetime, timedelta from sqlalchemy.sql import text from app import admin_permission, permission_required, super_admin_permission, db from app.models import Listings, ListingImages, User, Bookings, Role -from app.main.utils import generate_time_options +from app.main.utils import generate_time_options, pretty_time, get_days_until_departure, calculate_refund_amount from app.admin import bp @@ -23,6 +23,28 @@ def manage_bookings(): locations = Listings.get_all_locations(True) return render_template('admin/manage_bookings.html', locations=locations) + +@bp.route('/manage_bookings/view/<int:id>') +@permission_required(admin_permission) +def admin_view_user_booking(id): + 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) + + days_until_departure = get_days_until_departure(booking) + cancel_amount, cancel_percentage = calculate_refund_amount(booking) + refund = { + 'amount': cancel_amount, + 'percentage': cancel_percentage + } + + departed = False + if days_until_departure < 0: + departed = True + + return render_template('profile/view_booking.html', booking=booking, refund=refund, days_until_departure=days_until_departure, departed=departed) + + @bp.route('/manage_bookings/edit/<int:id>') @permission_required(admin_permission) def edit_booking(id): diff --git a/app/templates/errors/error.html b/app/templates/errors/error.html index 61e13de..94f3b68 100644 --- a/app/templates/errors/error.html +++ b/app/templates/errors/error.html @@ -3,6 +3,7 @@ <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='base.css') }}"> <script src="https://kit.fontawesome.com/11fd621de6.js" crossorigin="anonymous"></script> <title> HT | Something went wrong </title> + <link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon"> </head> <div class="quandary-div"> <h1>Something went wrong</h1> -- GitLab