diff options
-rw-r--r-- | program/admin.py | 12 | ||||
-rw-r--r-- | program/models.py | 94 | ||||
-rw-r--r-- | program/urls.py | 3 | ||||
-rw-r--r-- | program/views.py | 8 |
4 files changed, 111 insertions, 6 deletions
diff --git a/program/admin.py b/program/admin.py index 12e5e7a..52ca6b0 100644 --- a/program/admin.py +++ b/program/admin.py @@ -2,23 +2,25 @@ 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 forms import MusicFocusForm from datetime import date class BroadcastFormatAdmin(admin.ModelAdmin): - list_display = ('format',) + list_display = ('format', 'enabled', 'admin_color') prepopulated_fields = {'slug': ('format',)} class MusicFocusAdmin(admin.ModelAdmin): - list_display = ('focus', 'abbrev') + form = MusicFocusForm + list_display = ('focus', 'abbrev', 'admin_button') prepopulated_fields = {'slug': ('focus',)} class ShowInformationAdmin(admin.ModelAdmin): - list_display = ('information', 'abbrev') + list_display = ('information', 'abbrev', 'admin_button') prepopulated_fields = {'slug': ('information',)} class ShowTopicAdmin(admin.ModelAdmin): - list_display = ('topic', 'abbrev') + list_display = ('topic', 'abbrev', 'admin_button') prepopulated_fields = {'slug': ('topic',)} class NoteAdmin(admin.ModelAdmin): @@ -80,4 +82,4 @@ admin.site.register(Note, NoteAdmin) admin.site.register(ProgramSlot, ProgramSlotAdmin) admin.site.register(Show, ShowAdmin) -admin.site.register(Host)
\ No newline at end of file +admin.site.register(Host) diff --git a/program/models.py b/program/models.py index 8d415b8..9e6917c 100644 --- a/program/models.py +++ b/program/models.py @@ -12,12 +12,19 @@ from dateutil.rrule import rrule class BroadcastFormat(models.Model): format = models.CharField(_("Format"), max_length=32) slug = models.SlugField(_("Slug"), max_length=32, unique=True) + color = models.CharField(_("Color"), max_length=7, default='#ffffff') + enabled = models.BooleanField(_("Enabled"), default=True) class Meta: ordering = ('format',) verbose_name = _("Broadcast format") verbose_name_plural = _("Broadcast formats") + def admin_color(self): + return u'<span style="background-color:%s; padding: 0.2em">%s</span>' % (self.color, self.color) + admin_color.short_description = _("Color") + admin_color.allow_tags = True + def __unicode__(self): return u'%s' % self.format @@ -25,12 +32,41 @@ class ShowInformation(models.Model): information = models.CharField(_("Information"), max_length=32) abbrev = models.CharField(_("Abbreviation"), max_length=4, unique=True) slug = models.SlugField(_("Slug"), max_length=32, unique=True) + button = models.ImageField(_("Button image"), blank=True, null=True, upload_to='buttons') + button_hover = models.ImageField(_("Button image (hover)"), blank=True, null=True, upload_to='buttons') + big_button = models.ImageField(_("Big button image"), blank=True, null=True, upload_to='buttons') class Meta: ordering = ('information',) verbose_name = _("Show information") verbose_name_plural = _("Show information") + def admin_button(self): + if self.button: + return u'<img src="%s" />' % self.button.url + else: + return u'(no button)' + admin_button.short_description = _("Button") + admin_button.allow_tags = True + + def button_url(self): + if self.button: + return self.button.url + else: + return '/site_media/buttons/default-11.png' + + def button_hover_url(self): + if self.button_hover: + return self.button_hover.url + else: + return '/site_media/buttons/default-11.png' + + def big_button_url(self): + if self.big_button: + return self.big_button.url + else: + return '/site_media/buttons/default-17.png' + def __unicode__(self): return u'%s' % self.information @@ -38,12 +74,41 @@ class ShowTopic(models.Model): topic = models.CharField(_("Show topic"), max_length=32) abbrev = models.CharField(_("Abbreviation"), max_length=4, unique=True) slug = models.SlugField(_("Slug"), max_length=32, unique=True) + button = models.ImageField(_("Button image"), blank=True, null=True, upload_to='buttons') + button_hover = models.ImageField(_("Button image (hover)"), blank=True, null=True, upload_to='buttons') + big_button = models.ImageField(_("Big button image"), blank=True, null=True, upload_to='buttons') class Meta: ordering = ('topic',) verbose_name = _("Show topic") verbose_name_plural = _("Show topics") + def admin_button(self): + if self.button: + return u'<img src="%s" />' % self.button.url + else: + return u'(no button)' + admin_button.short_description = _("Button") + admin_button.allow_tags = True + + def button_url(self): + if self.button: + return self.button.url + else: + return '/site_media/buttons/default-11.png' + + def button_hover_url(self): + if self.button_hover: + return self.button_hover.url + else: + return '/site_media/buttons/default-11.png' + + def big_button_url(self): + if self.big_button: + return self.big_button.url + else: + return '/site_media/buttons/default-17.png' + def __unicode__(self): return u'%s' % self.topic @@ -51,12 +116,41 @@ class MusicFocus(models.Model): focus = models.CharField(_("Focus"), max_length=32) abbrev = models.CharField(_("Abbreviation"), max_length=4, unique=True) slug = models.SlugField(_("Slug"), max_length=32, unique=True) + button = models.ImageField(_("Button image"), blank=True, null=True, upload_to='buttons') + button_hover = models.ImageField(_("Button image (hover)"), blank=True, null=True, upload_to='buttons') + big_button = models.ImageField(_("Big button image"), blank=True, null=True, upload_to='buttons') class Meta: ordering = ('focus',) verbose_name = _("Music focus") verbose_name_plural = _("Music focus") + def admin_button(self): + if self.button: + return u'<img src="%s" />' % self.button.url + else: + return u'(no button)' + admin_button.short_description = _("Button") + admin_button.allow_tags = True + + def button_url(self): + if self.button: + return self.button.url + else: + return '/site_media/buttons/default-11.png' + + def button_hover_url(self): + if self.button_hover: + return self.button_hover.url + else: + return '/site_media/buttons/default-11.png' + + def big_button_url(self): + if self.big_button: + return self.big_button.url + else: + return '/site_media/buttons/default-17.png' + def __unicode__(self): return u'%s' % self.focus diff --git a/program/urls.py b/program/urls.py index 3aa1245..58dc0c0 100644 --- a/program/urls.py +++ b/program/urls.py @@ -4,7 +4,7 @@ from django.views.decorators.cache import cache_page from django.views.generic.list_detail import object_detail, object_list from models import Host, Show, TimeSlot -from views import current_show, day_schedule, recommendations, show_list, week_schedule +from views import current_show, day_schedule, recommendations, show_list, week_schedule, styles from datetime import date @@ -35,6 +35,7 @@ urlpatterns = patterns('', url(r'^shows/(?P<slug>[\w-]+)/?$', object_detail, shows_dict, name='show-detail'), url(r'^(?P<object_id>\d+)/?$', object_detail, timeslots_dict, name='timeslot-detail'), url(r'^week/?$', week_schedule), + url(r'^styles.css$', styles), ) if settings.DEBUG: diff --git a/program/views.py b/program/views.py index 83a5994..ec795cf 100644 --- a/program/views.py +++ b/program/views.py @@ -119,3 +119,11 @@ def week_schedule(request, year=None, week=None): extra_context['next_w4'] = datetime.strftime(monday+timedelta(days=28), '%Y/%W') return simple.direct_to_template(request, template='program/week_schedule.html', extra_context=extra_context) + +def styles(request): + extra_context = dict() + extra_context['broadcastformats'] = BroadcastFormat.objects.filter(enabled=True) + extra_context['musicfocus'] = MusicFocus.objects.all() + extra_context['showinformation'] = ShowInformation.objects.all() + extra_context['showtopic'] = ShowTopic.objects.all() + return simple.direct_to_template(request, template='program/styles.css', mimetype='text/css', extra_context=extra_context) |