Skip to content

Commit

Permalink
add additional fields for customization (#623)
Browse files Browse the repository at this point in the history
* add additional fields for customization

* add button background color

* add color for button text

* update migration
  • Loading branch information
larisa17 committed Jul 4, 2024
1 parent 7a1a83f commit 5fe4be1
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/account/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ class CustomizationAdmin(ScorerModelAdmin):
"customization_background_1",
"customization_background_2",
"customization_foreground_1",
"customization_foreground_2",
"customization_background_3",
],
},
),
Expand All @@ -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",
],
},
),
Expand Down
7 changes: 7 additions & 0 deletions api/account/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand All @@ -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,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
)
],
),
),
]
27 changes: 27 additions & 0 deletions api/account/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 5fe4be1

Please sign in to comment.