Use decorator syntax to register admin handlers
Same-same, just marginally neater.
This commit is contained in:
		
							parent
							
								
									6c91a14f6b
								
							
						
					
					
						commit
						440b4f864a
					
				
					 9 changed files with 13 additions and 13 deletions
				
			
		|  | @ -3,12 +3,13 @@ from django.contrib import admin | ||||||
| from .models import Entry, EntryTag | from .models import Entry, EntryTag | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @admin.register(EntryTag) | ||||||
| class EntryTagAdmin(admin.ModelAdmin): | class EntryTagAdmin(admin.ModelAdmin): | ||||||
|     prepopulated_fields = {'slug': ('label',)} |     prepopulated_fields = {'slug': ('label',)} | ||||||
| 
 | 
 | ||||||
| admin.site.register(EntryTag, EntryTagAdmin) |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @admin.register(Entry) | ||||||
| class EntryAdmin(admin.ModelAdmin): | class EntryAdmin(admin.ModelAdmin): | ||||||
|     list_display = ('pub_date', 'headline', 'author') |     list_display = ('pub_date', 'headline', 'author') | ||||||
|     list_filter = ['pub_date'] |     list_filter = ['pub_date'] | ||||||
|  | @ -18,4 +19,3 @@ class EntryAdmin(admin.ModelAdmin): | ||||||
|     filter_horizontal = ('tags',) |     filter_horizontal = ('tags',) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| admin.site.register(Entry, EntryAdmin) |  | ||||||
|  |  | ||||||
|  | @ -3,8 +3,8 @@ from django.contrib import admin | ||||||
| from .models import ContactEntry | from .models import ContactEntry | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @admin.register(ContactEntry) | ||||||
| class ContactEntryAdmin(admin.ModelAdmin): | class ContactEntryAdmin(admin.ModelAdmin): | ||||||
|     list_display = ('email', 'subscribe_conservancy') |     list_display = ('email', 'subscribe_conservancy') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| admin.site.register(ContactEntry, ContactEntryAdmin) |  | ||||||
|  |  | ||||||
|  | @ -4,6 +4,7 @@ from .models import Event, EventMedia, EventTag | ||||||
| 
 | 
 | ||||||
| admin.site.register(EventTag) | admin.site.register(EventTag) | ||||||
| 
 | 
 | ||||||
|  | @admin.register(Event) | ||||||
| class EventAdmin(admin.ModelAdmin): | class EventAdmin(admin.ModelAdmin): | ||||||
|     list_display = ("title", "date", "date_tentative", "location") |     list_display = ("title", "date", "date_tentative", "location") | ||||||
|     list_filter = ['date'] |     list_filter = ['date'] | ||||||
|  | @ -11,11 +12,10 @@ class EventAdmin(admin.ModelAdmin): | ||||||
|     search_fields = ["title", "description", "earth_location"] |     search_fields = ["title", "description", "earth_location"] | ||||||
|     prepopulated_fields = {'slug' : ("title",) } |     prepopulated_fields = {'slug' : ("title",) } | ||||||
| 
 | 
 | ||||||
| admin.site.register(Event, EventAdmin) |  | ||||||
| 
 | 
 | ||||||
|  | @admin.register(EventMedia) | ||||||
| class EventMediaAdmin(admin.ModelAdmin): | class EventMediaAdmin(admin.ModelAdmin): | ||||||
|     list_display = ("event", "format", "novel") |     list_display = ("event", "format", "novel") | ||||||
| 
 | 
 | ||||||
| admin.site.register(EventMedia, EventMediaAdmin) |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ from django.contrib import admin | ||||||
| from .models import ExternalArticle, ExternalArticleTag, PressRelease | from .models import ExternalArticle, ExternalArticleTag, PressRelease | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @admin.register(PressRelease) | ||||||
| class PressReleaseAdmin(admin.ModelAdmin): | class PressReleaseAdmin(admin.ModelAdmin): | ||||||
|     list_display = ("headline", "pub_date") |     list_display = ("headline", "pub_date") | ||||||
|     list_filter = ['pub_date'] |     list_filter = ['pub_date'] | ||||||
|  | @ -10,16 +11,15 @@ class PressReleaseAdmin(admin.ModelAdmin): | ||||||
|     search_fields = ['headline', 'summary', 'body'] |     search_fields = ['headline', 'summary', 'body'] | ||||||
|     prepopulated_fields = { 'slug' : ("headline",), } |     prepopulated_fields = { 'slug' : ("headline",), } | ||||||
| 
 | 
 | ||||||
| admin.site.register(PressRelease, PressReleaseAdmin) |  | ||||||
| admin.site.register(ExternalArticleTag) | admin.site.register(ExternalArticleTag) | ||||||
| 
 | 
 | ||||||
|  | @admin.register(ExternalArticle) | ||||||
| class ExternalArticleAdmin(admin.ModelAdmin): | class ExternalArticleAdmin(admin.ModelAdmin): | ||||||
|     list_display = ("title", "publication", "visible", "date") |     list_display = ("title", "publication", "visible", "date") | ||||||
|     list_filter = ['date'] |     list_filter = ['date'] | ||||||
|     date_hierarchy = 'date' |     date_hierarchy = 'date' | ||||||
|     search_fields = ["title", "info", "publication"] |     search_fields = ["title", "info", "publication"] | ||||||
| 
 | 
 | ||||||
| admin.site.register(ExternalArticle, ExternalArticleAdmin) |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -21,13 +21,14 @@ from django.contrib import admin | ||||||
| from .models import Cast, CastTag | from .models import Cast, CastTag | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @admin.register(CastTag) | ||||||
| class CastTagAdmin(admin.ModelAdmin): | class CastTagAdmin(admin.ModelAdmin): | ||||||
|     prepopulated_fields = {'slug': ('label',)} |     prepopulated_fields = {'slug': ('label',)} | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| admin.site.register(CastTag, CastTagAdmin) |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @admin.register(Cast) | ||||||
| class CastAdmin(admin.ModelAdmin): | class CastAdmin(admin.ModelAdmin): | ||||||
|     list_display = ('pub_date', 'title') |     list_display = ('pub_date', 'title') | ||||||
|     list_filter = ['pub_date'] |     list_filter = ['pub_date'] | ||||||
|  | @ -37,4 +38,3 @@ class CastAdmin(admin.ModelAdmin): | ||||||
|     filter_horizontal = ('tags',) |     filter_horizontal = ('tags',) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| admin.site.register(Cast, CastAdmin) |  | ||||||
|  |  | ||||||
|  | @ -3,9 +3,9 @@ from django.contrib import admin | ||||||
| from .models import Person | from .models import Person | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @admin.register(Person) | ||||||
| class PersonAdmin(admin.ModelAdmin): | class PersonAdmin(admin.ModelAdmin): | ||||||
|     list_display = ("username", "formal_name", "casual_name", |     list_display = ("username", "formal_name", "casual_name", | ||||||
|                     "currently_employed") |                     "currently_employed") | ||||||
|     list_filter = ["currently_employed"] |     list_filter = ["currently_employed"] | ||||||
| 
 | 
 | ||||||
| admin.site.register(Person, PersonAdmin) |  | ||||||
|  |  | ||||||
|  | @ -3,8 +3,8 @@ from django.contrib import admin | ||||||
| from .models import SummitRegistration | from .models import SummitRegistration | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @admin.register(SummitRegistration) | ||||||
| class SummitRegistrationAdmin(admin.ModelAdmin): | class SummitRegistrationAdmin(admin.ModelAdmin): | ||||||
|     list_display = ('name', 'email', 'affiliation', 'cle_credit') |     list_display = ('name', 'email', 'affiliation', 'cle_credit') | ||||||
| 
 | 
 | ||||||
| admin.site.register(SummitRegistration, SummitRegistrationAdmin) |  | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ from django.contrib import admin | ||||||
| from .models import Supporter | from .models import Supporter | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @admin.register(Supporter) | ||||||
| class SupporterAdmin(admin.ModelAdmin): | class SupporterAdmin(admin.ModelAdmin): | ||||||
|     list_display = ('display_name', 'display_until_date') |     list_display = ('display_name', 'display_until_date') | ||||||
| 
 | 
 | ||||||
| admin.site.register(Supporter, SupporterAdmin) |  | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ from django.contrib import admin | ||||||
| from .models import EarthLocation | from .models import EarthLocation | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @admin.register(EarthLocation) | ||||||
| class EarthLocationAdmin(admin.ModelAdmin): | class EarthLocationAdmin(admin.ModelAdmin): | ||||||
|     list_display = ("label", "html_map_link") |     list_display = ("label", "html_map_link") | ||||||
| 
 | 
 | ||||||
| admin.site.register(EarthLocation, EarthLocationAdmin) |  | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue