Skip to content

Commit

Permalink
fix: adding helptext to model fields, removing unused vars (#744)
Browse files Browse the repository at this point in the history
  • Loading branch information
nutrina authored Dec 3, 2024
1 parent 2032d17 commit c459e4c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
4 changes: 1 addition & 3 deletions api/ceramic_cache/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ def save_model(self, request, obj: RevocationList, form, change):
# If saving any of the objects below fails, we expect to roll back
csv_reader = csv.DictReader(obj.csv_file.open("rt"))
revocation_item_list = []
ceramic_cache_list = []
for revocation_item in csv_reader:
proof_value = revocation_item["proof_value"]
ceramic_cache = CeramicCache.objects.get(proof_value=proof_value)
Expand All @@ -151,7 +150,6 @@ def save_model(self, request, obj: RevocationList, form, change):
revocation_list=obj,
)
revocation_item_list.append(db_revocation_item)
ceramic_cache_list.append(ceramic_cache)
Revocation.objects.bulk_create(revocation_item_list, batch_size=1000)


Expand Down Expand Up @@ -244,7 +242,7 @@ def matching_revoked(self, obj):


def get_isodatetime_or_none(value) -> Optional[datetime]:
return datetime.fromisoformat(value) if value != "null" else None
return datetime.fromisoformat(value) if value != "null" and value != "" else None


class BanListForm(forms.ModelForm):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 4.2.6 on 2024-12-03 12:22

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("ceramic_cache", "0027_revocationlist_alter_banlist_csv_file_and_more"),
]

operations = [
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",
),
),
]
16 changes: 14 additions & 2 deletions api/ceramic_cache/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ class RevocationList(models.Model):
)
description = models.TextField(default="", null=True, blank=True)
csv_file = models.FileField(
max_length=1024, null=False, blank=False, upload_to="revocation_list"
max_length=1024,
null=False,
blank=False,
upload_to="revocation_list",
help_text="""CSV file for stamps to revoke. The CSV need sto have at least one column named
`proof_value` to identify which stamp to revoke. Other columns are ignored.""",
)

def __str__(self):
Expand Down Expand Up @@ -171,7 +176,14 @@ class BanList(models.Model):
)
description = models.TextField(default="", null=True, blank=True)
csv_file = models.FileField(
max_length=1024, null=False, blank=False, upload_to="ban_list"
max_length=1024,
null=False,
blank=False,
upload_to="ban_list",
help_text="""CSV file for stamps to revoke. The CSV need sto have at least the following columns
`type`, `provider`, `hash`, `address`, `end_time` (if empty of `null` will be considered null) to
identify the ban. If a value is not relevant for a prticular ban, it can be left empty.
Other columns are ignored.""",
)

def __str__(self):
Expand Down

0 comments on commit c459e4c

Please sign in to comment.