From 63f846908e37ea08029464d5acca0033eaa1a542 Mon Sep 17 00:00:00 2001 From: schultztimothy Date: Wed, 11 Sep 2024 14:11:49 -0600 Subject: [PATCH] feat: hide show explanation panel --- api/account/admin.py | 10 ++++++- api/account/api.py | 27 ++++++++++--------- ...35_customization_show_explanation_panel.py | 19 +++++++++++++ api/account/models.py | 4 +++ 4 files changed, 46 insertions(+), 14 deletions(-) create mode 100644 api/account/migrations/0035_customization_show_explanation_panel.py diff --git a/api/account/admin.py b/api/account/admin.py index 919f9248b..1e38654c3 100644 --- a/api/account/admin.py +++ b/api/account/admin.py @@ -240,6 +240,7 @@ class CustomizationAdmin(ScorerModelAdmin): "scorer_panel_text", "scorer", "use_custom_dashboard_panel", + "show_explanation_panel", ], }, ), @@ -280,7 +281,14 @@ class CustomizationAdmin(ScorerModelAdmin): ), ] - list_display = ["display", "id", "path", "use_custom_dashboard_panel", "scorer"] + list_display = [ + "display", + "id", + "path", + "use_custom_dashboard_panel", + "scorer", + "show_explanation_panel", + ] @admin.display(ordering="id") def display(self, obj): diff --git a/api/account/api.py b/api/account/api.py index 56b8624f9..e89ff9513 100644 --- a/api/account/api.py +++ b/api/account/api.py @@ -3,16 +3,6 @@ from datetime import datetime, timezone from typing import Dict, List, Optional, cast -import api_logging as logging -from account.models import ( - Account, - AccountAPIKey, - AddressList, - AddressListMember, - Community, - Nonce, - Customization, -) from django.conf import settings from django.contrib.auth import get_user_model from django.http import HttpResponse @@ -23,17 +13,27 @@ from ninja_extra.exceptions import APIException from ninja_jwt.authentication import JWTAuth from ninja_jwt.schema import RefreshToken +from siwe import SiweMessage, siwe + +import api_logging as logging +from account.models import ( + Account, + AccountAPIKey, + AddressList, + AddressListMember, + Community, + Customization, + Nonce, +) from scorer_weighted.models import ( BinaryWeightedScorer, WeightedScorer, get_default_weights, ) -from siwe import SiweMessage, siwe +from trusta_labs.api import CgrantsApiKey from .deduplication import Rules -from trusta_labs.api import CgrantsApiKey - secret_key = CgrantsApiKey() log = logging.getLogger(__name__) @@ -656,6 +656,7 @@ def get_account_customization(request, dashboard_path: str): "id": customization.scorer.id, }, includedChainIds=included_chain_ids, + showExplanationPanel=customization.show_explanation_panel, ) except Customization.DoesNotExist: diff --git a/api/account/migrations/0035_customization_show_explanation_panel.py b/api/account/migrations/0035_customization_show_explanation_panel.py new file mode 100644 index 000000000..63bc17ced --- /dev/null +++ b/api/account/migrations/0035_customization_show_explanation_panel.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.6 on 2024-09-11 20:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("account", "0034_customgithubstamp"), + ] + + operations = [ + migrations.AddField( + model_name="customization", + name="show_explanation_panel", + field=models.BooleanField( + default=True, help_text="Toggle to show or hide the middle component" + ), + ), + ] diff --git a/api/account/models.py b/api/account/models.py index 985045650..8826a8f9c 100644 --- a/api/account/models.py +++ b/api/account/models.py @@ -541,6 +541,10 @@ class CustomizationOnChainButtonAction(models.TextChoices): help_text="The info tooltip text", null=True, blank=True ) + show_explanation_panel = models.BooleanField( + default=True, help_text="Toggle to show or hide the middle component" + ) + def get_customization_dynamic_weights(self) -> dict: weights = {} for allow_list in self.allow_lists.all():