Skip to content

Commit

Permalink
add summary and categories to event description
Browse files Browse the repository at this point in the history
  • Loading branch information
lukavdplas committed Apr 18, 2024
1 parent 7c7ac71 commit a296c06
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
18 changes: 18 additions & 0 deletions backend/event/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
from core import admin as core_admin


@admin.register(models.EventCategory)
class EventCategoryAdmin(admin.ModelAdmin):
list_display = ["name", "description"]
search_fields = ["name", "description"]


class EventDescriptionAgentAdmin(admin.StackedInline):
model = models.EventDescriptionAgent
fields = ["agent"] + core_admin.description_field_fields
Expand Down Expand Up @@ -33,6 +39,18 @@ class EventDescriptionSpaceAdmin(admin.StackedInline):

@admin.register(models.EventDescription)
class EventDescriptionAdmin(core_admin.EntityDescriptionAdmin, admin.ModelAdmin):
filter_horizontal = ["categories"]
list_filter = ["source", "categories"]
fieldsets = [
core_admin.named_fieldset,
core_admin.description_source_fieldset,
(
"Contents",
{
"fields": ["summary", "categories"],
},
),
]
inlines = [
EventDescriptionAgentAdmin,
EventDescriptionGiftAdmin,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 4.2.7 on 2024-04-18 11:45

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('event', '0013_initial'),
]

operations = [
migrations.CreateModel(
name='EventCategory',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='A name to help identify this object', max_length=200)),
('description', models.TextField(blank=True, help_text='Longer description to help identify this object')),
],
options={
'abstract': False,
},
),
migrations.AddField(
model_name='eventdescription',
name='summary',
field=models.TextField(blank=True, help_text='full description of the events in the passage'),
),
migrations.AddField(
model_name='eventdescription',
name='categories',
field=models.ManyToManyField(help_text='labels assigned to this event', related_name='event_descriptions', to='event.eventcategory'),
),
]
16 changes: 15 additions & 1 deletion backend/event/models.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
from django.db import models
from django.core.exceptions import ValidationError

from core.models import EntityDescription, DescriptionField
from core.models import EntityDescription, DescriptionField, Named
from person.models import AgentDescription
from letter.models import GiftDescription, LetterDescription
from space.models import SpaceDescription


class EventCategory(Named):
class Meta:
verbose_name_plural = "event categories"


class EventDescription(EntityDescription, models.Model):
"""
An epistolary event described in as source text
"""

summary = models.TextField(
blank=True,
help_text="full description of the events in the passage",
)
categories = models.ManyToManyField(
to=EventCategory,
related_name="event_descriptions",
help_text="labels assigned to this event",
)
agents = models.ManyToManyField(
to=AgentDescription,
through="EventDescriptionAgent",
Expand Down

0 comments on commit a296c06

Please sign in to comment.