From 440b4f864a7a1902b382e6fcd77abca36cb6b97d Mon Sep 17 00:00:00 2001 From: Ben Sturmfels Date: Thu, 21 Mar 2024 09:35:00 +1100 Subject: [PATCH] Use decorator syntax to register admin handlers Same-same, just marginally neater. --- conservancy/blog/admin.py | 4 ++-- conservancy/contacts/admin.py | 2 +- conservancy/events/admin.py | 4 ++-- conservancy/news/admin.py | 4 ++-- conservancy/podjango/admin.py | 4 ++-- conservancy/staff/admin.py | 2 +- conservancy/summit_registration/admin.py | 2 +- conservancy/supporters/admin.py | 2 +- conservancy/worldmap/admin.py | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/conservancy/blog/admin.py b/conservancy/blog/admin.py index 827cd0d7..8f7b9e3a 100644 --- a/conservancy/blog/admin.py +++ b/conservancy/blog/admin.py @@ -3,12 +3,13 @@ from django.contrib import admin from .models import Entry, EntryTag +@admin.register(EntryTag) class EntryTagAdmin(admin.ModelAdmin): prepopulated_fields = {'slug': ('label',)} -admin.site.register(EntryTag, EntryTagAdmin) +@admin.register(Entry) class EntryAdmin(admin.ModelAdmin): list_display = ('pub_date', 'headline', 'author') list_filter = ['pub_date'] @@ -18,4 +19,3 @@ class EntryAdmin(admin.ModelAdmin): filter_horizontal = ('tags',) -admin.site.register(Entry, EntryAdmin) diff --git a/conservancy/contacts/admin.py b/conservancy/contacts/admin.py index adc2adf5..94048d4b 100644 --- a/conservancy/contacts/admin.py +++ b/conservancy/contacts/admin.py @@ -3,8 +3,8 @@ from django.contrib import admin from .models import ContactEntry +@admin.register(ContactEntry) class ContactEntryAdmin(admin.ModelAdmin): list_display = ('email', 'subscribe_conservancy') -admin.site.register(ContactEntry, ContactEntryAdmin) diff --git a/conservancy/events/admin.py b/conservancy/events/admin.py index 0d4f8196..eedba16f 100644 --- a/conservancy/events/admin.py +++ b/conservancy/events/admin.py @@ -4,6 +4,7 @@ from .models import Event, EventMedia, EventTag admin.site.register(EventTag) +@admin.register(Event) class EventAdmin(admin.ModelAdmin): list_display = ("title", "date", "date_tentative", "location") list_filter = ['date'] @@ -11,11 +12,10 @@ class EventAdmin(admin.ModelAdmin): search_fields = ["title", "description", "earth_location"] prepopulated_fields = {'slug' : ("title",) } -admin.site.register(Event, EventAdmin) +@admin.register(EventMedia) class EventMediaAdmin(admin.ModelAdmin): list_display = ("event", "format", "novel") -admin.site.register(EventMedia, EventMediaAdmin) diff --git a/conservancy/news/admin.py b/conservancy/news/admin.py index 49bc647b..2bd13c79 100644 --- a/conservancy/news/admin.py +++ b/conservancy/news/admin.py @@ -3,6 +3,7 @@ from django.contrib import admin from .models import ExternalArticle, ExternalArticleTag, PressRelease +@admin.register(PressRelease) class PressReleaseAdmin(admin.ModelAdmin): list_display = ("headline", "pub_date") list_filter = ['pub_date'] @@ -10,16 +11,15 @@ class PressReleaseAdmin(admin.ModelAdmin): search_fields = ['headline', 'summary', 'body'] prepopulated_fields = { 'slug' : ("headline",), } -admin.site.register(PressRelease, PressReleaseAdmin) admin.site.register(ExternalArticleTag) +@admin.register(ExternalArticle) class ExternalArticleAdmin(admin.ModelAdmin): list_display = ("title", "publication", "visible", "date") list_filter = ['date'] date_hierarchy = 'date' search_fields = ["title", "info", "publication"] -admin.site.register(ExternalArticle, ExternalArticleAdmin) diff --git a/conservancy/podjango/admin.py b/conservancy/podjango/admin.py index 0fdb0e92..a1c200a9 100644 --- a/conservancy/podjango/admin.py +++ b/conservancy/podjango/admin.py @@ -21,13 +21,14 @@ from django.contrib import admin from .models import Cast, CastTag +@admin.register(CastTag) class CastTagAdmin(admin.ModelAdmin): prepopulated_fields = {'slug': ('label',)} -admin.site.register(CastTag, CastTagAdmin) +@admin.register(Cast) class CastAdmin(admin.ModelAdmin): list_display = ('pub_date', 'title') list_filter = ['pub_date'] @@ -37,4 +38,3 @@ class CastAdmin(admin.ModelAdmin): filter_horizontal = ('tags',) -admin.site.register(Cast, CastAdmin) diff --git a/conservancy/staff/admin.py b/conservancy/staff/admin.py index d2626a1d..8c3e4628 100644 --- a/conservancy/staff/admin.py +++ b/conservancy/staff/admin.py @@ -3,9 +3,9 @@ from django.contrib import admin from .models import Person +@admin.register(Person) class PersonAdmin(admin.ModelAdmin): list_display = ("username", "formal_name", "casual_name", "currently_employed") list_filter = ["currently_employed"] -admin.site.register(Person, PersonAdmin) diff --git a/conservancy/summit_registration/admin.py b/conservancy/summit_registration/admin.py index 1f50b69b..09c90313 100644 --- a/conservancy/summit_registration/admin.py +++ b/conservancy/summit_registration/admin.py @@ -3,8 +3,8 @@ from django.contrib import admin from .models import SummitRegistration +@admin.register(SummitRegistration) class SummitRegistrationAdmin(admin.ModelAdmin): list_display = ('name', 'email', 'affiliation', 'cle_credit') -admin.site.register(SummitRegistration, SummitRegistrationAdmin) diff --git a/conservancy/supporters/admin.py b/conservancy/supporters/admin.py index 8d174af9..c20b34a6 100644 --- a/conservancy/supporters/admin.py +++ b/conservancy/supporters/admin.py @@ -3,7 +3,7 @@ from django.contrib import admin from .models import Supporter +@admin.register(Supporter) class SupporterAdmin(admin.ModelAdmin): list_display = ('display_name', 'display_until_date') -admin.site.register(Supporter, SupporterAdmin) diff --git a/conservancy/worldmap/admin.py b/conservancy/worldmap/admin.py index d4a528bf..b042a852 100644 --- a/conservancy/worldmap/admin.py +++ b/conservancy/worldmap/admin.py @@ -3,7 +3,7 @@ from django.contrib import admin from .models import EarthLocation +@admin.register(EarthLocation) class EarthLocationAdmin(admin.ModelAdmin): list_display = ("label", "html_map_link") -admin.site.register(EarthLocation, EarthLocationAdmin)