diff --git a/temba/msgs/migrations/0265_broadcast_template_variables.py b/temba/msgs/migrations/0265_broadcast_template_variables.py new file mode 100644 index 00000000000..2e5997d44d7 --- /dev/null +++ b/temba/msgs/migrations/0265_broadcast_template_variables.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.4 on 2024-07-01 19:24 + +import django.contrib.postgres.fields +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("msgs", "0264_broadcast_exclusions"), + ] + + operations = [ + migrations.AddField( + model_name="broadcast", + name="template_variables", + field=django.contrib.postgres.fields.ArrayField(base_field=models.TextField(), null=True, size=None), + ), + ] diff --git a/temba/msgs/models.py b/temba/msgs/models.py index 116f9520495..619de62732f 100644 --- a/temba/msgs/models.py +++ b/temba/msgs/models.py @@ -198,11 +198,12 @@ class Broadcast(models.Model): query = models.TextField(null=True) exclusions = models.JSONField(default=dict, null=True) - # message content in different languages, e.g. {"eng": {"text": "Hello", "attachments": [...]}, "spa": ...} - translations = models.JSONField() + # message content + translations = models.JSONField() # text, attachments and quick replies by language base_language = models.CharField(max_length=3) # ISO-639-3 optin = models.ForeignKey("msgs.OptIn", null=True, on_delete=models.PROTECT) template = models.ForeignKey("templates.Template", null=True, on_delete=models.PROTECT) + template_variables = ArrayField(models.TextField(), null=True) status = models.CharField(max_length=1, choices=STATUS_CHOICES, default=STATUS_QUEUED) created_by = models.ForeignKey(User, null=True, on_delete=models.PROTECT, related_name="broadcast_creations") @@ -291,7 +292,7 @@ def get_translation(self, contact=None) -> dict: def trans(d): # ensure that we have all fields - return {"text": "", "attachments": [], "quick_replies": [], "template_variables": []} | d + return {"text": "", "attachments": [], "quick_replies": []} | d if contact and contact.language and contact.language in self.org.flow_languages: # try contact language if contact.language in self.translations: