From 82d718de5e98b8543796ee61f112ab1e4177d850 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 14 May 2024 17:04:55 +0100 Subject: Further tidying --- pyblackbird_cc/resources/admin.py | 6 ++++ pyblackbird_cc/resources/views.py | 8 ++--- .../templates/resources/resource_detail.html | 36 +++++++++++----------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/pyblackbird_cc/resources/admin.py b/pyblackbird_cc/resources/admin.py index 1140c35..302f5ca 100644 --- a/pyblackbird_cc/resources/admin.py +++ b/pyblackbird_cc/resources/admin.py @@ -1,6 +1,7 @@ # Register your models here. from django.contrib import admin +from pyblackbird_cc.resources.models import Resource from pyblackbird_cc.resources.models import ResourceCategory from pyblackbird_cc.resources.models import ResourceType @@ -13,3 +14,8 @@ class ResourceTypeAdmin(admin.ModelAdmin): @admin.register(ResourceCategory) class ResourceCategoryAdmin(admin.ModelAdmin): pass + + +@admin.register(Resource) +class ResourceAdmin(admin.ModelAdmin): + pass diff --git a/pyblackbird_cc/resources/views.py b/pyblackbird_cc/resources/views.py index b09f37e..c3e79ff 100644 --- a/pyblackbird_cc/resources/views.py +++ b/pyblackbird_cc/resources/views.py @@ -86,8 +86,8 @@ def _extract_metadata_from_resource(resource_obj) -> ResourceInfo | None: snapshot_urls=snapshot_url_dict, thumbnail_filenames=resource_obj.thumbnail_filenames, thumbnail_urls=thumbnail_urls, - created=resource_obj.created_at.strftime("%Y-%m-%d %H:%M:%S"), - updated=resource_obj.updated_at.strftime("%Y-%m-%d %H:%M:%S"), + created=resource_obj.created_at, + updated=resource_obj.updated_at, ) except Exception as e: logging.exception(f"Error extracting resource information: {e}") @@ -232,9 +232,7 @@ def create_resource(request): age_range = form.cleaned_data["age_range"] curriculum = form.cleaned_data["curriculum"] main_resource_category = form.cleaned_data["main_resource_category"] - additional_resource_category = form.cleaned_data[ - "additional_resource_category" - ] + additional_resource_category = form.cleaned_data["additional_resource_category"] try: resource = Resource.objects.create( diff --git a/pyblackbird_cc/templates/resources/resource_detail.html b/pyblackbird_cc/templates/resources/resource_detail.html index 605f6bb..0bfdf92 100644 --- a/pyblackbird_cc/templates/resources/resource_detail.html +++ b/pyblackbird_cc/templates/resources/resource_detail.html @@ -7,7 +7,7 @@

{{ resource.name }}

- Subject:{{ resource.main_resource_category }} + Subject: {{ resource.main_resource_category }}
Age range: {{ resource.age_range }} @@ -15,6 +15,12 @@
Resource type: {{ resource.resource_type }}
+
+ Number of files: X NUMBER OF FILES +
+
+
+ Created: {{ resource.created|date:"D d M Y" }}
@@ -30,15 +36,15 @@ -
-
-

Resource files preview

- {% for snapshot_filename, snapshot_urls in resource.snapshot_urls.items %} -
{{ snapshot_filename }}
+ {% for snapshot_filename, snapshot_urls in resource.snapshot_urls.items %} +
+
+

File preview:

+

{{ snapshot_filename|cut:".pdf" }}

-
+
{% for snapshot_url in snapshot_urls %} -
+
{{ snapshot_filename }} @@ -47,18 +53,12 @@
- {% endfor %} -
+
+ {% endfor %}
-
-

What's included?

-
{{ resource.description }}
-

What's it for?

-
{% lorem %}
-

Resource Details

-
{% lorem %}
-
+

What's included?

+
{{ resource.description }}
-- cgit v1.2.3