aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-10-20 21:15:36 +0100
committerMatthew Lemon <y@yulqen.org>2024-10-20 21:15:36 +0100
commit087ebafdd87cc6513a8b8adec8d188b7096f9ab4 (patch)
tree5ba49cae878bb687eb716684e99f3c00b273a66e
parente063a30a06caef9e4cda7afb5ef175b1c04b5e96 (diff)
bugfix: assign price of 0 to resource without Price object
-rw-r--r--alphabetlearning/resources/views.py5
-rw-r--r--alphabetlearning/templates/resources/resource_detail.html2
2 files changed, 6 insertions, 1 deletions
diff --git a/alphabetlearning/resources/views.py b/alphabetlearning/resources/views.py
index c3d1bcd..773b1c2 100644
--- a/alphabetlearning/resources/views.py
+++ b/alphabetlearning/resources/views.py
@@ -293,6 +293,10 @@ def resource_detail(request, resource_id):
"""
resource_obj = get_object_or_404(Resource, pk=resource_id)
resource_metadata = _extract_metadata_from_resource(resource_obj)
+ try:
+ price = resource_obj.price_obj.first().price / 1000
+ except AttributeError:
+ price = 0
resource = {
"id": resource_obj.id,
"name": resource_obj.name,
@@ -306,6 +310,7 @@ def resource_detail(request, resource_id):
),
"age_range": resource_obj.age_range,
"curriculum": resource_obj.curriculum,
+ "price": price,
"pdf_filenames": resource_metadata.pdf_filenames,
"pdf_urls": resource_metadata.pdf_urls,
"thumbnails": list(
diff --git a/alphabetlearning/templates/resources/resource_detail.html b/alphabetlearning/templates/resources/resource_detail.html
index b92ba52..edbada1 100644
--- a/alphabetlearning/templates/resources/resource_detail.html
+++ b/alphabetlearning/templates/resources/resource_detail.html
@@ -35,7 +35,7 @@
{% endif %}
</div>
<div class="col">
- <p class="fs-3 fw-semibold">£1.50 (or 1 credit)</p>
+ <p class="fs-3 fw-semibold">£{{ resource.price|floatformat:2 }} (or 1 credit)</p>
</div>
<hr>