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

fix: new screen for ban & revocation, moved help texts from form to m… #745

Merged
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: 2 additions & 8 deletions api/ceramic_cache/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class AccountAPIKeyAdmin(ScorerModelAdmin):
@admin.register(Revocation)
class RevocationAdmin(ScorerModelAdmin):
list_display = ("id", "proof_value", "ceramic_cache", "revocation_list")
raw_id_fields = ["ceramic_cache", "revocation_list"]
search_fields = ("proof_value",)
list_filter = ["revocation_list"]

Expand Down Expand Up @@ -156,17 +157,10 @@ def save_model(self, request, obj: RevocationList, form, change):
class BanForm(ModelForm):
class Meta:
model = Ban
fields = ["hash", "address", "provider", "end_time", "reason"]
fields = ["type", "hash", "address", "provider", "end_time", "reason"]
widgets = {
"reason": forms.Textarea(attrs={"rows": 3}),
}
help_texts = {
"hash": "Specific credential hash to ban",
"address": "Address to ban",
"provider": "Provider (e.g. CoinbaseDualVerification) to ban - must be used with address",
"end_time": "Leave blank for indefinite ban",
"reason": "(Optional) THIS WILL BE PUBLICLY VISIBLE",
}


@admin.action(description="Revoke matching credentials for selected bans")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Generated by Django 4.2.6 on 2024-12-03 14:08

from django.db import migrations, models

import account.models


class Migration(migrations.Migration):
dependencies = [
("ceramic_cache", "0028_alter_banlist_csv_file_alter_revocationlist_csv_file"),
]

operations = [
migrations.AlterField(
model_name="ban",
name="address",
field=account.models.EthAddressField(
blank=True,
db_index=True,
default="",
help_text="Address to ban",
max_length=42,
),
),
migrations.AlterField(
model_name="ban",
name="end_time",
field=models.DateTimeField(
blank=True,
db_index=True,
help_text="Leave blank for indefinite ban",
null=True,
),
),
migrations.AlterField(
model_name="ban",
name="hash",
field=models.CharField(
blank=True,
db_index=True,
default="",
help_text="Specific credential hash to ban",
max_length=100,
),
),
migrations.AlterField(
model_name="ban",
name="provider",
field=models.CharField(
blank=True,
db_index=True,
default="",
help_text="Provider (e.g. CoinbaseDualVerification) to ban - must be used with address",
max_length=256,
),
),
migrations.AlterField(
model_name="ban",
name="reason",
field=models.TextField(
blank=True,
help_text="(Optional) THIS WILL BE PUBLICLY VISIBLE",
null=True,
),
),
migrations.AlterField(
model_name="banlist",
name="csv_file",
field=models.FileField(
help_text="CSV file for stamps to revoke. The CSV need sto have at least the following columns\n `type`, `provider`, `hash`, `address`, `end_time` (if empty of `null` will be considered null) to\n identify the ban. If a value is not relevant for a prticular ban, it can be left empty.\n Other columns are ignored.",
max_length=1024,
upload_to="ban_list",
),
),
migrations.AlterField(
model_name="revocationlist",
name="csv_file",
field=models.FileField(
help_text="CSV file for stamps to revoke. The CSV need sto have at least one column named\n `proof_value` to identify which stamp to revoke. Other columns are ignored.",
max_length=1024,
upload_to="revocation_list",
),
),
]
28 changes: 23 additions & 5 deletions api/ceramic_cache/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,29 @@ class Ban(models.Model):
type = models.CharField(
max_length=20, choices=BAN_TYPE_CHOICES, null=False, blank=False, default=None
)
provider = models.CharField(default="", max_length=256, db_index=True, blank=True)
hash = models.CharField(default="", max_length=100, db_index=True, blank=True)
address = EthAddressField(default="", db_index=True, blank=True)
end_time = models.DateTimeField(null=True, blank=True, db_index=True)
reason = models.TextField(null=True, blank=True)
provider = models.CharField(
default="",
max_length=256,
db_index=True,
blank=True,
help_text="Provider (e.g. CoinbaseDualVerification) to ban - must be used with address",
)
hash = models.CharField(
default="",
max_length=100,
db_index=True,
blank=True,
help_text="Specific credential hash to ban",
)
address = EthAddressField(
default="", db_index=True, blank=True, help_text="Address to ban"
)
end_time = models.DateTimeField(
null=True, blank=True, db_index=True, help_text="Leave blank for indefinite ban"
)
reason = models.TextField(
null=True, blank=True, help_text="(Optional) THIS WILL BE PUBLICLY VISIBLE"
)
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
last_run_revoke_matching = models.DateTimeField(
null=True, blank=True, help_text="Last time revoke_matching_credentials was run"
Expand Down
Loading