aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-05-14 20:31:22 +0100
committerMatthew Lemon <y@yulqen.org>2024-05-14 20:31:22 +0100
commitc976b9f3685fb506f3095dbf705f864e21121f93 (patch)
treedf6026690ed4955f74314daef5bc698ca6a72285
parent64c1e2ffd2898f41fc6c5e0d080541e7289fe442 (diff)
Added cards to resource list page
-rw-r--r--pyblackbird_cc/resources/views.py4
-rw-r--r--pyblackbird_cc/templates/resources/resource_list.html105
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 @@
<div class="container">
- <div class="row bg-white">
- <div class="col bg-white pt-3 border border-success border-opacity-25 rounded">
- {% if request.user.is_authenticated %}
- <div>
- <a href="{% url 'resources:create_resource' %} ">Add a new resource</a>
- </div>
- <div>
- Logged in as {{ request.user.email }}
- </div>
- <div>
- <form action="{% url 'account_logout' %}" method="post">
- {% csrf_token %}
- <button type="submit">Log out</button>
- </form>
- </div>
- {% endif %}
+ <div class="row">
+ <div class="col">
+ <div class="d-flex flex-row justify-content-between">
+ {% if request.user.is_authenticated %}
+ <div>
+ <a class="btn btn-primary" href="{% url 'resources:create_resource' %} ">Add a new resource</a>
+ </div>
+ <div>
+ Logged in as {{ request.user.email }}
+ </div>
+ <div>
+ <form action="{% url 'account_logout' %}" method="post">
+ {% csrf_token %}
+ <button type="submit">Log out</button>
+ </form>
+ </div>
+ {% endif %}
+ </div>
</div>
</div>
<div class="row my-4">
- <div class="col-6 bg-white pt-3 border border-success border-opacity-25 rounded">
+ <div class="col">
{% if resource_list %}
- {% for resource in resource_list %}
- <div>
- <div>
- <a class="no-underline"
- href="{% url 'resources:resource_detail' resource_id=resource.id %}">
- <h1 class="resource-title">{{ resource.name }}</h1>
- </a>
- </div>
- <div>
- <div class="card" style="width: 18rem;">
- <img class="card-img-top" src="{{ resource.thumbnail_urls|first }}"
- alt="{{ resource.thumbnail_filename }}">
- <div class="card-body">
- <h5 class="card-title">{{ resource.name }}</h5>
- <p class="card-text">Some quick example text to build on the card title and make up the bulk of the
- card's content.</p>
- <a href="{% url 'resources:resource_detail' resource_id=resource.id %}" class="btn btn-primary">More...</a>
+ <div class="d-flex flex-row justify-content-start flex-wrap">
+ {% for resource in resource_list %}
+ <div class="card mx-2 mt-2" style="width: 22rem;">
+ <div class="card-header">
+ <div class="text-success">
+ Featured
</div>
</div>
-
-
- <div>Main category: {{ resource.main_resource_category_name }}</div>
- {% if resource.additional_resource_category_name %}
- <div>Additional category: {{ resource.additional_resource_category_name }}</div>
- {% endif %}
- </div>
- </div>
- <div>
- <div class="resource-img-detail">
- {# {% for img in resource.thumbnail_urls %}#}
- {# <img style="max-height: 400px;#}
- {# width: auto"#}
- {# src="{{ img }}"#}
- {# alt="{{ resource.thumbnail_filename }}" />#}
- {# {% endfor %}#}
- <img style="max-height: 300px; width: auto" src="{{ resource.thumbnail_urls|first }}"
+ <img class="card-img-top" src="{{ resource.thumbnail_urls|first }}"
alt="{{ resource.thumbnail_filename }}">
+ <div class="card-body">
+ <h5 class="card-title">{{ resource.name }}</h5>
+ <div class="d-flex flex-row justify-content-start align-content-center">
+ <div>
+ <span class="badge text-bg-secondary me-2">{{ resource.main_resource_category_name }}</span>
+ </div>
+ <div>
+ <span class="badge text-bg-success me-2">{{ resource.age_range }}</span>
+ </div>
+ </div>
+ <p class="card-text my-3">{{ resource.description }}</p>
+ <a href="{% url 'resources:resource_detail' resource_id=resource.id %}"
+ class="btn btn-secondary">More...</a>
+ </div>
</div>
- <div>
- Click
- <button hx-get="/hx-download-btn?rn={{ resource.pdf_filename }}"
- hx-target="next #download-reveal">here
- </button>
- to download the resource
- </div>
- <div id="download-reveal"></div>
- </div>
- {% endfor %}
+
+ {% endfor %}
+ </div>
{% else %}
<p>There are no resources</p>
{% endif %}
-
</div>
</div>
</div>