From f9a56bd145cb9e831011a30289209d86c7b0cd07 Mon Sep 17 00:00:00 2001 From: Valerij Maljulin Date: Thu, 2 Nov 2023 15:25:04 +0100 Subject: [PATCH] Moving js to a separate file, refactoring templates to use a common layout --- waiverdb/api_v1.py | 9 ++++++ waiverdb/templates/layout.html | 44 ++--------------------------- waiverdb/templates/new_waiver.html | 5 ++++ waiverdb/templates/permissions.html | 35 ++++++----------------- 4 files changed, 25 insertions(+), 68 deletions(-) diff --git a/waiverdb/api_v1.py b/waiverdb/api_v1.py index 643fa8b..e488098 100644 --- a/waiverdb/api_v1.py +++ b/waiverdb/api_v1.py @@ -392,6 +392,14 @@ def get(self): ), mimetype='text/html') +class WaiversJSResource(Resource): + """ + Provides a JS for a new waiver form + """ + def get(self): + return Response(render_template('new_waiver.js'), mimetype='application/javascript') + + class WaiversCreateResource(WaiversResource): """ Deprecated, kept as a redirect for a backward compatibility @@ -725,6 +733,7 @@ def get(self): # set up the Api resource routing here api.add_resource(WaiversResource, '/waivers/') api.add_resource(WaiversNewResource, '/waivers/new') +api.add_resource(WaiversJSResource, '/waivers/new/new_waiver.js') api.add_resource(WaiversCreateResource, '/waivers/create') api.add_resource(WaiverResource, '/waivers/') api.add_resource(FilteredWaiversResource, '/waivers/+filtered') diff --git a/waiverdb/templates/layout.html b/waiverdb/templates/layout.html index d8fc3c1..f7f3485 100644 --- a/waiverdb/templates/layout.html +++ b/waiverdb/templates/layout.html @@ -17,52 +17,14 @@ - - + {% block scripts %} + {% endblock %}

- Waiver DB + {{ self.title() }}

{% for message in get_flashed_messages() %} diff --git a/waiverdb/templates/new_waiver.html b/waiverdb/templates/new_waiver.html index 858fd7a..0503f12 100644 --- a/waiverdb/templates/new_waiver.html +++ b/waiverdb/templates/new_waiver.html @@ -4,6 +4,11 @@ WaiverDB: Create a Waiver {% endblock %} +{% block scripts %} + + +{% endblock %} + {% block body %} {% if warning %} diff --git a/waiverdb/templates/permissions.html b/waiverdb/templates/permissions.html index a5cc2e0..07e9960 100644 --- a/waiverdb/templates/permissions.html +++ b/waiverdb/templates/permissions.html @@ -1,30 +1,13 @@ - - - - - - - +{% extends "layout.html" %} - +{% block title %} + WaiverDB: Permissions +{% endblock %} - - {% block title %} - WaiverDB Permissions - {% endblock %} - +{% block scripts %} +{% endblock %} - - - - - -
-

- Waiver DB - {{ self.title() }} -

+{% block body %} @@ -57,6 +40,4 @@

{%- endfor %}

-
- - +{% endblock %}