Skip to content

Commit

Permalink
feat(admin): Add columns to License admin to ease review
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Nov 8, 2024
1 parent 43976e5 commit 498b027
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions data_registry/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from django.db.models import Q
from django.urls import NoReverseMatch, reverse
from django.utils import timezone
from django.utils.html import escape
from django.utils.html import escape, urlize
from django.utils.safestring import mark_safe
from modeltranslation.admin import TabbedDjangoJqueryTranslationAdmin
from modeltranslation.admin import TabbedDjangoJqueryTranslationAdmin, TranslationAdmin

from data_registry import forms
from data_registry.exceptions import RecoverableError
Expand Down Expand Up @@ -347,9 +347,9 @@ def last_task(self, obj):


@admin.register(License)
class LicenseAdmin(TabbedDjangoJqueryTranslationAdmin):
class LicenseAdmin(TranslationAdmin):
form = forms.LicenseAdminForm
list_display = ["__str__", "url"]
list_display = ["__str__", "name_es", "link", "description_length"]

fieldsets = (
(
Expand All @@ -369,6 +369,14 @@ class LicenseAdmin(TabbedDjangoJqueryTranslationAdmin):
),
)

@admin.display(description="URL", ordering="url")
def link(self, obj):
return mark_safe(urlize(obj.url))

@admin.display(description="Description length")
def description_length(self, obj):
return ", ".join([str(len(field)) for field in (obj.description_en, obj.description_es, obj.description_ru)])


# https://docs.djangoproject.com/en/4.2/ref/contrib/admin/#logentry-objects
@admin.register(admin.models.LogEntry)
Expand Down

0 comments on commit 498b027

Please sign in to comment.