diff --git a/manuscript/urls.py b/manuscript/urls.py index 6d71afb..bd90506 100644 --- a/manuscript/urls.py +++ b/manuscript/urls.py @@ -7,5 +7,7 @@ path("", views.index, name="index"), path("manuscripts/", views.manuscripts, name="manuscripts"), path("manuscripts//", views.manuscript, name="manuscript"), + path("toponyms/", views.toponyms, name="toponyms"), + path("toponyms//", views.toponym, name="toponym"), path("stanzas/", views.stanzas, name="stanzas"), ] diff --git a/manuscript/views.py b/manuscript/views.py index 3517443..9090d78 100644 --- a/manuscript/views.py +++ b/manuscript/views.py @@ -6,7 +6,7 @@ from django.urls import reverse from django.views import generic -from manuscript.models import SingleManuscript, Stanza +from manuscript.models import Location, SingleManuscript, Stanza def index(request: HttpRequest): @@ -34,19 +34,36 @@ def stanzas(request: HttpRequest): def manuscripts(request: HttpRequest): - manuscripts = SingleManuscript.objects.all() - return render(request, "manuscripts.html", {"manuscripts": manuscripts}) + manuscript_objs = SingleManuscript.objects.all() + return render(request, "manuscripts.html", {"manuscripts": manuscript_objs}) def manuscript(request: HttpRequest, siglum: str): - manuscript = get_object_or_404(SingleManuscript, siglum=siglum) - folios = manuscript.folio_set.all() + get_manuscript = get_object_or_404(SingleManuscript, siglum=siglum) + folios = get_manuscript.folio_set.prefetch_related("locations_mentioned").all() return render( request, "manuscript_single.html", { - "manuscript": manuscript, + "manuscript": get_manuscript, "folios": folios, - "iiif_manifest": manuscript.iiif_url, + "iiif_manifest": get_manuscript.iiif_url, }, ) + + +def toponyms(request: HttpRequest): + toponym_objs = Location.objects.all() + return render(request, "toponyms.html", {"toponyms": toponym_objs}) + + +def toponym(request: HttpRequest, toponym_param: str): + filtered_toponym = get_object_or_404(Location, toponym=toponym_param) + filtered_manuscript = get_object_or_404( + SingleManuscript, folio__locations_mentioned__toponym=toponym_param + ) + return render( + request, + "toponym.html", + {"toponym": filtered_toponym, "manuscript": filtered_manuscript}, + ) diff --git a/templates/manuscript_single.html b/templates/manuscript_single.html index 78f364c..459f296 100644 --- a/templates/manuscript_single.html +++ b/templates/manuscript_single.html @@ -18,14 +18,7 @@

Related Toponyms

{% for folio in folios %} -
Folio {{ folio.folio_number }}
- +

Folio {{ folio.folio_number }}: {% for location in folio.locations_mentioned.all %}{{ location.country }}{% empty %}No related toponyms.{% endfor %}

{% empty %}

No related folios.

{% endfor %} diff --git a/templates/toponym_single.html b/templates/toponym_single.html new file mode 100644 index 0000000..e5fd31a --- /dev/null +++ b/templates/toponym_single.html @@ -0,0 +1,28 @@ +{% extends "base.html" %} +{% load static %} + +{% block title %}Toponym - La Sfera{% endblock title %} + +{% block content %} + +
+
+
+

+ Manuscripts with the toponym {{ toponym.location.country}} +

+ + {% for manuscript in manuscripts %} +

+ {{ manuscript.siglum }} +

+ {% empty %} +

No manuscripts with this toponym.

+ {% endfor %} + +
+
+{% endblock content %} + +{% block scripts %} +{% endblock scripts %} \ No newline at end of file