summaryrefslogtreecommitdiff
path: root/program/admin.py
diff options
context:
space:
mode:
authorErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2014-04-29 22:22:00 (GMT)
committerErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2014-04-29 22:22:00 (GMT)
commitac251a798769bc5909d25a1f95a98822d46bfbb8 (patch)
tree46e3753599dbe8e02d6299a557ba707bedbd3acc /program/admin.py
parent185a79985c93c44e058ab4bf0345d2dafc4148ee (diff)
pep8-ized code
Diffstat (limited to 'program/admin.py')
-rw-r--r--program/admin.py43
1 files changed, 33 insertions, 10 deletions
diff --git a/program/admin.py b/program/admin.py
index 6a542bc..7b52fa4 100644
--- a/program/admin.py
+++ b/program/admin.py
@@ -1,28 +1,34 @@
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
-from models import BroadcastFormat, MusicFocus, ShowInformation, ShowTopic, Host, Note, ProgramSlot, Show, TimeSlot
+from models import (BroadcastFormat, MusicFocus, ShowInformation, ShowTopic,
+ Host, Note, ProgramSlot, Show, TimeSlot)
from forms import MusicFocusForm
from datetime import date
+
class BroadcastFormatAdmin(admin.ModelAdmin):
list_display = ('format', 'enabled', 'admin_color')
prepopulated_fields = {'slug': ('format',)}
+
class MusicFocusAdmin(admin.ModelAdmin):
form = MusicFocusForm
list_display = ('focus', 'abbrev', 'admin_buttons')
prepopulated_fields = {'slug': ('focus',)}
+
class ShowInformationAdmin(admin.ModelAdmin):
list_display = ('information', 'abbrev', 'admin_buttons')
prepopulated_fields = {'slug': ('information',)}
+
class ShowTopicAdmin(admin.ModelAdmin):
list_display = ('topic', 'abbrev', 'admin_buttons')
prepopulated_fields = {'slug': ('topic',)}
+
class NoteAdmin(admin.ModelAdmin):
date_hierarchy = 'start'
list_display = ('title', 'show', 'start', 'status')
@@ -33,49 +39,66 @@ class NoteAdmin(admin.ModelAdmin):
shows = request.user.shows.all()
return super(NoteAdmin, self).queryset(request).filter(show__in=shows)
- def formfield_for_foreignkey(self, db_field, request, **kwargs):
+ def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
if db_field.name == 'timeslot':
shows = request.user.shows.all()
kwargs['queryset'] = TimeSlot.objects.filter(show__in=shows)
- return super(NoteAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
+ return super(NoteAdmin, self).formfield_for_foreignkey(db_field,
+ request,
+ **kwargs)
def save_model(self, request, obj, form, change):
obj.save()
+
class TimeSlotInline(admin.TabularInline):
model = TimeSlot
+
def renew(modeladmin, request, queryset):
- next_year = date.today().year+1
+ next_year = date.today().year + 1
queryset.update(until=date(next_year, 12, 31))
+
+
renew.short_description = _("Renew selected time slots")
+
class ProgramSlotAdmin(admin.ModelAdmin):
actions = (renew,)
inlines = (TimeSlotInline,)
- list_display = ('show', 'byweekday', 'rrule', 'tstart', 'tend', 'until', 'timeslot_count')
+ list_display = ('show', 'byweekday', 'rrule', 'tstart', 'tend', 'until',
+ 'timeslot_count')
list_filter = ('byweekday', 'rrule', 'is_repetition')
ordering = ('byweekday', 'dstart')
save_on_top = True
search_fields = ('show__name',)
+
class ProgramSlotInline(admin.TabularInline):
model = ProgramSlot
+
class ShowAdmin(admin.ModelAdmin):
- filter_horizontal = ('hosts', 'owners', 'musicfocus', 'showinformation', 'showtopic')
+ filter_horizontal = ('hosts', 'owners', 'musicfocus', 'showinformation',
+ 'showtopic')
inlines = (ProgramSlotInline,)
- list_display = ('name', 'short_description', 'broadcastformat', 'has_active_programslots')
- list_filter = ('broadcastformat', 'showinformation', 'showtopic', 'musicfocus',)
+ list_display = ('name', 'short_description', 'broadcastformat',
+ 'has_active_programslots')
+ list_filter = ('broadcastformat', 'showinformation', 'showtopic',
+ 'musicfocus',)
ordering = ('slug',)
prepopulated_fields = {'slug': ('name',)}
search_fields = ('name', 'short_description', 'description')
fields = (
- 'predecessor', 'broadcastformat', 'name', 'slug', 'image', 'image_enabled', 'short_description', 'description', 'email',
- 'website', 'cba_series_id', 'automation_id', 'hosts', 'owners', 'showinformation', 'showtopic', 'musicfocus',
+ 'predecessor', 'broadcastformat', 'name', 'slug', 'image',
+ 'image_enabled', 'short_description', 'description',
+ 'email',
+ 'website', 'cba_series_id', 'automation_id', 'hosts', 'owners',
+ 'showinformation', 'showtopic', 'musicfocus',
)
+
admin.site.register(BroadcastFormat, BroadcastFormatAdmin)
admin.site.register(MusicFocus, MusicFocusAdmin)
admin.site.register(ShowInformation, ShowInformationAdmin)