death descriptions
- SHA
96bb19ab67f85f2e45f778d7c4c3691c6f769438- Parents
-
b8b500c - Tree
17499e1
96bb19a
96bb19ab67f85f2e45f778d7c4c3691c6f769438b8b500c
17499e1| Status | File | + | - |
|---|---|---|---|
| M |
memorial/admin.py
|
11 | 2 |
| A |
memorial/migrations/0003_person_death_description.py
|
21 | 0 |
| M |
memorial/models.py
|
6 | 0 |
| M |
memorial/serializers.py
|
3 | 2 |
memorial/admin.pymodified@@ -49,7 +49,7 @@ class ConflictAdmin(admin.ModelAdmin): | ||
| 49 | 49 | @admin.register(Person) |
| 50 | 50 | class PersonAdmin(admin.ModelAdmin): |
| 51 | 51 | form = PersonAdminForm |
| 52 | - list_display = ['display_name', 'class_year', 'conflict', 'rank', 'date_of_death', 'has_pdf'] | |
| 52 | + list_display = ['display_name', 'class_year', 'conflict', 'rank', 'date_of_death', 'has_pdf', 'has_description'] | |
| 53 | 53 | list_filter = ['conflict', 'class_year', 'rank'] |
| 54 | 54 | search_fields = ['first_name', 'last_name', 'unit'] |
| 55 | 55 | autocomplete_fields = ['conflict'] |
@@ -64,6 +64,10 @@ class PersonAdmin(admin.ModelAdmin): | ||
| 64 | 64 | ('Military Information', { |
| 65 | 65 | 'fields': ('conflict', 'rank', 'unit', 'date_of_death') |
| 66 | 66 | }), |
| 67 | + ('Death Details', { | |
| 68 | + 'fields': ('death_description',), | |
| 69 | + 'classes': ('wide',), # Makes the text field wider | |
| 70 | + }), | |
| 67 | 71 | ('Memorial Content', { |
| 68 | 72 | 'fields': ('pdf_file', 'pdf_key'), |
| 69 | 73 | 'description': 'Upload a PDF or view the current S3 key' |
@@ -75,4 +79,9 @@ class PersonAdmin(admin.ModelAdmin): | ||
| 75 | 79 | def has_pdf(self, obj): |
| 76 | 80 | return bool(obj.pdf_key) |
| 77 | 81 | has_pdf.boolean = True |
| 78 | - has_pdf.short_description = 'Has PDF' | |
| 82 | + has_pdf.short_description = 'Has PDF' | |
| 83 | + | |
| 84 | + def has_description(self, obj): | |
| 85 | + return bool(obj.death_description) | |
| 86 | + has_description.boolean = True | |
| 87 | + has_description.short_description = 'Has Description' | |
memorial/migrations/0003_person_death_description.pyadded@@ -0,0 +1,21 @@ | ||
| 1 | +# Generated by Django 5.0.6 on 2025-07-14 19:07 | |
| 2 | + | |
| 3 | +from django.db import migrations, models | |
| 4 | + | |
| 5 | + | |
| 6 | +class Migration(migrations.Migration): | |
| 7 | + | |
| 8 | + dependencies = [ | |
| 9 | + ("memorial", "0002_person_class_year"), | |
| 10 | + ] | |
| 11 | + | |
| 12 | + operations = [ | |
| 13 | + migrations.AddField( | |
| 14 | + model_name="person", | |
| 15 | + name="death_description", | |
| 16 | + field=models.TextField( | |
| 17 | + blank=True, | |
| 18 | + help_text="Description of how this person died (e.g., 'Killed in action during the Battle of Normandy')", | |
| 19 | + ), | |
| 20 | + ), | |
| 21 | + ] | |
memorial/models.pymodified@@ -48,6 +48,12 @@ class Person(models.Model): | ||
| 48 | 48 | unit = models.CharField(max_length=200, blank=True) |
| 49 | 49 | date_of_death = models.DateField(null=True, blank=True) |
| 50 | 50 | |
| 51 | + # Death details | |
| 52 | + death_description = models.TextField( | |
| 53 | + blank=True, | |
| 54 | + help_text="Description of how this person died (e.g., 'Killed in action during the Battle of Normandy')" | |
| 55 | + ) | |
| 56 | + | |
| 51 | 57 | # Memorial content |
| 52 | 58 | pdf_key = models.CharField( |
| 53 | 59 | max_length=500, |
memorial/serializers.pymodified@@ -9,7 +9,7 @@ class PersonListSerializer(serializers.ModelSerializer): | ||
| 9 | 9 | |
| 10 | 10 | class Meta: |
| 11 | 11 | model = Person |
| 12 | - fields = ['id', 'display_name', 'full_display_name', 'rank', 'unit', 'class_year'] | |
| 12 | + fields = ['id', 'display_name', 'full_display_name', 'rank', 'unit', 'class_year', 'death_description'] | |
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | class PersonDetailSerializer(serializers.ModelSerializer): |
@@ -24,7 +24,8 @@ class PersonDetailSerializer(serializers.ModelSerializer): | ||
| 24 | 24 | fields = [ |
| 25 | 25 | 'id', 'first_name', 'middle_name', 'last_name', 'suffix', |
| 26 | 26 | 'display_name', 'full_display_name', 'class_year', 'rank', 'unit', |
| 27 | - 'date_of_death', 'conflict', 'conflict_name', 'pdf_key', 'pdf_url' | |
| 27 | + 'date_of_death', 'death_description', 'conflict', 'conflict_name', | |
| 28 | + 'pdf_key', 'pdf_url' | |
| 28 | 29 | ] |
| 29 | 30 | |
| 30 | 31 | def get_pdf_url(self, obj): |