From c50f016547ceeba4d75b1f7be6c2e5752973daf0 Mon Sep 17 00:00:00 2001 From: Luka van der Plas Date: Mon, 15 Apr 2024 14:33:30 +0200 Subject: [PATCH] add key persons + key sites to case study --- backend/case_study/admin.py | 4 +-- ...sestudy_key_persons_casestudy_key_sites.py | 25 +++++++++++++++++++ backend/case_study/models.py | 15 ++++++++++- 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 backend/case_study/migrations/0003_casestudy_key_persons_casestudy_key_sites.py diff --git a/backend/case_study/admin.py b/backend/case_study/admin.py index 4b97fc1a..415c4530 100644 --- a/backend/case_study/admin.py +++ b/backend/case_study/admin.py @@ -5,8 +5,8 @@ @admin.register(models.CaseStudy) class CaseStudyAdmin(admin.ModelAdmin): list_display = ["name", "description"] - fields = ["name", "description", "episodes"] - filter_horizontal = ["episodes"] + fields = ["name", "description", "episodes", "key_persons", "key_sites"] + filter_horizontal = ["episodes", "key_persons", "key_sites"] @admin.register(models.Episode) diff --git a/backend/case_study/migrations/0003_casestudy_key_persons_casestudy_key_sites.py b/backend/case_study/migrations/0003_casestudy_key_persons_casestudy_key_sites.py new file mode 100644 index 00000000..a4af114c --- /dev/null +++ b/backend/case_study/migrations/0003_casestudy_key_persons_casestudy_key_sites.py @@ -0,0 +1,25 @@ +# Generated by Django 4.2.7 on 2024-04-15 12:31 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('person', '0014_alter_persondateofbirth_person_and_more'), + ('space', '0008_alter_spacedescription_source'), + ('case_study', '0002_casestudy_description_alter_casestudy_name_episode_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='casestudy', + name='key_persons', + field=models.ManyToManyField(blank=True, help_text='Key historical figures involved in this case study', to='person.historicalperson'), + ), + migrations.AddField( + model_name='casestudy', + name='key_sites', + field=models.ManyToManyField(blank=True, help_text='Key historical sites involved in this case study', to='space.structure'), + ), + ] diff --git a/backend/case_study/models.py b/backend/case_study/models.py index b7beb42e..3f928eeb 100644 --- a/backend/case_study/models.py +++ b/backend/case_study/models.py @@ -1,7 +1,8 @@ from django.db import models from core.models import Named from event.models import EventDescription - +from person.models import HistoricalPerson +from space.models import Structure class CaseStudy(Named, models.Model): """ @@ -18,6 +19,18 @@ class Meta: help_text="Episodes involved in this case study", ) + key_persons = models.ManyToManyField( + to=HistoricalPerson, + blank=True, + help_text="Key historical figures involved in this case study", + ) + + key_sites = models.ManyToManyField( + to=Structure, + blank=True, + help_text="Key historical sites involved in this case study", + ) + def __str__(self): return self.name