From a079cf0f2e486d2d551fadbac1ae84ce6f1ebcb3 Mon Sep 17 00:00:00 2001 From: norohind <60548839+norohind@users.noreply.github.com> Date: Thu, 16 Dec 2021 15:05:41 +0300 Subject: [PATCH] web: new pretty design for squad info page --- .../table_template_squad_info_by_tag.html | 20 +++++++++++++++++++ web/__init__.py | 17 +++++++++++----- 2 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 templates/table_template_squad_info_by_tag.html diff --git a/templates/table_template_squad_info_by_tag.html b/templates/table_template_squad_info_by_tag.html new file mode 100644 index 0000000..d1a725b --- /dev/null +++ b/templates/table_template_squad_info_by_tag.html @@ -0,0 +1,20 @@ + + + + + {{ @json2html_template.html }} + + {{ details_type }} information for {{ tag }} + + +
+
+
+ +
+ {{ @footer.html }} + + \ No newline at end of file diff --git a/web/__init__.py b/web/__init__.py index 95d93ee..08cdaa6 100644 --- a/web/__init__.py +++ b/web/__init__.py @@ -8,13 +8,21 @@ model.open_model() class SquadsInfoByTagHtml: - def on_get(self, req: falcon.request.Request, resp: falcon.response.Response, tag: str) -> None: + def on_get(self, req: falcon.request.Request, resp: falcon.response.Response, tag: str, details_type: str) -> None: resp.content_type = falcon.MEDIA_HTML + + details_type = details_type.lower() + + if details_type not in ['short', 'extended']: + raise falcon.HTTPBadRequest(description=f'details_type must be one of short, extended') + resp.text = render( - 'table_template.html', + 'table_template_squad_info_by_tag.html', { 'target_column_name': 'None', - 'target_new_url': '' + 'target_new_url': '', + 'tag': tag, + 'details_type': details_type.title() } ) @@ -53,8 +61,7 @@ class SquadsInfoByTag: application = falcon.App() -application.add_route('/squads/now/by-tag/short/{tag}', SquadsInfoByTagHtml()) -application.add_route('/squads/now/by-tag/extended/{tag}', SquadsInfoByTagHtml()) +application.add_route('/squads/now/by-tag/{details_type}/{tag}', SquadsInfoByTagHtml()) application.add_route('/api/squads/now/by-tag/{details_type}/{tag}', SquadsInfoByTag())