Skip to content

Commit

Permalink
feat: Added pages, view, and url for toponyms
Browse files Browse the repository at this point in the history
  • Loading branch information
hepplerj committed Jun 10, 2024
1 parent 6a8590c commit d8e5fda
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 15 deletions.
2 changes: 2 additions & 0 deletions manuscript/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
path("", views.index, name="index"),
path("manuscripts/", views.manuscripts, name="manuscripts"),
path("manuscripts/<str:siglum>/", views.manuscript, name="manuscript"),
path("toponyms/", views.toponyms, name="toponyms"),
path("toponyms/<int:pk>/", views.toponym, name="toponym"),
path("stanzas/", views.stanzas, name="stanzas"),
]
31 changes: 24 additions & 7 deletions manuscript/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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},
)
9 changes: 1 addition & 8 deletions templates/manuscript_single.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ <h3 class="text-2xl pb-8" id="text">

<h4 class="text-xl pt-8">Related Toponyms</h4>
{% for folio in folios %}
<h5>Folio {{ folio.folio_number }}</h5>
<ul>
{% for location in folio.locations_mentioned.all %}
<li>{{ location.country }}</li>
{% empty %}
<li>No related toponyms.</li>
{% endfor %}
</ul>
<p class="pb-1">Folio {{ folio.folio_number }}: {% for location in folio.locations_mentioned.all %}<a href="#" class="underline hover:no-underline">{{ location.country }}</a>{% empty %}No related toponyms.{% endfor %}<br></p>
{% empty %}
<p>No related folios.</p>
{% endfor %}
Expand Down
28 changes: 28 additions & 0 deletions templates/toponym_single.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% extends "base.html" %}
{% load static %}

{% block title %}Toponym - La Sfera{% endblock title %}

{% block content %}

<div class="flex justify-center mx-auto container">
<section id="toponym" class="flex flex-col md:flex-row w-full p-4 my-10">
<div class="w-full md:w-2/5 p-2">
<h3 class="text-2xl pb-8" id="text">
Manuscripts with the toponym {{ toponym.location.country}}
</h3>

{% for manuscript in manuscripts %}
<p class="pb-1">
<a href="/manuscripts/{{ manuscript.siglum }}" class="underline hover:no-underline">{{ manuscript.siglum }}</a>
</p>
{% empty %}
<p>No manuscripts with this toponym.</p>
{% endfor %}

</section>
</div>
{% endblock content %}

{% block scripts %}
{% endblock scripts %}

0 comments on commit d8e5fda

Please sign in to comment.