From 2211a8eed64dd469484a3d01a949bc18eb780764 Mon Sep 17 00:00:00 2001 From: larisa17 <42570262+larisa17@users.noreply.github.com> Date: Tue, 2 Jul 2024 20:19:49 +0300 Subject: [PATCH] add additional fields for customization (#623) * add additional fields for customization * add button background color * add color for button text * update migration --- api/account/admin.py | 5 ++ api/account/api.py | 7 ++ ...tion_body_display_info_tooltip_and_more.py | 73 +++++++++++++++++++ api/account/models.py | 27 +++++++ 4 files changed, 112 insertions(+) create mode 100644 api/account/migrations/0032_customization_body_display_info_tooltip_and_more.py diff --git a/api/account/admin.py b/api/account/admin.py index bede7ea7f..977d68f80 100644 --- a/api/account/admin.py +++ b/api/account/admin.py @@ -242,6 +242,8 @@ class CustomizationAdmin(ScorerModelAdmin): "customization_background_1", "customization_background_2", "customization_foreground_1", + "customization_foreground_2", + "customization_background_3", ], }, ), @@ -261,6 +263,9 @@ class CustomizationAdmin(ScorerModelAdmin): "body_action_url", "body_main_text", "body_sub_text", + "button_action_type", + "body_display_info_tooltip", + "body_info_tooltip_text", ], }, ), diff --git a/api/account/api.py b/api/account/api.py index d6ca9f982..56b8624f9 100644 --- a/api/account/api.py +++ b/api/account/api.py @@ -623,6 +623,8 @@ def get_account_customization(request, dashboard_path: str): "customizationBackground1": customization.customization_background_1, "customizationBackground2": customization.customization_background_2, "customizationForeground1": customization.customization_foreground_1, + "customizationForeground2": customization.customization_foreground_2, + "customizationBackground3": customization.customization_background_3, } }, scorerPanel={ @@ -641,6 +643,11 @@ def get_account_customization(request, dashboard_path: str): "action": { "text": customization.body_action_text, "url": customization.body_action_url, + "type": customization.button_action_type, + }, + "displayInfoTooltip": { + "shouldDisplay": customization.body_display_info_tooltip, + "text": customization.body_info_tooltip_text, }, }, }, diff --git a/api/account/migrations/0032_customization_body_display_info_tooltip_and_more.py b/api/account/migrations/0032_customization_body_display_info_tooltip_and_more.py new file mode 100644 index 000000000..b75189247 --- /dev/null +++ b/api/account/migrations/0032_customization_body_display_info_tooltip_and_more.py @@ -0,0 +1,73 @@ +# Generated by Django 4.2.6 on 2024-07-02 17:11 + +import account.models +import django.core.validators +from django.db import migrations, models +import re + + +class Migration(migrations.Migration): + dependencies = [ + ("account", "0031_alter_allowlist_customization"), + ] + + operations = [ + migrations.AddField( + model_name="customization", + name="body_display_info_tooltip", + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name="customization", + name="body_info_tooltip_text", + field=account.models.ReactNodeField( + blank=True, help_text="The info tooltip text", null=True + ), + ), + migrations.AddField( + model_name="customization", + name="button_action_type", + field=models.CharField( + choices=[ + ("Simple Link", "Simple Link"), + ("Onchain Push", "Onchain Push"), + ], + default="Simple Link", + max_length=25, + ), + ), + migrations.AddField( + model_name="customization", + name="customization_background_3", + field=account.models.RGBHexColorField( + blank=True, + help_text="Action button background color. RGB hex value expected, for example `#aaff66`", + max_length=7, + null=True, + validators=[ + django.core.validators.RegexValidator( + re.compile("^#[A-Fa-f0-9]{6}$"), + "Enter a valid RGBA color as hex string ", + "invalid", + ) + ], + ), + ), + migrations.AddField( + model_name="customization", + name="customization_foreground_2", + field=account.models.RGBHexColorField( + blank=True, + help_text="Action button text color. RGB hex value expected, for example `#aaff66`", + max_length=7, + null=True, + validators=[ + django.core.validators.RegexValidator( + re.compile("^#[A-Fa-f0-9]{6}$"), + "Enter a valid RGBA color as hex string ", + "invalid", + ) + ], + ), + ), + ] diff --git a/api/account/models.py b/api/account/models.py index ca66fee67..44b918587 100644 --- a/api/account/models.py +++ b/api/account/models.py @@ -417,6 +417,10 @@ class CustomizationLogoBackgroundType(models.TextChoices): DOTS = "DOTS" NONE = "NONE" + class CustomizationOnChainButtonAction(models.TextChoices): + SIMPLE_LINK = "Simple Link" + ONCHAIN_PUSH = "Onchain Push" + path = models.CharField( max_length=100, db_index=True, @@ -458,6 +462,18 @@ class CustomizationLogoBackgroundType(models.TextChoices): blank=True, ) + customization_background_3 = RGBHexColorField( + help_text="Action button background color. RGB hex value expected, for example `#aaff66`", + null=True, + blank=True, + ) + + customization_foreground_2 = RGBHexColorField( + help_text="Action button text color. RGB hex value expected, for example `#aaff66`", + null=True, + blank=True, + ) + # Logo logo_image = ReactNodeField( help_text="The logo in SVG format", null=True, blank=True @@ -486,6 +502,17 @@ class CustomizationLogoBackgroundType(models.TextChoices): null=True, ) + button_action_type = models.CharField( + max_length=25, + choices=CustomizationOnChainButtonAction.choices, + default=CustomizationOnChainButtonAction.SIMPLE_LINK, + ) + + body_display_info_tooltip = models.BooleanField(default=False) + body_info_tooltip_text = ReactNodeField( + help_text="The info tooltip text", null=True, blank=True + ) + def get_customization_dynamic_weights(self) -> dict: weights = {} for allow_list in self.allow_lists.all():