Skip to content

Commit

Permalink
add footer to export
Browse files Browse the repository at this point in the history
  • Loading branch information
Hlamallama committed Feb 1, 2024
1 parent 8c89258 commit 1fc4623
Show file tree
Hide file tree
Showing 13 changed files with 256 additions and 51 deletions.
2 changes: 1 addition & 1 deletion contentrepo/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"default": dj_database_url.config(
default=os.environ.get(
"CONTENTREPO_DATABASE",
"postgres://postgres@localhost/contentrepo",
"postgres://postgres:myPassword@localhost/contentrepo",
),
engine="django.db.backends.postgresql",
)
Expand Down
4 changes: 4 additions & 0 deletions home/export_content_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class ExportRow:
doc_link: str = ""
media_link: str = ""
related_pages: str = ""
footer: str = ""

@classmethod
def headings(cls) -> list[str]:
Expand Down Expand Up @@ -132,6 +133,8 @@ def add_message_fields(self, msg_blocks: MsgBlocks) -> None:
self.buttons = self.serialise_buttons(whatsapp.value["buttons"])
if "example_values" in whatsapp.value:
self.example_values = ", ".join(whatsapp.value["example_values"])
if "footer" in whatsapp.value:
self.footer = whatsapp.value["footer"]

@staticmethod
def serialise_buttons(buttons: blocks.StreamValue.StreamChild) -> str:
Expand Down Expand Up @@ -341,6 +344,7 @@ def _set_xlsx_styles(wb: Workbook, sheet: Worksheet) -> None:
"doc_link": 118,
"media_link": 118,
"related": 118,
"footer": 118,
}

for index, column_width in enumerate(column_widths_in_pts.values(), 2):
Expand Down
201 changes: 201 additions & 0 deletions home/migrations/0048_alter_contentpage_whatsapp_body.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
# Generated by Django 4.1.10 on 2024-02-01 13:02

import django.core.validators
from django.db import migrations
import home.models
import wagtail.blocks
import wagtail.documents.blocks
import wagtail.fields
import wagtail.images.blocks


class Migration(migrations.Migration):
dependencies = [
("home", "0047_alter_contentpage_messenger_title_and_more"),
]

operations = [
migrations.AlterField(
model_name="contentpage",
name="whatsapp_body",
field=wagtail.fields.StreamField(
[
(
"Whatsapp_Message",
wagtail.blocks.StructBlock(
[
(
"image",
wagtail.images.blocks.ImageChooserBlock(
required=False
),
),
(
"document",
wagtail.documents.blocks.DocumentChooserBlock(
icon="document", required=False
),
),
(
"media",
home.models.MediaBlock(
icon="media", required=False
),
),
(
"message",
wagtail.blocks.TextBlock(
help_text="each text message cannot exceed 4096 characters, messages with media cannot exceed 1024 characters.",
validators=(
django.core.validators.MaxLengthValidator(
4096
),
),
),
),
(
"example_values",
wagtail.blocks.ListBlock(
wagtail.blocks.CharBlock(label="Example Value"),
default=[],
help_text="Please add example values for all variables used in a WhatsApp template",
label="Variable Example Values",
),
),
(
"variation_messages",
wagtail.blocks.ListBlock(
wagtail.blocks.StructBlock(
[
(
"variation_restrictions",
wagtail.blocks.StreamBlock(
[
(
"gender",
wagtail.blocks.ChoiceBlock(
choices=home.models.get_gender_choices
),
),
(
"age",
wagtail.blocks.ChoiceBlock(
choices=home.models.get_age_choices
),
),
(
"relationship",
wagtail.blocks.ChoiceBlock(
choices=home.models.get_relationship_choices
),
),
],
help_text="Restrict this variation to users with this profile value. Valid values must be added to the Site Settings",
max_num=1,
min_num=1,
required=False,
use_json_field=True,
),
),
(
"message",
wagtail.blocks.TextBlock(
help_text="each message cannot exceed 4096 characters.",
validators=(
django.core.validators.MaxLengthValidator(
4096
),
),
),
),
]
),
default=[],
),
),
(
"next_prompt",
wagtail.blocks.CharBlock(
help_text="prompt text for next message",
required=False,
validators=(
django.core.validators.MaxLengthValidator(
20
),
),
),
),
(
"buttons",
wagtail.blocks.StreamBlock(
[
(
"next_message",
wagtail.blocks.StructBlock(
[
(
"title",
wagtail.blocks.CharBlock(
help_text="text for the button, up to 20 characters.",
validators=(
django.core.validators.MaxLengthValidator(
20
),
),
),
)
]
),
),
(
"go_to_page",
wagtail.blocks.StructBlock(
[
(
"title",
wagtail.blocks.CharBlock(
help_text="text for the button, up to 20 characters.",
validators=(
django.core.validators.MaxLengthValidator(
20
),
),
),
),
(
"page",
wagtail.blocks.PageChooserBlock(
help_text="page the button should go to"
),
),
]
),
),
],
max_num=3,
required=False,
),
),
(
"footer",
wagtail.blocks.CharBlock(
help_text="Footer cannot exceed 60 characters.",
required=False,
validators=(
django.core.validators.MaxLengthValidator(
60
),
),
),
),
],
help_text="Each message will be sent with the text and media",
),
)
],
blank=True,
null=True,
use_json_field=True,
),
),
]
10 changes: 5 additions & 5 deletions home/tests/content2.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
structure,message,page_id,slug,parent,web_title,web_subtitle,web_body,whatsapp_title,whatsapp_body,variation_title,variation_body,sms_title,sms_body,ussd_title,ussd_body,messenger_title,messenger_body,viber_title,viber_body,translation_tag,tags,quick_replies,triggers,locale,next_prompt,buttons,image_link,doc_link,media_link,related_pages,example_values
Menu 1,0,,main-menu,,Main Menu,,,,,,,,,,,,,,,a0b85075-d01b-46bf-8997-8591e87ba171,,,,English,,,,,,,[]
structure,message,page_id,slug,parent,web_title,web_subtitle,web_body,whatsapp_title,whatsapp_body,variation_title,variation_body,sms_title,sms_body,ussd_title,ussd_body,messenger_title,messenger_body,viber_title,viber_body,translation_tag,tags,quick_replies,triggers,locale,next_prompt,buttons,image_link,doc_link,media_link,related_pages,example_values,footer
Menu 1,0,,main-menu,,Main Menu,,,,,,,,,,,,,,,a0b85075-d01b-46bf-8997-8591e87ba171,,,,English,,,,,,,[],
Sub 1.1,1,,main-menu-first-time-user,Main Menu,main menu first time user,,,main menu first time user," *Welcome to HealthAlert* 🌍

This is a messaging service created by the _*World Health Organization*_ *(WHO)* that provides information on COVID-19 as well as emergency resources for disease outbreaks, natural, and man-made disasters.
Expand All @@ -12,12 +12,12 @@ This is a messaging service created by the World Health Organization (WHO) that

You can return to this main menu at any time by replying 🏠

Choose what you'd like to know more about by tapping a button below ⬇️",,,5892bccd-8025-419d-9a8e-a6a37b755dbf,menu,"Self-help🌬️, Settings⚙️, Health Info🏥",Main menu🏠,English,,[],,,,,[]
Choose what you'd like to know more about by tapping a button below ⬇️",,,5892bccd-8025-419d-9a8e-a6a37b755dbf,menu,"Self-help🌬️, Settings⚙️, Health Info🏥",Main menu🏠,English,,[],,,,,[],
Sub 1.1.1,1,,health-info,main menu first time user,health info,,,health info,"*Health information* 🏥

Get information and advice from WHO by tapping on a button below ⬇️",,,Health Info SMS Title,*Health Info SMS Body*,Health Info USSD Title,*Health Info USSD Body*,health info,"*Health information* 🏥

Get information and advice from WHO by tapping on a button below ⬇️",,,c9d6309e-173f-4c1d-bbaf-440b1fd4415f,health_info,,,English,,[],,,,,[]
Get information and advice from WHO by tapping on a button below ⬇️",,,c9d6309e-173f-4c1d-bbaf-440b1fd4415f,health_info,,,English,,[],,,,,[],
Sub 1.1.2,1,,self-help,main menu first time user,self-help,,,self-help,"*Self-help programs* 🌬️

Reply with a number to take part in a *free* self-help program created by WHO.
Expand All @@ -32,4 +32,4 @@ Reply with a number to take part in a *free* self-help program created by WHO.
1. Quit tobacco 🚭
_Stop smoking with the help of a guided, 42-day program._
2. Manage your stress 🧘🏽‍♀️
_Learn how to cope with stress and improve your wellbeing._",,,3e5d77f7-4d34-430d-aad7-d9ca01f79732,self_help,,,English,,[],,,,,[]
_Learn how to cope with stress and improve your wellbeing._",,,3e5d77f7-4d34-430d-aad7-d9ca01f79732,self_help,,,English,,[],,,,,[],
24 changes: 12 additions & 12 deletions home/tests/exported_content_20230911-variations-linked-page.csv
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
structure,message,page_id,slug,parent,web_title,web_subtitle,web_body,whatsapp_title,whatsapp_body,whatsapp_template_name,variation_title,variation_body,sms_title,sms_body,ussd_title,ussd_body,messenger_title,messenger_body,viber_title,viber_body,translation_tag,tags,quick_replies,triggers,locale,next_prompt,buttons,image_link,doc_link,media_link,related_pages,example_values
Menu 1,0,5,appointment-reminders,,Appointment reminders,,,,,,,,,,,,,,,,8cff04aa-cf08-4120-88b4-e2269b7d5d80,,,,English,,,,,,,
Menu 2,0,6,stage-based-messages,,Stage-based messages,,,,,,,,,,,,,,,,5f2d9e63-f047-41ab-921a-c5ca7c04d643,,,,English,,,,,,,
Menu 3,0,7,health-info-messages,,Health info messages,,,,,,,,,,,,,,,,3db069a4-7112-4e66-a9a2-f35c6c18055a,,,,English,,,,,,,
Menu 4,0,17,whatsapp-template-testing,,whatsapp template testing,,,,,,,,,,,,,,,,5f7221f4-146a-48c2-b2e3-c8491aaead9d,,,,English,,,,,,,
Menu 5,0,164,import-export,,Import Export,,,,,,,,,,,,,,,,497bdc1f-43fc-4925-80a1-e68cb942faa4,,,,English,,,,,,,
Sub 5.1,1,165,cp-import-export,Import Export,CP-Import/export,,,WA import export data,Message 1 contains an image,,,,,,,,,,,,8ac50daf-de21-4d05-b697-6d983b7ed3d5,"Tag2, Tag1",Quick reply1,"Trigger2, Trigger1",English,,[],/admin/images/usage/4/,,,ma_qa_temp,
,1,165,cp-import-export,,,,,,,,gender: male,Variation message one for Gender Male,,,,,,,,,,,,,,,,,,,,
,2,165,cp-import-export,,,,,,"Message2 has a document attached, lets add some variable placeholders as well {{0}}",,,,,,,,,,,,,,,,,,[],,/admin/documents/usage/1/,,,
,2,165,cp-import-export,,,,,,,,gender: empty,Variation message one for Gender Rather not say,,,,,,,,,,,,,,,,,,,,
,3,165,cp-import-export,,,,,,Message 3 with no variation but has an audio clip,,,,,,,,,,,,,,,,,,[],,,/admin/media/usage/1/,,
Sub 5.2,1,166,ma_qa_temp,Import Export,MA QA Temp,,,,,,,,,,,,,,,,e9793b5f-f8c7-46c5-8a5e-bd9b8f00fee9,,,,English,,,,,,,
structure,message,page_id,slug,parent,web_title,web_subtitle,web_body,whatsapp_title,whatsapp_body,whatsapp_template_name,variation_title,variation_body,sms_title,sms_body,ussd_title,ussd_body,messenger_title,messenger_body,viber_title,viber_body,translation_tag,tags,quick_replies,triggers,locale,next_prompt,buttons,image_link,doc_link,media_link,related_pages,example_values,footer
Menu 1,0,5,appointment-reminders,,Appointment reminders,,,,,,,,,,,,,,,,8cff04aa-cf08-4120-88b4-e2269b7d5d80,,,,English,,,,,,,,
Menu 2,0,6,stage-based-messages,,Stage-based messages,,,,,,,,,,,,,,,,5f2d9e63-f047-41ab-921a-c5ca7c04d643,,,,English,,,,,,,,
Menu 3,0,7,health-info-messages,,Health info messages,,,,,,,,,,,,,,,,3db069a4-7112-4e66-a9a2-f35c6c18055a,,,,English,,,,,,,,
Menu 4,0,17,whatsapp-template-testing,,whatsapp template testing,,,,,,,,,,,,,,,,5f7221f4-146a-48c2-b2e3-c8491aaead9d,,,,English,,,,,,,,
Menu 5,0,164,import-export,,Import Export,,,,,,,,,,,,,,,,497bdc1f-43fc-4925-80a1-e68cb942faa4,,,,English,,,,,,,,
Sub 5.1,1,165,cp-import-export,Import Export,CP-Import/export,,,WA import export data,Message 1 contains an image,,,,,,,,,,,,8ac50daf-de21-4d05-b697-6d983b7ed3d5,"Tag2, Tag1",Quick reply1,"Trigger2, Trigger1",English,,[],/admin/images/usage/4/,,,ma_qa_temp,,
,1,165,cp-import-export,,,,,,,,gender: male,Variation message one for Gender Male,,,,,,,,,,,,,,,,,,,,,
,2,165,cp-import-export,,,,,,"Message2 has a document attached, lets add some variable placeholders as well {{0}}",,,,,,,,,,,,,,,,,,[],,/admin/documents/usage/1/,,,,
,2,165,cp-import-export,,,,,,,,gender: empty,Variation message one for Gender Rather not say,,,,,,,,,,,,,,,,,,,,,
,3,165,cp-import-export,,,,,,Message 3 with no variation but has an audio clip,,,,,,,,,,,,,,,,,,[],,,/admin/media/usage/1/,,,
Sub 5.2,1,166,ma_qa_temp,Import Export,MA QA Temp,,,,,,,,,,,,,,,,e9793b5f-f8c7-46c5-8a5e-bd9b8f00fee9,,,,English,,,,,,,,
Loading

0 comments on commit 1fc4623

Please sign in to comment.