From cecae328ae7dcd6527b8eb4dcdd342c087ba061f Mon Sep 17 00:00:00 2001 From: sandeshit Date: Mon, 22 Jun 2026 15:03:47 +0545 Subject: [PATCH 1/4] feat(dref-summary): add new model and register for translation. - Create new model DrefSummary. - Register for translation. - Create migrations. --- dref/admin.py | 47 ++++++- dref/migrations/0090_drefsummary.py | 30 +++++ ...mmary_challenges_identified_ar_and_more.py | 123 ++++++++++++++++++ dref/models.py | 52 ++++++++ dref/translation.py | 12 ++ 5 files changed, 263 insertions(+), 1 deletion(-) create mode 100644 dref/migrations/0090_drefsummary.py create mode 100644 dref/migrations/0091_drefsummary_challenges_identified_ar_and_more.py diff --git a/dref/admin.py b/dref/admin.py index 02e84fa7e..5ae9d5a42 100644 --- a/dref/admin.py +++ b/dref/admin.py @@ -1,13 +1,14 @@ from django.contrib import admin from reversion_compare.admin import CompareVersionAdmin -from lang.admin import TranslationAdmin +from lang.admin import TranslationAdmin, TranslationInlineModelAdmin from .models import ( Dref, DrefFile, DrefFinalReport, DrefOperationalUpdate, + DrefSummary, IdentifiedNeed, NationalSocietyAction, PlannedIntervention, @@ -125,8 +126,31 @@ class SourceInformationAdmin(admin.ModelAdmin): search_fields = ("source_name",) +class DrefSummaryInline(admin.StackedInline, TranslationInlineModelAdmin): + model = DrefSummary + extra = 0 + readonly_fields = ( + "status", + "hash", + "created_at", + "updated_at", + ) + fields = ( + "status", + "hash", + "situational_overview", + "operational_strategy", + "people_centered_approach", + "challenges_identified", + "lessons_learned", + "created_at", + "updated_at", + ) + + @admin.register(Dref) class DrefAdmin(CompareVersionAdmin, TranslationAdmin, admin.ModelAdmin): + inlines = [DrefSummaryInline] search_fields = ("title", "appeal_code") list_display = ( "title", @@ -301,3 +325,24 @@ def save_model(self, request, obj, form, change): @admin.register(ProposedAction) class ProposedActionAdmin(ReadOnlyMixin, admin.ModelAdmin): search_fields = ["action"] + + +@admin.register(DrefSummary) +class DrefSummaryAdmin(TranslationAdmin, admin.ModelAdmin): + list_display = ("dref", "status", "created_at", "updated_at") + list_filter = ("status",) + search_fields = ("dref__title", "dref__appeal_code") + readonly_fields = ("hash", "created_at", "updated_at") + autocomplete_fields = ("dref",) + fields = ( + "dref", + "status", + "hash", + "situational_overview", + "operational_strategy", + "people_centered_approach", + "challenges_identified", + "lessons_learned", + "created_at", + "updated_at", + ) diff --git a/dref/migrations/0090_drefsummary.py b/dref/migrations/0090_drefsummary.py new file mode 100644 index 000000000..8548f3564 --- /dev/null +++ b/dref/migrations/0090_drefsummary.py @@ -0,0 +1,30 @@ +# Generated by Django 4.2.30 on 2026-06-22 05:01 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('dref', '0089_remove_dref_field_report_dref_event'), + ] + + operations = [ + migrations.CreateModel( + name='DrefSummary', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), + ('hash', models.CharField(max_length=64, unique=True)), + ('situational_overview', models.TextField(blank=True, null=True)), + ('operational_strategy', models.TextField(blank=True, null=True)), + ('people_centered_approach', models.TextField(blank=True, null=True)), + ('challenges_identified', models.TextField(blank=True, null=True)), + ('lessons_learned', models.TextField(blank=True, null=True)), + ('status', models.IntegerField(choices=[(100, 'Pending'), (200, 'Success'), (300, 'Failed')], default=100)), + ('dref', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='summary', to='dref.dref')), + ], + ), + ] diff --git a/dref/migrations/0091_drefsummary_challenges_identified_ar_and_more.py b/dref/migrations/0091_drefsummary_challenges_identified_ar_and_more.py new file mode 100644 index 000000000..0139d1f67 --- /dev/null +++ b/dref/migrations/0091_drefsummary_challenges_identified_ar_and_more.py @@ -0,0 +1,123 @@ +# Generated by Django 4.2.30 on 2026-06-22 08:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dref', '0090_drefsummary'), + ] + + operations = [ + migrations.AddField( + model_name='drefsummary', + name='challenges_identified_ar', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='challenges_identified_en', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='challenges_identified_es', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='challenges_identified_fr', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='lessons_learned_ar', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='lessons_learned_en', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='lessons_learned_es', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='lessons_learned_fr', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='operational_strategy_ar', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='operational_strategy_en', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='operational_strategy_es', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='operational_strategy_fr', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='people_centered_approach_ar', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='people_centered_approach_en', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='people_centered_approach_es', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='people_centered_approach_fr', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='situational_overview_ar', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='situational_overview_en', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='situational_overview_es', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='situational_overview_fr', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='drefsummary', + name='translation_module_original_language', + field=models.CharField(choices=[('en', 'English'), ('es', 'Spanish'), ('fr', 'French'), ('ar', 'Arabic')], default='en', help_text='Language used to create this entity', max_length=2, verbose_name='Entity Original language'), + ), + migrations.AddField( + model_name='drefsummary', + name='translation_module_skip_auto_translation', + field=models.BooleanField(default=False, help_text='Skip auto translation operation for this entity?', verbose_name='Skip auto translation'), + ), + ] diff --git a/dref/models.py b/dref/models.py index 4be868395..7f97bec87 100644 --- a/dref/models.py +++ b/dref/models.py @@ -1700,3 +1700,55 @@ def get_for(user, status=None): if status == Dref.Status.APPROVED: return queryset.filter(status=Dref.Status.APPROVED) return queryset + + +class DrefSummary(models.Model): + + class SummaryStatus(models.IntegerChoices): + PENDING = 100, _("Pending") + SUCCESS = 200, _("Success") + FAILED = 300, _("Failed") + + dref = models.OneToOneField( + Dref, + on_delete=models.CASCADE, + related_name="summary", + ) + + created_at = models.DateTimeField(auto_now_add=True) + updated_at = models.DateTimeField(auto_now=True) + + hash = models.CharField( + max_length=64, + unique=True, + ) + + situational_overview = models.TextField( + blank=True, + null=True, + ) + + operational_strategy = models.TextField( + blank=True, + null=True, + ) + + people_centered_approach = models.TextField( + blank=True, + null=True, + ) + + challenges_identified = models.TextField( + blank=True, + null=True, + ) + + lessons_learned = models.TextField( + blank=True, + null=True, + ) + + status = models.IntegerField( + choices=SummaryStatus.choices, + default=SummaryStatus.PENDING, + ) diff --git a/dref/translation.py b/dref/translation.py index 1c3b29d50..58a7fc986 100644 --- a/dref/translation.py +++ b/dref/translation.py @@ -5,6 +5,7 @@ DrefFile, DrefFinalReport, DrefOperationalUpdate, + DrefSummary, IdentifiedNeed, NationalSocietyAction, PlannedIntervention, @@ -116,6 +117,17 @@ class DrefOperationalUpdateTO(TranslationOptions): ) +@register(DrefSummary) +class DrefSummaryTO(TranslationOptions): + fields = ( + "situational_overview", + "operational_strategy", + "people_centered_approach", + "challenges_identified", + "lessons_learned", + ) + + @register(IdentifiedNeed) class IdentifiedNeedTO(TranslationOptions): fields = ("description",) From 35b66bb5c8daada96490ee4f3b59dd6818251ef2 Mon Sep 17 00:00:00 2001 From: sandeshit Date: Mon, 22 Jun 2026 15:05:46 +0545 Subject: [PATCH 2/4] feat(serializer): create a serializer for summary. --- api/test_views.py | 37 ++++++++++++++++++++++++++++++++++++- assets | 2 +- dref/factories/dref.py | 15 +++++++++++++++ dref/serializers.py | 18 ++++++++++++++++++ 4 files changed, 70 insertions(+), 2 deletions(-) diff --git a/api/test_views.py b/api/test_views.py index 6f215aedc..a54da83a1 100644 --- a/api/test_views.py +++ b/api/test_views.py @@ -31,8 +31,9 @@ DrefFactory, DrefFinalReportFactory, DrefOperationalUpdateFactory, + DrefSummaryFactory, ) -from dref.models import Dref, DrefFile +from dref.models import Dref, DrefFile, DrefSummary from main.test_case import APITestCase from per.factories import OpsLearningFactory @@ -1535,3 +1536,37 @@ def test_dref_operational_update_with_timeline_ops_updates(self): self.assertIsNotNone(dref_data) self.assertIsNotNone(dref_data["final_report_details"]) self.assertEqual(len(dref_data["timeline_operational_updates"]), 3) + + def test_dref_summary_fields_present_when_summary_exists(self): + event = EventFactory.create(dtype=self.disaster_type) + dref = self._approved_dref(event) + DrefSummaryFactory.create( + dref=dref, + status=DrefSummary.SummaryStatus.SUCCESS, + situational_overview="overview text", + operational_strategy="strategy text", + people_centered_approach="approach text", + challenges_identified="challenges text", + lessons_learned="lessons text", + ) + + data = self._get(event).data + + self.assertEqual(data["stage"], EventStage.DREF_APPLICATION) + summary = data["dref"]["summary"] + self.assertIsNotNone(summary) + self.assertEqual(summary["status"], DrefSummary.SummaryStatus.SUCCESS) + self.assertEqual(summary["situational_overview"], "overview text") + self.assertEqual(summary["operational_strategy"], "strategy text") + self.assertEqual(summary["people_centered_approach"], "approach text") + self.assertEqual(summary["challenges_identified"], "challenges text") + self.assertEqual(summary["lessons_learned"], "lessons text") + + def test_dref_summary_is_none_when_no_summary_exists(self): + event = EventFactory.create(dtype=self.disaster_type) + self._approved_dref(event) + + data = self._get(event).data + + self.assertEqual(data["stage"], EventStage.DREF_APPLICATION) + self.assertIsNone(data["dref"]["summary"]) diff --git a/assets b/assets index 780b7a6c0..3b248f67d 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 780b7a6c0efc7b6e353015308c701be2d7c2c419 +Subproject commit 3b248f67db1f055d24cb7d50ceaa5346b0cba330 diff --git a/dref/factories/dref.py b/dref/factories/dref.py index ceabd59d0..27d69c417 100644 --- a/dref/factories/dref.py +++ b/dref/factories/dref.py @@ -9,6 +9,7 @@ DrefFile, DrefFinalReport, DrefOperationalUpdate, + DrefSummary, IdentifiedNeed, NationalSocietyAction, PlannedIntervention, @@ -198,3 +199,17 @@ class Meta: model = ProposedAction proposed_type = fuzzy.FuzzyChoice(ProposedAction.Action) + + +class DrefSummaryFactory(factory.django.DjangoModelFactory): + class Meta: + model = DrefSummary + + dref = factory.SubFactory(DrefFactory) + hash = factory.Sequence(lambda n: f"{n:064d}") + status = DrefSummary.SummaryStatus.SUCCESS + situational_overview = fuzzy.FuzzyText(length=100) + operational_strategy = fuzzy.FuzzyText(length=100) + people_centered_approach = fuzzy.FuzzyText(length=100) + challenges_identified = fuzzy.FuzzyText(length=100) + lessons_learned = fuzzy.FuzzyText(length=100) diff --git a/dref/serializers.py b/dref/serializers.py index 2a6525e57..55824c3db 100644 --- a/dref/serializers.py +++ b/dref/serializers.py @@ -25,6 +25,7 @@ DrefFile, DrefFinalReport, DrefOperationalUpdate, + DrefSummary, IdentifiedNeed, NationalSocietyAction, PlannedIntervention, @@ -2427,6 +2428,20 @@ def get_dref_contacts(self, obj): return get_dref_emergency_contacts(obj) +class DrefSummarySerializer(serializers.ModelSerializer): + class Meta: + model = DrefSummary + fields = ( + "id", + "status", + "situational_overview", + "operational_strategy", + "people_centered_approach", + "challenges_identified", + "lessons_learned", + ) + + class EmergencyDrefSerializer(serializers.ModelSerializer): status_display = serializers.CharField(source="get_status_display", read_only=True) country_details = MiniCountrySerializer(source="country", read_only=True) @@ -2436,6 +2451,7 @@ class EmergencyDrefSerializer(serializers.ModelSerializer): cover_image_file = DrefFileSerializer(source="cover_image", required=False, allow_null=True) disaster_type_details = DisasterTypeSerializer(source="disaster_type", read_only=True) type_of_dref_display = serializers.CharField(source="get_type_of_dref_display", read_only=True) + summary = DrefSummarySerializer(read_only=True) # Dref operational update operational_update_details = serializers.SerializerMethodField() @@ -2498,6 +2514,8 @@ class Meta: "timeline_operational_updates", # Contacts "dref_contacts", + # Summary + "summary", ) @extend_schema_field(TimelineEmergencyDrefOperationalUpdateSerializer(many=True)) From 37341e5b1651aa3e5464d732c62fc9e65c8b257c Mon Sep 17 00:00:00 2001 From: sandeshit Date: Fri, 26 Jun 2026 08:07:53 +0545 Subject: [PATCH 3/4] fixup! feat(serializer): create a serializer for summary. --- assets | 2 +- dref/admin.py | 8 +- dref/migrations/0090_drefsummary.py | 30 ++++- ...mmary_challenges_identified_ar_and_more.py | 123 ------------------ dref/models.py | 7 +- dref/serializers.py | 2 +- 6 files changed, 36 insertions(+), 136 deletions(-) delete mode 100644 dref/migrations/0091_drefsummary_challenges_identified_ar_and_more.py diff --git a/assets b/assets index 3b248f67d..5fbdb9ac6 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 3b248f67db1f055d24cb7d50ceaa5346b0cba330 +Subproject commit 5fbdb9ac6ad83472709f248c4bbe32a70587b577 diff --git a/dref/admin.py b/dref/admin.py index 5ae9d5a42..8ff4f67ce 100644 --- a/dref/admin.py +++ b/dref/admin.py @@ -131,13 +131,13 @@ class DrefSummaryInline(admin.StackedInline, TranslationInlineModelAdmin): extra = 0 readonly_fields = ( "status", - "hash", + "prompt_hash", "created_at", "updated_at", ) fields = ( "status", - "hash", + "prompt_hash", "situational_overview", "operational_strategy", "people_centered_approach", @@ -332,12 +332,12 @@ class DrefSummaryAdmin(TranslationAdmin, admin.ModelAdmin): list_display = ("dref", "status", "created_at", "updated_at") list_filter = ("status",) search_fields = ("dref__title", "dref__appeal_code") - readonly_fields = ("hash", "created_at", "updated_at") + readonly_fields = ("prompt_hash", "created_at", "updated_at") autocomplete_fields = ("dref",) fields = ( "dref", "status", - "hash", + "prompt_hash", "situational_overview", "operational_strategy", "people_centered_approach", diff --git a/dref/migrations/0090_drefsummary.py b/dref/migrations/0090_drefsummary.py index 8548f3564..e68b40311 100644 --- a/dref/migrations/0090_drefsummary.py +++ b/dref/migrations/0090_drefsummary.py @@ -1,7 +1,7 @@ -# Generated by Django 4.2.30 on 2026-06-22 05:01 +# Generated by Django 5.2.14 on 2026-06-26 02:06 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): @@ -17,13 +17,35 @@ class Migration(migrations.Migration): ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), - ('hash', models.CharField(max_length=64, unique=True)), + ('prompt_hash', models.CharField(max_length=64, unique=True)), ('situational_overview', models.TextField(blank=True, null=True)), + ('situational_overview_en', models.TextField(blank=True, null=True)), + ('situational_overview_es', models.TextField(blank=True, null=True)), + ('situational_overview_fr', models.TextField(blank=True, null=True)), + ('situational_overview_ar', models.TextField(blank=True, null=True)), ('operational_strategy', models.TextField(blank=True, null=True)), + ('operational_strategy_en', models.TextField(blank=True, null=True)), + ('operational_strategy_es', models.TextField(blank=True, null=True)), + ('operational_strategy_fr', models.TextField(blank=True, null=True)), + ('operational_strategy_ar', models.TextField(blank=True, null=True)), ('people_centered_approach', models.TextField(blank=True, null=True)), + ('people_centered_approach_en', models.TextField(blank=True, null=True)), + ('people_centered_approach_es', models.TextField(blank=True, null=True)), + ('people_centered_approach_fr', models.TextField(blank=True, null=True)), + ('people_centered_approach_ar', models.TextField(blank=True, null=True)), ('challenges_identified', models.TextField(blank=True, null=True)), + ('challenges_identified_en', models.TextField(blank=True, null=True)), + ('challenges_identified_es', models.TextField(blank=True, null=True)), + ('challenges_identified_fr', models.TextField(blank=True, null=True)), + ('challenges_identified_ar', models.TextField(blank=True, null=True)), ('lessons_learned', models.TextField(blank=True, null=True)), - ('status', models.IntegerField(choices=[(100, 'Pending'), (200, 'Success'), (300, 'Failed')], default=100)), + ('lessons_learned_en', models.TextField(blank=True, null=True)), + ('lessons_learned_es', models.TextField(blank=True, null=True)), + ('lessons_learned_fr', models.TextField(blank=True, null=True)), + ('lessons_learned_ar', models.TextField(blank=True, null=True)), + ('status', models.IntegerField(choices=[(100, 'Pending'), (200, 'Processing'), (300, 'Success'), (400, 'Failed')], default=100)), + ('translation_module_original_language', models.CharField(choices=[('en', 'English'), ('es', 'Spanish'), ('fr', 'French'), ('ar', 'Arabic')], default='en', help_text='Language used to create this entity', max_length=2, verbose_name='Entity Original language')), + ('translation_module_skip_auto_translation', models.BooleanField(default=False, help_text='Skip auto translation operation for this entity?', verbose_name='Skip auto translation')), ('dref', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='summary', to='dref.dref')), ], ), diff --git a/dref/migrations/0091_drefsummary_challenges_identified_ar_and_more.py b/dref/migrations/0091_drefsummary_challenges_identified_ar_and_more.py deleted file mode 100644 index 0139d1f67..000000000 --- a/dref/migrations/0091_drefsummary_challenges_identified_ar_and_more.py +++ /dev/null @@ -1,123 +0,0 @@ -# Generated by Django 4.2.30 on 2026-06-22 08:40 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('dref', '0090_drefsummary'), - ] - - operations = [ - migrations.AddField( - model_name='drefsummary', - name='challenges_identified_ar', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='challenges_identified_en', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='challenges_identified_es', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='challenges_identified_fr', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='lessons_learned_ar', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='lessons_learned_en', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='lessons_learned_es', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='lessons_learned_fr', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='operational_strategy_ar', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='operational_strategy_en', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='operational_strategy_es', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='operational_strategy_fr', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='people_centered_approach_ar', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='people_centered_approach_en', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='people_centered_approach_es', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='people_centered_approach_fr', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='situational_overview_ar', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='situational_overview_en', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='situational_overview_es', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='situational_overview_fr', - field=models.TextField(blank=True, null=True), - ), - migrations.AddField( - model_name='drefsummary', - name='translation_module_original_language', - field=models.CharField(choices=[('en', 'English'), ('es', 'Spanish'), ('fr', 'French'), ('ar', 'Arabic')], default='en', help_text='Language used to create this entity', max_length=2, verbose_name='Entity Original language'), - ), - migrations.AddField( - model_name='drefsummary', - name='translation_module_skip_auto_translation', - field=models.BooleanField(default=False, help_text='Skip auto translation operation for this entity?', verbose_name='Skip auto translation'), - ), - ] diff --git a/dref/models.py b/dref/models.py index 7f97bec87..8d2f9280a 100644 --- a/dref/models.py +++ b/dref/models.py @@ -1706,8 +1706,9 @@ class DrefSummary(models.Model): class SummaryStatus(models.IntegerChoices): PENDING = 100, _("Pending") - SUCCESS = 200, _("Success") - FAILED = 300, _("Failed") + PROCESSING = 200, _("Processing") + SUCCESS = 300, _("Success") + FAILED = 400, _("Failed") dref = models.OneToOneField( Dref, @@ -1718,7 +1719,7 @@ class SummaryStatus(models.IntegerChoices): created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) - hash = models.CharField( + prompt_hash = models.CharField( max_length=64, unique=True, ) diff --git a/dref/serializers.py b/dref/serializers.py index 55824c3db..a144ade2e 100644 --- a/dref/serializers.py +++ b/dref/serializers.py @@ -2428,7 +2428,7 @@ def get_dref_contacts(self, obj): return get_dref_emergency_contacts(obj) -class DrefSummarySerializer(serializers.ModelSerializer): +class DrefSummarySerializer(ModelSerializer): class Meta: model = DrefSummary fields = ( From 1fe27cd30cfe0873849f49d571bd453921e8f3d5 Mon Sep 17 00:00:00 2001 From: sandeshit Date: Fri, 26 Jun 2026 10:21:23 +0545 Subject: [PATCH 4/4] fixup! feat(serializer): create a serializer for summary. --- dref/factories/dref.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dref/factories/dref.py b/dref/factories/dref.py index 27d69c417..1ca5efb69 100644 --- a/dref/factories/dref.py +++ b/dref/factories/dref.py @@ -206,7 +206,7 @@ class Meta: model = DrefSummary dref = factory.SubFactory(DrefFactory) - hash = factory.Sequence(lambda n: f"{n:064d}") + prompt_hash = factory.Sequence(lambda n: f"{n:064d}") status = DrefSummary.SummaryStatus.SUCCESS situational_overview = fuzzy.FuzzyText(length=100) operational_strategy = fuzzy.FuzzyText(length=100)