Skip to content

Commit

Permalink
Merge pull request #349 from praekeltfoundation/standalone-template-b…
Browse files Browse the repository at this point in the history
…ugfixes

Standalone template bugfixes
  • Loading branch information
fritzbrand authored Jul 31, 2024
2 parents ea73e94 + 6c1228c commit ee87071
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
21 changes: 21 additions & 0 deletions home/migrations/0079_alter_whatsapptemplate_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.2.11 on 2024-07-29 06:39

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("home", "0078_alter_assessment_high_inflection_and_more"),
]

operations = [
migrations.AlterField(
model_name="whatsapptemplate",
name="message",
field=models.TextField(
help_text="each template message cannot exceed 1024 characters",
max_length=1024,
),
),
]
10 changes: 4 additions & 6 deletions home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1542,9 +1542,8 @@ class SubmissionStatus(models.TextChoices):
related_name="image",
)
message = models.TextField(
help_text="each text message cannot exceed 4096 characters, messages with "
"media cannot exceed 1024 characters.",
max_length=4096,
help_text="each template message cannot exceed 1024 characters",
max_length=1024,
)

example_values = StreamField(
Expand Down Expand Up @@ -1603,8 +1602,8 @@ def save_revision(
previous_revision=None,
clean=True,
):
previous_revision = self.get_latest_revision()

previous_revision = self.get_latest_revision()
revision = super().save_revision(
user,
submitted_for_moderation,
Expand All @@ -1626,7 +1625,7 @@ def save_revision(
previous_revision_fields = ()

if self.fields == previous_revision_fields:
return
return revision

self.template_name = self.create_whatsapp_template_name()
try:
Expand Down Expand Up @@ -1655,7 +1654,6 @@ def save_revision(
)

revision.save(update_fields=["content"])

return revision

def clean(self):
Expand Down
18 changes: 9 additions & 9 deletions home/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,17 @@ class WhatsAppTemplateAdmin(SnippetViewSet):
"category",
"locale",
"status",
"quick_replies",
"example_values",
"submission_status",
)
list_filter = ("locale",)

search_fields = (
"name",
"category",
"message",
"locale",
)

index_view_class = CustomIndexViewWhatsAppTemplate

panels = [
Expand All @@ -274,13 +281,6 @@ class WhatsAppTemplateAdmin(SnippetViewSet):
),
]

search_fields = (
"name",
"category",
"message",
"locale",
)


class AssessmentAdmin(SnippetViewSet):
model = Assessment
Expand Down

0 comments on commit ee87071

Please sign in to comment.