vmi-virtual-memorial/vmi-wd-backend / 96bb19a

Browse files

death descriptions

Authored by espadonne
SHA
96bb19ab67f85f2e45f778d7c4c3691c6f769438
Parents
b8b500c
Tree
17499e1

4 changed files

StatusFile+-
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):
4949
 @admin.register(Person)
5050
 class PersonAdmin(admin.ModelAdmin):
5151
     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']
5353
     list_filter = ['conflict', 'class_year', 'rank']
5454
     search_fields = ['first_name', 'last_name', 'unit']
5555
     autocomplete_fields = ['conflict']
@@ -64,6 +64,10 @@ class PersonAdmin(admin.ModelAdmin):
6464
         ('Military Information', {
6565
             'fields': ('conflict', 'rank', 'unit', 'date_of_death')
6666
         }),
67
+        ('Death Details', {
68
+            'fields': ('death_description',),
69
+            'classes': ('wide',),  # Makes the text field wider
70
+        }),
6771
         ('Memorial Content', {
6872
             'fields': ('pdf_file', 'pdf_key'),
6973
             'description': 'Upload a PDF or view the current S3 key'
@@ -75,4 +79,9 @@ class PersonAdmin(admin.ModelAdmin):
7579
     def has_pdf(self, obj):
7680
         return bool(obj.pdf_key)
7781
     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):
4848
     unit = models.CharField(max_length=200, blank=True)
4949
     date_of_death = models.DateField(null=True, blank=True)
5050
     
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
+    
5157
     # Memorial content
5258
     pdf_key = models.CharField(
5359
         max_length=500, 
memorial/serializers.pymodified
@@ -9,7 +9,7 @@ class PersonListSerializer(serializers.ModelSerializer):
99
     
1010
     class Meta:
1111
         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']
1313
 
1414
 
1515
 class PersonDetailSerializer(serializers.ModelSerializer):
@@ -24,7 +24,8 @@ class PersonDetailSerializer(serializers.ModelSerializer):
2424
         fields = [
2525
             'id', 'first_name', 'middle_name', 'last_name', 'suffix',
2626
             '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'
2829
         ]
2930
     
3031
     def get_pdf_url(self, obj):