Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: hide show explanation panel #674

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion api/account/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ class CustomizationAdmin(ScorerModelAdmin):
"scorer_panel_text",
"scorer",
"use_custom_dashboard_panel",
"show_explanation_panel",
],
},
),
Expand Down Expand Up @@ -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):
Expand Down
27 changes: 14 additions & 13 deletions api/account/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__)
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
),
),
]
4 changes: 4 additions & 0 deletions api/account/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Loading