Skip to content

Commit

Permalink
add references to admin
Browse files Browse the repository at this point in the history
  • Loading branch information
lukavdplas committed Feb 9, 2024
1 parent fff75fd commit 73dbcc1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions backend/event/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.contrib import admin
from source.admin import ReferenceInlineAdmin
from . import models


Expand Down Expand Up @@ -46,6 +47,7 @@ class LetterActionAdmin(admin.ModelAdmin):
LetterActionCategoryAdmin,
EventDateAdmin,
RoleAdmin,
ReferenceInlineAdmin,
]
exclude = ["letters"]

Expand Down
2 changes: 2 additions & 0 deletions backend/letter/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.contrib import admin
from source.admin import ReferenceInlineAdmin
from . import models


Expand Down Expand Up @@ -37,4 +38,5 @@ class LetterAdmin(admin.ModelAdmin):
LetterMaterialAdmin,
LetterSenderAdmin,
LetterAddresseesAdmin,
ReferenceInlineAdmin,
]
2 changes: 2 additions & 0 deletions backend/person/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.contrib import admin
from source.admin import ReferenceInlineAdmin
from . import models


Expand Down Expand Up @@ -35,6 +36,7 @@ class PersonAdmin(admin.ModelAdmin):
OccupationAdmin,
PersonDateOfBirthAdmin,
PersonDateOfDeathAdmin,
ReferenceInlineAdmin,
]


Expand Down
13 changes: 12 additions & 1 deletion backend/source/admin.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions backend/source/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])]

0 comments on commit 73dbcc1

Please sign in to comment.