Skip to content

Commit

Permalink
feat(admin): Display number of lines in description
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Nov 8, 2024
1 parent 498b027 commit 401cab8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions data_registry/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,12 @@ class LicenseAdmin(TranslationAdmin):
def link(self, obj):
return mark_safe(urlize(obj.url))

@admin.display(description="Description length")
@admin.display(description="Lines (characters)")
def description_length(self, obj):
return ", ".join([str(len(field)) for field in (obj.description_en, obj.description_es, obj.description_ru)])
# Russian isn't populated in practice: SELECT id, name_ru, description_ru FROM data_registry_license;
characters = "/".join(str(len(field)) for field in (obj.description_en, obj.description_es))
lines = "/".join(str(len(field.split("\n"))) for field in (obj.description_en, obj.description_es))
return f"{lines} ({characters})"


# https://docs.djangoproject.com/en/4.2/ref/contrib/admin/#logentry-objects
Expand Down

0 comments on commit 401cab8

Please sign in to comment.