Skip to content

Commit

Permalink
Add Admin panel for ops learning summary and SectorTag translation
Browse files Browse the repository at this point in the history
  • Loading branch information
susilnem committed Nov 6, 2024
1 parent ea5dce1 commit 086bf86
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Generated by Django 4.2.16 on 2024-11-06 07:46

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("deployments", "0089_alter_emergencyproject_districts"),
]

operations = [
migrations.AddField(
model_name="sectortag",
name="title_ar",
field=models.CharField(max_length=255, null=True, verbose_name="title"),
),
migrations.AddField(
model_name="sectortag",
name="title_en",
field=models.CharField(max_length=255, null=True, verbose_name="title"),
),
migrations.AddField(
model_name="sectortag",
name="title_es",
field=models.CharField(max_length=255, null=True, verbose_name="title"),
),
migrations.AddField(
model_name="sectortag",
name="title_fr",
field=models.CharField(max_length=255, null=True, verbose_name="title"),
),
migrations.AddField(
model_name="sectortag",
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="sectortag",
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"
),
),
]
32 changes: 32 additions & 0 deletions per/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,36 @@ def break_to_rows(many2many, many2many_validated, is_validated, idx):
export_selected_records.short_description = "Export selected Ops Learning records to CSV"


class OpsLearningCacheResponseAdmin(TranslationAdmin):
search_fields = (
"response",
"id",
)
list_display = (
"__str__",
"insights1_title",
"insights2_title",
"insights3_title",
"status",
)
used_ops_learning_in = "used_ops_learning_in"
autocomplete_fields = ("used_ops_learning",)
exclude = (
"export_status",
"exported_file",
"exported_at",
)


class OpsLearningPromptResponseCacheAdmin(admin.ModelAdmin):
list_display = (
"__str__",
"type",
"response",
)
list_filter = ("type",)


admin.site.register(models.Form, FormAdmin)
admin.site.register(models.FormArea, FormAreaAdmin)
admin.site.register(models.FormComponent, FormComponentAdmin)
Expand All @@ -329,3 +359,5 @@ def break_to_rows(many2many, many2many_validated, is_validated, idx):
admin.site.register(models.OpsLearning, OpsLearningAdmin)
admin.site.register(models.PerDocumentUpload, PerDocumentUploadAdmin)
admin.site.register(models.FormQuestionGroup, FormQuestionGroupAdmin)
admin.site.register(models.OpsLearningCacheResponse, OpsLearningCacheResponseAdmin)
admin.site.register(models.OpsLearningPromptResponseCache, OpsLearningPromptResponseCacheAdmin)
2 changes: 1 addition & 1 deletion per/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ class PromptType(models.IntegerChoices):
response = models.JSONField(verbose_name=_("response"), default=dict)

def __str__(self) -> str:
return f"{self.type} - {self.prompt_hash}"
return f"{self.prompt_hash}"


class OpsLearningCacheResponse(models.Model):
Expand Down
6 changes: 6 additions & 0 deletions per/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
PerAssessment,
PerComponentRating,
PerWorkPlanComponent,
SectorTag,
)


Expand Down Expand Up @@ -138,3 +139,8 @@ class OpsLearningSectorCacheResponseTO(TranslationOptions):
@register(OpsLearningComponentCacheResponse)
class OpsLearningComponentCacheResponseTO(TranslationOptions):
fields = ("content",)


@register(SectorTag)
class SectorTagTO(TranslationOptions):
fields = ("title",)

0 comments on commit 086bf86

Please sign in to comment.