From 2366eecf6b387ccb48cf3b49cfefa8e9a6d5dd29 Mon Sep 17 00:00:00 2001 From: Dylan Hillerbrand Date: Wed, 28 Aug 2024 16:11:21 -0400 Subject: [PATCH 1/2] feat(chant detail): show chant project when it exists --- django/cantusdb_project/main_app/models/project.py | 2 +- .../cantusdb_project/main_app/templates/chant_detail.html | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/django/cantusdb_project/main_app/models/project.py b/django/cantusdb_project/main_app/models/project.py index bba9ca3e0..025664262 100644 --- a/django/cantusdb_project/main_app/models/project.py +++ b/django/cantusdb_project/main_app/models/project.py @@ -13,4 +13,4 @@ class Project(BaseModel): name = models.CharField(max_length=63) def __str__(self): - return f"{self.name} ({self.id})" + return f"{self.name}" diff --git a/django/cantusdb_project/main_app/templates/chant_detail.html b/django/cantusdb_project/main_app/templates/chant_detail.html index e83585a83..022f48101 100644 --- a/django/cantusdb_project/main_app/templates/chant_detail.html +++ b/django/cantusdb_project/main_app/templates/chant_detail.html @@ -65,6 +65,13 @@

{{ chant.incipit }}

{{ chant.c_sequence }}
{% endif %} + + {% if chant.project %} +
+
Project
+
{{ chant.project }}
+
+ {% endif %}
From 8691030d1334ba6ce0a44a5a9987d9badc9cbea8 Mon Sep 17 00:00:00 2001 From: Dylan Hillerbrand Date: Wed, 28 Aug 2024 16:17:54 -0400 Subject: [PATCH 2/2] fix(chant detail): select_related on project relationship --- django/cantusdb_project/main_app/views/chant.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django/cantusdb_project/main_app/views/chant.py b/django/cantusdb_project/main_app/views/chant.py index f5be3d7b7..4bb38dc16 100644 --- a/django/cantusdb_project/main_app/views/chant.py +++ b/django/cantusdb_project/main_app/views/chant.py @@ -186,7 +186,7 @@ class ChantDetailView(DetailView): def get_queryset(self) -> QuerySet: qs = super().get_queryset() return qs.select_related( - "source__holding_institution", "service", "genre", "feast" + "source__holding_institution", "service", "genre", "feast", "project" ) def get_context_data(self, **kwargs):