Skip to content

Commit

Permalink
Changes nullable fields to non-nullable and adding migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Buhle79 committed Jan 24, 2024
1 parent 875b0fa commit adc5a75
Show file tree
Hide file tree
Showing 3 changed files with 275 additions and 8 deletions.
189 changes: 189 additions & 0 deletions home/migrations/0046_alter_contentpage_whatsapp_body.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
# Generated by Django 4.1.13 on 2024-01-24 04:40

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", "0045_merge_20240123_1102"),
]

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,
),
),
],
help_text="Each message will be sent with the text and media",
),
)
],
blank=True,
null=True,
use_json_field=True,
),
),
]
79 changes: 79 additions & 0 deletions home/migrations/0047_alter_contentpage_messenger_title_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Generated by Django 4.1.13 on 2024-01-24 05:21

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("home", "0046_alter_contentpage_whatsapp_body"),
]

operations = [
migrations.AlterField(
model_name="contentpage",
name="messenger_title",
field=models.CharField(blank=True, default="", max_length=200),
),
migrations.AlterField(
model_name="contentpage",
name="subtitle",
field=models.CharField(blank=True, default="", max_length=200),
),
migrations.AlterField(
model_name="contentpage",
name="viber_title",
field=models.CharField(blank=True, default="", max_length=200),
),
migrations.AlterField(
model_name="contentpage",
name="whatsapp_title",
field=models.CharField(blank=True, default="", max_length=200),
),
migrations.AlterField(
model_name="pageview",
name="platform",
field=models.CharField(
blank=True,
choices=[
("WHATSAPP", "whatsapp"),
("SMS", "sms"),
("USSD", "ussd"),
("VIBER", "viber"),
("MESSENGER", "messenger"),
("WEB", "web"),
],
default="web",
max_length=20,
),
),
migrations.AlterField(
model_name="sitesettings",
name="login_message",
field=models.CharField(
blank=True,
default="",
help_text="The login message shown on the login page",
max_length=100,
),
),
migrations.AlterField(
model_name="sitesettings",
name="title",
field=models.CharField(
blank=True,
default="",
help_text="The branding title shown in the CMS",
max_length=30,
),
),
migrations.AlterField(
model_name="sitesettings",
name="welcome_message",
field=models.CharField(
blank=True,
default="",
help_text="The welcome message shown after logging in",
max_length=100,
),
),
]
15 changes: 7 additions & 8 deletions home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,19 @@ class SiteSettings(BaseSiteSetting):
title = models.CharField(
max_length=30,
blank=True,
null=True,
default="",
help_text="The branding title shown in the CMS",
)
login_message = models.CharField(
max_length=100,
blank=True,
null=True,
default="",
help_text="The login message shown on the login page",
)
welcome_message = models.CharField(
max_length=100,
blank=True,
null=True,
default="",
help_text="The welcome message shown after logging in",
)
logo = models.ImageField(blank=True, null=True, upload_to="images")
Expand Down Expand Up @@ -465,7 +465,7 @@ class WhatsAppTemplateCategory(models.TextChoices):
)

# Web page setup
subtitle = models.CharField(max_length=200, blank=True, null=True)
subtitle = models.CharField(max_length=200, blank=True, default="")
body = StreamField(
[
("paragraph", blocks.RichTextBlock()),
Expand Down Expand Up @@ -500,7 +500,7 @@ class WhatsAppTemplateCategory(models.TextChoices):
choices=WhatsAppTemplateCategory.choices,
default=WhatsAppTemplateCategory.UTILITY,
)
whatsapp_title = models.CharField(max_length=200, blank=True, null=True)
whatsapp_title = models.CharField(max_length=200, blank=True, default="")
whatsapp_body = StreamField(
[
(
Expand Down Expand Up @@ -575,7 +575,7 @@ class WhatsAppTemplateCategory(models.TextChoices):
]

# messenger page setup
messenger_title = models.CharField(max_length=200, blank=True, null=True)
messenger_title = models.CharField(max_length=200, blank=True, default="")
messenger_body = StreamField(
[
(
Expand Down Expand Up @@ -604,7 +604,7 @@ class WhatsAppTemplateCategory(models.TextChoices):
]

# viber page setup
viber_title = models.CharField(max_length=200, blank=True, null=True)
viber_title = models.CharField(max_length=200, blank=True, default="")
viber_body = StreamField(
[
(
Expand Down Expand Up @@ -1092,7 +1092,6 @@ class PageView(models.Model):
("MESSENGER", "messenger"),
("WEB", "web"),
],
null=True,
blank=True,
default="web",
max_length=20,
Expand Down

0 comments on commit adc5a75

Please sign in to comment.