diff --git a/backend/event/admin.py b/backend/event/admin.py index 428a4e78..80429ac0 100644 --- a/backend/event/admin.py +++ b/backend/event/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin +from source.admin import ReferenceInlineAdmin from . import models @@ -46,6 +47,7 @@ class LetterActionAdmin(admin.ModelAdmin): LetterActionCategoryAdmin, EventDateAdmin, RoleAdmin, + ReferenceInlineAdmin, ] exclude = ["letters"] diff --git a/backend/letter/admin.py b/backend/letter/admin.py index 75bc2eb9..b0b681d8 100644 --- a/backend/letter/admin.py +++ b/backend/letter/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin +from source.admin import ReferenceInlineAdmin from . import models @@ -37,4 +38,5 @@ class LetterAdmin(admin.ModelAdmin): LetterMaterialAdmin, LetterSenderAdmin, LetterAddresseesAdmin, + ReferenceInlineAdmin, ] diff --git a/backend/person/admin.py b/backend/person/admin.py index 23600cc1..d098972a 100644 --- a/backend/person/admin.py +++ b/backend/person/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin +from source.admin import ReferenceInlineAdmin from . import models @@ -35,6 +36,7 @@ class PersonAdmin(admin.ModelAdmin): OccupationAdmin, PersonDateOfBirthAdmin, PersonDateOfDeathAdmin, + ReferenceInlineAdmin, ] diff --git a/backend/source/admin.py b/backend/source/admin.py index d6366570..57f97210 100644 --- a/backend/source/admin.py +++ b/backend/source/admin.py @@ -1,7 +1,18 @@ from django.contrib import admin +from django.contrib.contenttypes.admin import GenericStackedInline from . import models - @admin.register(models.Source) class SourceAdmin(admin.ModelAdmin): fields = ["name", "bibliographical_info"] + + +class ReferenceInlineAdmin(GenericStackedInline): + model = models.Reference + fields = [ + "source", + "location", + "terminology", + "mention", + ] + extra = 0 diff --git a/backend/source/models.py b/backend/source/models.py index a1ea67e3..50b45f14 100644 --- a/backend/source/models.py +++ b/backend/source/models.py @@ -71,5 +71,8 @@ class Reference(models.Model): help_text="how is this entity presented in the text?", ) + def __str__(self): + return f"reference to {self.content_object} ({self.content_type.model}) in {self.source}" + class Meta: indexes = [models.Index(fields=["content_type", "object_id"])]