From c976b9f3685fb506f3095dbf705f864e21121f93 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 14 May 2024 20:31:22 +0100 Subject: Added cards to resource list page --- pyblackbird_cc/resources/views.py | 4 + .../templates/resources/resource_list.html | 105 +++++++++------------ 2 files changed, 47 insertions(+), 62 deletions(-) diff --git a/pyblackbird_cc/resources/views.py b/pyblackbird_cc/resources/views.py index c3e79ff..c1d7672 100644 --- a/pyblackbird_cc/resources/views.py +++ b/pyblackbird_cc/resources/views.py @@ -27,8 +27,10 @@ logger = logging.getLogger(__name__) class ResourceInfo: id: int name: str + description: str main_resource_category_name: str additional_resource_category_name: str | None + age_range: str | None pdf_filenames: list[str] pdf_urls: list[str] snapshot_urls: dict[str, list[str]] @@ -79,8 +81,10 @@ def _extract_metadata_from_resource(resource_obj) -> ResourceInfo | None: return ResourceInfo( id=resource_obj.id, name=resource_obj.name, + description=resource_obj.description, main_resource_category_name=resource_obj.main_resource_category.name, additional_resource_category_name=arc_name, + age_range=resource_obj.age_range, pdf_filenames=pdf_resource_filenames, pdf_urls=pdf_urls, snapshot_urls=snapshot_url_dict, diff --git a/pyblackbird_cc/templates/resources/resource_list.html b/pyblackbird_cc/templates/resources/resource_list.html index fabc6a8..98c70e9 100644 --- a/pyblackbird_cc/templates/resources/resource_list.html +++ b/pyblackbird_cc/templates/resources/resource_list.html @@ -7,81 +7,62 @@
-
-
- {% if request.user.is_authenticated %} -
- Add a new resource -
-
- Logged in as {{ request.user.email }} -
-
-
- {% csrf_token %} - -
-
- {% endif %} +
+
+
+ {% if request.user.is_authenticated %} + +
+ Logged in as {{ request.user.email }} +
+
+
+ {% csrf_token %} + +
+
+ {% endif %} +
-
+
{% if resource_list %} - {% for resource in resource_list %} -
- -
-
- {{ resource.thumbnail_filename }} -
-
{{ resource.name }}
-

Some quick example text to build on the card title and make up the bulk of the - card's content.

- More... +
+ {% for resource in resource_list %} +
+
+
+ Featured
- - -
Main category: {{ resource.main_resource_category_name }}
- {% if resource.additional_resource_category_name %} -
Additional category: {{ resource.additional_resource_category_name }}
- {% endif %} -
-
-
-
- {# {% for img in resource.thumbnail_urls %}#} - {# {{ resource.thumbnail_filename }}#} - {# {% endfor %}#} - {{ resource.thumbnail_filename }} +
+
{{ resource.name }}
+
+
+ {{ resource.main_resource_category_name }} +
+
+ {{ resource.age_range }} +
+
+

{{ resource.description }}

+ More... +
-
- Click - - to download the resource -
-
-
- {% endfor %} + + {% endfor %} +
{% else %}

There are no resources

{% endif %} -
-- cgit v1.2.3