Use decorator syntax to register admin handlers

Same-same, just marginally neater.
This commit is contained in:
Ben Sturmfels 2024-03-21 09:35:00 +11:00
parent 6c91a14f6b
commit 440b4f864a
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0
9 changed files with 13 additions and 13 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)