diff --git a/api/ceramic_cache/admin.py b/api/ceramic_cache/admin.py index 6ea1047e5..0184f5f25 100644 --- a/api/ceramic_cache/admin.py +++ b/api/ceramic_cache/admin.py @@ -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"] @@ -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") diff --git a/api/ceramic_cache/migrations/0029_alter_ban_address_alter_ban_end_time_alter_ban_hash_and_more.py b/api/ceramic_cache/migrations/0029_alter_ban_address_alter_ban_end_time_alter_ban_hash_and_more.py new file mode 100644 index 000000000..e02d3295b --- /dev/null +++ b/api/ceramic_cache/migrations/0029_alter_ban_address_alter_ban_end_time_alter_ban_hash_and_more.py @@ -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", + ), + ), + ] diff --git a/api/ceramic_cache/models.py b/api/ceramic_cache/models.py index 62e6d0f61..aef831974 100644 --- a/api/ceramic_cache/models.py +++ b/api/ceramic_cache/models.py @@ -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"