From 185a79985c93c44e058ab4bf0345d2dafc4148ee Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Tue, 29 Apr 2014 23:12:42 +0200 Subject: updated requirements diff --git a/requirements.txt b/requirements.txt index 8567bc6..f089112 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -Django==1.4.10 +Django==1.4.12 MySQL-python==1.2.5 -Pillow==2.3.0 -PyYAML==3.10 +Pillow==2.4.0 +PyYAML==3.11 django-tinymce==1.5.2 python-dateutil==1.5 -- cgit v0.10.2 From ac251a798769bc5909d25a1f95a98822d46bfbb8 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 30 Apr 2014 00:22:00 +0200 Subject: pep8-ized code diff --git a/nop/models.py b/nop/models.py index 6aeb794..1b39eed 100644 --- a/nop/models.py +++ b/nop/models.py @@ -30,6 +30,7 @@ class Standby(models.Model): db_table = u'standby' ordering = ['-timestamp'] + class State(models.Model): timestamp = models.BigIntegerField(primary_key=True) state = models.CharField(max_length=96, blank=True) diff --git a/nop/urls.py b/nop/urls.py index c4012a6..0d7f279 100644 --- a/nop/urls.py +++ b/nop/urls.py @@ -8,7 +8,9 @@ NOP_STATIC_DIR = os.path.join(os.path.dirname(__file__), 'site_media') urlpatterns = patterns( '', url(r'^/get_current/?$', get_current), - url(r'^/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P\d{1,2})/(?P\d{1,2})/?$', get), + url(r'^/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P\d{1,2})/(?P\d{1,2})/?$', + get), url(r'^/?$', nop_form), - url(r'^/static/(?P.*)$', 'django.views.static.serve', {'document_root': NOP_STATIC_DIR}), + url(r'^/static/(?P.*)$', 'django.views.static.serve', + {'document_root': NOP_STATIC_DIR}), ) diff --git a/nop/views.py b/nop/views.py index 9d71379..967a81c 100644 --- a/nop/views.py +++ b/nop/views.py @@ -59,7 +59,8 @@ def _which(timestamp=None): def _get_show(datetime=None): try: if datetime: - timeslot = TimeSlot.objects.get(start__lte=datetime, end__gt=datetime) + timeslot = TimeSlot.objects.get(start__lte=datetime, + end__gt=datetime) else: timeslot = TimeSlot.objects.get_or_create_current() except (ObjectDoesNotExist, MultipleObjectsReturned): @@ -82,7 +83,8 @@ def _current(): album = None show = _get_show() - if show['id'] in MUSIKPROG_IDS or (show['id'] in SPECIAL_PROGRAM_IDS and not show['note']): + if show['id'] in MUSIKPROG_IDS \ + or (show['id'] in SPECIAL_PROGRAM_IDS and not show['note']): result = _which().objects.using(DB).all()[0] artist = result.artist title = result.title @@ -105,7 +107,8 @@ def _bydate(year=None, month=None, day=None, hour=None, minute=None): 'title': None, 'album': None}] else: - ts = int(time.mktime((int(year), int(month), int(day), int(hour), int(minute), 0, 0, 0, -1))) * 1000000 + ts = int(time.mktime((int(year), int(month), int(day), int(hour), + int(minute), 0, 0, 0, -1))) * 1000000 result = _which(ts).objects.using(DB).filter(timestamp__lt=ts)[:5] return [{'show': show['name'], 'start': _dtstring(time.localtime(item.timestamp//1000000)), @@ -129,14 +132,16 @@ def nop_form(request): date = None time = None - if request.method == 'GET' and ('date' in request.GET or 'time' in request.GET): + if request.method == 'GET' \ + and ('date' in request.GET or 'time' in request.GET): form = NopForm(request.GET) if form.is_valid(): date = form.cleaned_data['date'] time = form.cleaned_data['time'] else: - form = NopForm(initial={'date': datetime.date(datetime.now()), 'time': datetime.time(datetime.now())}) + form = NopForm(initial={'date': datetime.date(datetime.now()), + 'time': datetime.time(datetime.now())}) if not date: date = datetime.date(datetime.now()) 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) diff --git a/program/forms.py b/program/forms.py index 0ecd371..0c33b20 100644 --- a/program/forms.py +++ b/program/forms.py @@ -1,15 +1,16 @@ -from django import forms +from django.forms import ModelForm, ValidationError from django.core.files.images import get_image_dimensions from program.models import MusicFocus, ShowInformation, ShowTopic -class FormWithButton(forms.ModelForm): + +class FormWithButton(ModelForm): def clean_button(self): button = self.cleaned_data.get('button') if button: width, height = get_image_dimensions(button) if width != 11 or height != 11: - raise forms.ValidationError("width or height is not 11, (11x11)") + raise ValidationError("width or height is not 11, (11x11)") return button def clean_button_hover(self): @@ -17,7 +18,7 @@ class FormWithButton(forms.ModelForm): if button_hover: width, height = get_image_dimensions(button_hover) if width != 11 or height != 11: - raise forms.ValidationError("width or height is not 11, (11x11)") + raise ValidationError("width or height is not 11, (11x11)") return button_hover def clean_big_button(self): @@ -25,18 +26,20 @@ class FormWithButton(forms.ModelForm): if big_button: width, height = get_image_dimensions(big_button) if width != 17 or height != 17: - raise forms.ValidationError("width or height is not 17, (17x17)") + raise ValidationError("width or height is not 17, (17x17)") return big_button + class MusicFocusForm(FormWithButton): class Meta: model = MusicFocus + class ShowInformationForm(FormWithButton): class Meta: model = ShowInformation + class ShowTopicForm(FormWithButton): class Meta: model = ShowTopic - diff --git a/program/management/__init__.py b/program/management/__init__.py index 3aa4ca5..e69de29 100644 --- a/program/management/__init__.py +++ b/program/management/__init__.py @@ -1,2 +0,0 @@ -__author__ = 'ers' - \ No newline at end of file diff --git a/program/management/commands/__init__.py b/program/management/commands/__init__.py index 3aa4ca5..e69de29 100644 --- a/program/management/commands/__init__.py +++ b/program/management/commands/__init__.py @@ -1,2 +0,0 @@ -__author__ = 'ers' - \ No newline at end of file diff --git a/program/models.py b/program/models.py index 7cdc345..50b5889 100644 --- a/program/models.py +++ b/program/models.py @@ -1,5 +1,6 @@ from django.contrib.auth.models import User -from django.core.exceptions import ObjectDoesNotExist, ValidationError, MultipleObjectsReturned +from django.core.exceptions import (ObjectDoesNotExist, ValidationError, + MultipleObjectsReturned) from django.db import models from django.utils.translation import ugettext_lazy as _ @@ -11,11 +12,13 @@ from dateutil.rrule import rrule from utils import get_automation_id_choices + 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') - text_color = models.CharField(_("Text color"), max_length=7, default='#000000') + text_color = models.CharField(_("Text color"), max_length=7, + default='#000000') enabled = models.BooleanField(_("Enabled"), default=True) class Meta: @@ -24,20 +27,26 @@ class BroadcastFormat(models.Model): verbose_name_plural = _("Broadcast formats") def admin_color(self): - return u'%s/%s' % (self.color, self.text_color, self.color, self.text_color) + return u'%s/%s' % ( + self.color, self.text_color, self.color, self.text_color) + admin_color.short_description = _("Color") admin_color.allow_tags = True def __unicode__(self): return u'%s' % self.format + 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') + 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',) @@ -62,6 +71,7 @@ class ShowInformation(models.Model): buttons.append(u'x') return ' '.join(buttons) + admin_buttons.short_description = _("Buttons") admin_buttons.allow_tags = True @@ -86,13 +96,17 @@ class ShowInformation(models.Model): def __unicode__(self): return u'%s' % self.information + 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') + 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',) @@ -117,6 +131,7 @@ class ShowTopic(models.Model): buttons.append(u'x') return ' '.join(buttons) + admin_buttons.short_description = _("Buttons") admin_buttons.allow_tags = True @@ -141,13 +156,17 @@ class ShowTopic(models.Model): def __unicode__(self): return u'%s' % self.topic + 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') + 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',) @@ -172,6 +191,7 @@ class MusicFocus(models.Model): buttons.append(u'x') return ' '.join(buttons) + admin_buttons.short_description = _("Buttons") admin_buttons.allow_tags = True @@ -196,15 +216,16 @@ class MusicFocus(models.Model): def __unicode__(self): return u'%s' % self.focus + class Host(models.Model): name = models.CharField(_("Name"), max_length=128) email = models.EmailField(_("E-Mail"), blank=True) website = models.URLField(_("Website"), blank=True) class Meta: - ordering = ('name',) - verbose_name = _("Host") - verbose_name_plural = _("Hosts") + ordering = ('name',) + verbose_name = _("Host") + verbose_name_plural = _("Hosts") def __unicode__(self): return u'%s' % self.name @@ -213,24 +234,43 @@ class Host(models.Model): def get_absolute_url(self): return ('host-detail', [str(self.id)]) + class Show(models.Model): - predecessor = models.ForeignKey('self', blank=True, null=True, related_name='successors', verbose_name=_("Predecessor")) - hosts = models.ManyToManyField(Host, blank=True, null=True, related_name='shows', verbose_name=_("Hosts")) - owners = models.ManyToManyField(User, blank=True, null=True, related_name='shows', verbose_name=_("Owners")) - broadcastformat = models.ForeignKey(BroadcastFormat, related_name='shows', verbose_name=_("Broadcast format")) - showinformation = models.ManyToManyField(ShowInformation, blank=True, null=True, related_name='shows', verbose_name=_("Show information")) - showtopic = models.ManyToManyField(ShowTopic, blank=True, null=True, related_name='shows', verbose_name=_("Show topic")) - musicfocus = models.ManyToManyField(MusicFocus, blank=True, null=True, related_name='shows', verbose_name=_("Music focus")) + predecessor = models.ForeignKey('self', blank=True, null=True, + related_name='successors', + verbose_name=_("Predecessor")) + hosts = models.ManyToManyField(Host, blank=True, null=True, + related_name='shows', + verbose_name=_("Hosts")) + owners = models.ManyToManyField(User, blank=True, null=True, + related_name='shows', + verbose_name=_("Owners")) + broadcastformat = models.ForeignKey(BroadcastFormat, related_name='shows', + verbose_name=_("Broadcast format")) + showinformation = models.ManyToManyField(ShowInformation, blank=True, + null=True, related_name='shows', + verbose_name=_("Show information")) + showtopic = models.ManyToManyField(ShowTopic, blank=True, null=True, + related_name='shows', + verbose_name=_("Show topic")) + musicfocus = models.ManyToManyField(MusicFocus, blank=True, null=True, + related_name='shows', + verbose_name=_("Music focus")) name = models.CharField(_("Name"), max_length=255) slug = models.CharField(_("Slug"), max_length=255, unique=True) - image = models.ImageField(_("Image"), blank=True, null=True, upload_to='show_images') - image_enabled = models.BooleanField(_("show Image"), default=True ) + image = models.ImageField(_("Image"), blank=True, null=True, + upload_to='show_images') + image_enabled = models.BooleanField(_("show Image"), default=True) short_description = models.CharField(_("Short description"), max_length=64) - description = tinymce_models.HTMLField(_("Description"), blank=True, null=True) + description = tinymce_models.HTMLField(_("Description"), blank=True, + null=True) email = models.EmailField(_("E-Mail"), blank=True, null=True) website = models.URLField(_("Website"), blank=True, null=True) - cba_series_id = models.IntegerField(_("CBA series ID"), blank=True, null=True) - automation_id = models.IntegerField(_("Automation ID"), blank=True, null=True, choices=get_automation_id_choices()) + cba_series_id = models.IntegerField(_("CBA series ID"), blank=True, + null=True) + automation_id = models.IntegerField(_("Automation ID"), blank=True, + null=True, + choices=get_automation_id_choices()) created = models.DateTimeField(auto_now_add=True, editable=False) last_updated = models.DateTimeField(auto_now=True, editable=False) @@ -247,10 +287,12 @@ class Show(models.Model): return ('show-detail', [self.slug]) def has_active_programslots(self): - return self.programslots.filter(until__gt=date.today()).count() > 0 + return self.programslots.filter(until__gt=date.today()).count() > 0 + has_active_programslots.boolean = True has_active_programslots.short_description = _("Has active program slots") + class RRule(models.Model): FREQ_CHOICES = ( (1, _("Monthly")), @@ -268,7 +310,8 @@ class RRule(models.Model): name = models.CharField(_("Name"), max_length=32, unique=True) freq = models.IntegerField(_("Frequency"), choices=FREQ_CHOICES) interval = models.IntegerField(_("Interval"), default=1) - bysetpos = models.IntegerField(_("Set position"), blank=True, choices=BYSETPOS_CHOICES, null=True) + bysetpos = models.IntegerField(_("Set position"), blank=True, + choices=BYSETPOS_CHOICES, null=True) count = models.IntegerField(_("Count"), blank=True, null=True) class Meta: @@ -279,6 +322,7 @@ class RRule(models.Model): def __unicode__(self): return u'%s' % self.name + class ProgramSlot(models.Model): BYWEEKDAY_CHOICES = ( (0, _("Monday")), @@ -289,15 +333,19 @@ class ProgramSlot(models.Model): (5, _("Saturday")), (6, _("Sunday")), ) - rrule = models.ForeignKey(RRule, related_name='programslots', verbose_name=_("Recurrence rule")) + rrule = models.ForeignKey(RRule, related_name='programslots', + verbose_name=_("Recurrence rule")) byweekday = models.IntegerField(_("Weekday"), choices=BYWEEKDAY_CHOICES) - show = models.ForeignKey(Show, related_name='programslots', verbose_name=_("Show")) + show = models.ForeignKey(Show, related_name='programslots', + verbose_name=_("Show")) dstart = models.DateField(_("First date")) tstart = models.TimeField(_("Start time")) tend = models.TimeField(_("End time")) until = models.DateField(_("Last date")) is_repetition = models.BooleanField(_("Is repetition"), default=False) - automation_id = models.IntegerField(_("Automation ID"), blank=True, null=True, choices=get_automation_id_choices()) + automation_id = models.IntegerField(_("Automation ID"), blank=True, + null=True, + choices=get_automation_id_choices()) created = models.DateTimeField(auto_now_add=True, editable=False) last_updated = models.DateTimeField(auto_now=True, editable=False) @@ -323,7 +371,13 @@ class ProgramSlot(models.Model): def save(self, *args, **kwargs): if self.pk: old = ProgramSlot.objects.get(pk=self.pk) - if self.rrule != old.rrule or self.byweekday != old.byweekday or self.show != old.show or self.dstart != old.dstart or self.tstart != old.tstart or self.tend != old.tend or self.is_repetition != old.is_repetition: + if self.rrule != old.rrule \ + or self.byweekday != old.byweekday \ + or self.show != old.show \ + or self.dstart != old.dstart \ + or self.tstart != old.tstart \ + or self.tend != old.tend \ + or self.is_repetition != old.is_repetition: raise ValidationError(u"only until can be changed") else: old = False @@ -353,28 +407,33 @@ class ProgramSlot(models.Model): dend = self.dstart starts = list(rrule(freq=self.rrule.freq, - dtstart=datetime.combine(self.dstart, self.tstart), - interval=self.rrule.interval, - until=self.until+relativedelta(days=+1), - bysetpos=self.rrule.bysetpos, - byweekday=byweekday_start)) + dtstart=datetime.combine(self.dstart, self.tstart), + interval=self.rrule.interval, + until=self.until + relativedelta(days=+1), + bysetpos=self.rrule.bysetpos, + byweekday=byweekday_start)) ends = list(rrule(freq=self.rrule.freq, - dtstart=datetime.combine(dend, self.tend), - interval=self.rrule.interval, - until=self.until+relativedelta(days=+1), - bysetpos=self.rrule.bysetpos, - byweekday=byweekday_end)) + dtstart=datetime.combine(dend, self.tend), + interval=self.rrule.interval, + until=self.until + relativedelta(days=+1), + bysetpos=self.rrule.bysetpos, + byweekday=byweekday_end)) if not old: for k in range(min(len(starts), len(ends))): - timeslot = TimeSlot.objects.create(programslot=self, start=starts[k], end=ends[k]) + timeslot = TimeSlot.objects.create(programslot=self, + start=starts[k], + end=ends[k]) elif self.until > old.until: for k in range(min(len(starts), len(ends))): if starts[k].date() > old.until: - timeslot = TimeSlot.objects.create(programslot=self, start=starts[k], end=ends[k]) + timeslot = TimeSlot.objects.create(programslot=self, + start=starts[k], + end=ends[k]) def timeslot_count(self): return self.timeslots.count() + timeslot_count.description = _("Time slot count") def has_active_timeslot(self): @@ -386,12 +445,15 @@ class ProgramSlot(models.Model): else: return False + class TimeSlotManager(models.Manager): def get_or_create_current(self): try: - return TimeSlot.objects.get(start__lte=datetime.now(), end__gt=datetime.now()) + return TimeSlot.objects.get(start__lte=datetime.now(), + end__gt=datetime.now()) except MultipleObjectsReturned: - return TimeSlot.objects.filter(start__lte=datetime.now(), end__gt=datetime.now())[0] + return TimeSlot.objects.filter(start__lte=datetime.now(), + end__gt=datetime.now())[0] except ObjectDoesNotExist: once = RRule.objects.get(pk=1) today = date.today().weekday() @@ -403,7 +465,10 @@ class TimeSlotManager(models.Manager): dstart, tstart = previous.end.date(), previous.end.time() until, tend = next.start.date(), next.start.time() - new_programslot = ProgramSlot(rrule=once, byweekday=today, show=default, dstart=dstart, tstart=tstart, tend=tend, until=until) + new_programslot = ProgramSlot(rrule=once, byweekday=today, + show=default, dstart=dstart, + tstart=tstart, tend=tend, + until=until) try: new_programslot.validate_unique() new_programslot.save() @@ -413,20 +478,26 @@ class TimeSlotManager(models.Manager): return new_programslot.timeslots.all()[0] def get_day_timeslots(self, day): - today = datetime.combine(day, time(6,0)) + today = datetime.combine(day, time(6, 0)) tomorrow = today + timedelta(days=1) - return TimeSlot.objects.filter(models.Q(start__lte=today, end__gte=today) | - models.Q(start__gt=today, start__lt=tomorrow)).exclude(end=today) + return TimeSlot.objects.filter(models.Q(start__lte=today, + end__gte=today) | + models.Q(start__gt=today, + start__lt=tomorrow)).exclude(end=today) def get_24h_timeslots(self, start): end = start + timedelta(hours=24) - return TimeSlot.objects.filter(models.Q(start__lte=start, end__gte=start) | - models.Q(start__gt=start, start__lt=end)).exclude(end=start) + return TimeSlot.objects.filter(models.Q(start__lte=start, + end__gte=start) | + models.Q(start__gt=start, + start__lt=end)).exclude(end=start) + class TimeSlot(models.Model): - programslot = models.ForeignKey(ProgramSlot, related_name='timeslots', verbose_name=_("Program slot")) + programslot = models.ForeignKey(ProgramSlot, related_name='timeslots', + verbose_name=_("Program slot")) start = models.DateTimeField(_("Start time"), unique=True) end = models.DateTimeField(_("End time")) show = models.ForeignKey(Show, editable=False, related_name='timeslots') @@ -452,6 +523,7 @@ class TimeSlot(models.Model): def get_absolute_url(self): return ('timeslot-detail', [self.id]) + class Note(models.Model): STATUS_CHOICES = ( (0, _("Cancellation")), @@ -461,8 +533,10 @@ class Note(models.Model): timeslot = models.OneToOneField(TimeSlot, verbose_name=_("Time slot")) title = models.CharField(_("Title"), max_length=128) content = tinymce_models.HTMLField(_("Content")) - status = models.IntegerField(_("Status"), choices=STATUS_CHOICES, default=1) - cba_entry_id = models.IntegerField(_("CBA entry ID"), blank=True, null=True) + status = models.IntegerField(_("Status"), choices=STATUS_CHOICES, + default=1) + cba_entry_id = models.IntegerField(_("CBA entry ID"), blank=True, + null=True) start = models.DateTimeField(editable=False) show = models.ForeignKey(Show, editable=False, related_name='notes') created = models.DateTimeField(auto_now_add=True, editable=False) @@ -477,7 +551,7 @@ class Note(models.Model): return u'%s - %s' % (self.title, self.timeslot) def save(self, *args, **kwargs): - self.start = self.timeslot.start + self.start = self.timeslot.start self.show = self.timeslot.programslot.show super(Note, self).save(*args, **kwargs) diff --git a/program/templatetags/content_boxes.py b/program/templatetags/content_boxes.py index b56f0d2..6e2b6c7 100644 --- a/program/templatetags/content_boxes.py +++ b/program/templatetags/content_boxes.py @@ -5,21 +5,25 @@ register = template.Library() from program.models import BroadcastFormat, MusicFocus, ShowInformation, ShowTopic + @register.inclusion_tag('boxes/broadcastformat.html') def broadcastformat(): broadcastformats = BroadcastFormat.objects.filter(enabled=True) return {'broadcastformats': broadcastformats} + @register.inclusion_tag('boxes/musicfocus.html') def musicfocus(): musicfoci = MusicFocus.objects.all() return {'musicfoci': musicfoci} + @register.inclusion_tag('boxes/showinformation.html') def showinformation(): showinformations = ShowInformation.objects.all() return {'showinformations': showinformations} + @register.inclusion_tag('boxes/showtopic.html') def showtopic(): showtopics = ShowTopic.objects.all() diff --git a/program/templatetags/timeslots.py b/program/templatetags/timeslots.py index 902de36..c2c44b5 100644 --- a/program/templatetags/timeslots.py +++ b/program/templatetags/timeslots.py @@ -4,19 +4,22 @@ register = template.Library() from datetime import datetime, time, timedelta + @register.simple_tag def duration(start, end): return 'style="height: %dpx"' % ((end-start).seconds/60) + @register.simple_tag def duration_until(end): - start = datetime.combine(end.date(), time(6,0)) + start = datetime.combine(end.date(), time(6, 0)) return 'style="height: %dpx"' % ((end-start).seconds/60) + @register.simple_tag def duration_since(start): - if start.time() < time(23,59): - end = datetime.combine(start.date()+timedelta(days=1), time(6,0)) + if start.time() < time(23, 59): + end = datetime.combine(start.date()+timedelta(days=1), time(6, 0)) else: - end = datetime.combine(start.date(), time(6,0)) - return 'style="height: %dpx"' % ((end-start).seconds/60) \ No newline at end of file + end = datetime.combine(start.date(), time(6, 0)) + return 'style="height: %dpx"' % ((end-start).seconds/60) diff --git a/program/urls.py b/program/urls.py index 59caa2a..fbdc037 100644 --- a/program/urls.py +++ b/program/urls.py @@ -4,16 +4,19 @@ 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, styles +from views import current_show, day_schedule, recommendations, show_list, \ + week_schedule, styles from datetime import date hosts_dict = { - 'queryset': Host.objects.filter(shows__programslots__until__gte=date.today()).distinct(), + 'queryset': Host.objects.filter( + shows__programslots__until__gte=date.today()).distinct(), 'template_object_name': 'host' } shows_dict = { - 'queryset': Show.objects.filter(programslots__until__gt=date.today()).exclude(id=1).distinct(), + 'queryset': Show.objects.filter( + programslots__until__gt=date.today()).exclude(id=1).distinct(), 'template_object_name': 'show' } timeslots_dict = { @@ -23,24 +26,38 @@ timeslots_dict = { recommendations_dict = {'template_name': 'boxes/recommendations.html'} urlpatterns = patterns('', - url(r'^today/?$', day_schedule), - url(r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/?$', day_schedule), - url(r'^(?P\d{4})/(?P\d{1,2})/?$', week_schedule), - url(r'^current_box/?$', cache_page(current_show, 60)), - url(r'^hosts/?$', object_list, dict(hosts_dict, template_name='host_list.html')), - url(r'^hosts/(?P\d+)/?$', object_detail, dict(hosts_dict, template_name='host_detail.html'), name='host-detail'), - url(r'^tips/?$', recommendations), - url(r'^tips_box/?$', recommendations, recommendations_dict), - url(r'^shows/?$', show_list), - url(r'^shows/(?P[\w-]+)/?$', object_detail, dict(shows_dict, template_name='show_detail.html'), name='show-detail'), - url(r'^(?P\d+)/?$', object_detail, dict(timeslots_dict, template_name='timeslot_detail.html'), name='timeslot-detail'), - url(r'^week/?$', week_schedule), - url(r'^styles.css$', styles), -) + url(r'^today/?$', day_schedule), + url(r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/?$', + day_schedule), + url(r'^(?P\d{4})/(?P\d{1,2})/?$', + week_schedule), + url(r'^current_box/?$', cache_page(current_show, 60)), + url(r'^hosts/?$', + object_list, + dict(hosts_dict, template_name='host_list.html')), + url(r'^hosts/(?P\d+)/?$', object_detail, + dict(hosts_dict, template_name='host_detail.html'), + name='host-detail'), + url(r'^tips/?$', recommendations), + url(r'^tips_box/?$', recommendations, + recommendations_dict), + url(r'^shows/?$', show_list), + url(r'^shows/(?P[\w-]+)/?$', object_detail, + dict(shows_dict, template_name='show_detail.html'), + name='show-detail'), + url(r'^(?P\d+)/?$', object_detail, + dict(timeslots_dict, + template_name='timeslot_detail.html'), + name='timeslot-detail'), + url(r'^week/?$', week_schedule), + url(r'^styles.css$', styles)) if settings.DEBUG: import os - PROGRAM_STATIC_DIR = os.path.join(os.path.dirname(__file__), '../site_media') + + PROGRAM_STATIC_DIR = os.path.join(os.path.dirname(__file__), + '../site_media') urlpatterns += patterns('', - url(r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': PROGRAM_STATIC_DIR}), - ) + url(r'^static/(?P.*)$', + 'django.views.static.serve', + {'document_root': PROGRAM_STATIC_DIR})) diff --git a/program/views.py b/program/views.py index bc7700e..e01868a 100644 --- a/program/views.py +++ b/program/views.py @@ -1,27 +1,31 @@ +from datetime import date, datetime, time, timedelta +import json + from django.views.generic import list_detail, simple from django.shortcuts import get_object_or_404 from django.db.models import Q from django.http import HttpResponse -from models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, ShowTopic, TimeSlot +from models import (BroadcastFormat, MusicFocus, Note, Show, ShowInformation, + ShowTopic, TimeSlot) -from datetime import date, datetime, time, timedelta - -import json def show_list(request): queryset = Show.objects.filter(programslots__until__gt=date.today()).exclude(id=1).distinct() if 'broadcastformat' in request.GET: - broadcastformat = get_object_or_404(BroadcastFormat, slug=request.GET['broadcastformat']) + broadcastformat = get_object_or_404(BroadcastFormat, + slug=request.GET['broadcastformat']) queryset = queryset.filter(broadcastformat=broadcastformat) elif 'musicfocus' in request.GET: - musicfocus = get_object_or_404(MusicFocus, slug=request.GET['musicfocus']) + musicfocus = get_object_or_404(MusicFocus, + slug=request.GET['musicfocus']) queryset = queryset.filter(musicfocus=musicfocus) elif 'showinformation' in request.GET: - showinformation = get_object_or_404(ShowInformation, slug=request.GET['showinformation']) + showinformation = get_object_or_404(ShowInformation, + slug=request.GET['showinformation']) queryset = queryset.filter(showinformation=showinformation) elif 'showtopic' in request.GET: @@ -29,42 +33,57 @@ def show_list(request): queryset = queryset.filter(showtopic=showtopic) - return list_detail.object_list(request, queryset=queryset, template_object_name='show', template_name='show_list.html') + return list_detail.object_list(request, queryset=queryset, + template_object_name='show', + template_name='show_list.html') + def recommendations(request, template_name='recommendations.html'): now = datetime.now() end = now + timedelta(weeks=1) - queryset = TimeSlot.objects.filter(Q(note__isnull=False, note__status=1, start__range=(now, end)) | - Q(show__broadcastformat__slug='sondersendung', start__range=(now, end))).order_by('start')[:20] - return list_detail.object_list(request, queryset=queryset, template_name=template_name, template_object_name='recommendation') + queryset = TimeSlot.objects.filter(Q(note__isnull=False, note__status=1, + start__range=(now, end)) | + Q(show__broadcastformat__slug='sondersendung', + start__range=(now, end))).order_by('start')[:20] + return list_detail.object_list(request, queryset=queryset, + template_name=template_name, + template_object_name='recommendation') + def day_schedule(request, year=None, month=None, day=None): if year is None and month is None and day is None: today = datetime.combine(date.today(), time(6, 0)) else: - today = datetime.strptime('%s__%s__%s__06__00' % (year, month, day), '%Y__%m__%d__%H__%M') + today = datetime.strptime('%s__%s__%s__06__00' % (year, month, day), + '%Y__%m__%d__%H__%M') - tomorrow = today+timedelta(days=1) + tomorrow = today + timedelta(days=1) - recommendations = Note.objects.filter(status=1, timeslot__start__range=(today, tomorrow)) + recommendations = Note.objects.filter(status=1, + timeslot__start__range=(today, + tomorrow)) default_show = Show.objects.get(pk=1) - extra_context = dict(day=today, recommendations=recommendations, default_show=default_show) + extra_context = dict(day=today, recommendations=recommendations, + default_show=default_show) timeslots = TimeSlot.objects.get_day_timeslots(today) if 'broadcastformat' in request.GET: - broadcastformat = get_object_or_404(BroadcastFormat, slug=request.GET['broadcastformat']) + broadcastformat = get_object_or_404(BroadcastFormat, + slug=request.GET['broadcastformat']) extra_context['timeslots'] = timeslots.filter(show__broadcastformat=broadcastformat) elif 'musicfocus' in request.GET: - musicfocus = get_object_or_404(MusicFocus, slug=request.GET['musicfocus']) + musicfocus = get_object_or_404(MusicFocus, + slug=request.GET['musicfocus']) extra_context['timeslots'] = timeslots.filter(show__musicfocus=musicfocus) elif 'showinformation' in request.GET: - showinformation = get_object_or_404(ShowInformation, slug=request.GET['showinformation']) + showinformation = get_object_or_404(ShowInformation, + slug=request.GET['showinformation']) extra_context['timeslots'] = timeslots.filter(show__showinformation=showinformation) elif 'showtopic' in request.GET: @@ -74,7 +93,9 @@ def day_schedule(request, year=None, month=None, day=None): else: extra_context['timeslots'] = timeslots - return simple.direct_to_template(request, extra_context=extra_context, template='day_schedule.html') + return simple.direct_to_template(request, extra_context=extra_context, + template='day_schedule.html') + def current_show(request): current = TimeSlot.objects.get_or_create_current() @@ -83,27 +104,32 @@ def current_show(request): after_next = next.get_next_by_start() extra_context = dict(current=current, - previous=previous, - next=next, - after_next=after_next) + previous=previous, + next=next, + after_next=after_next) + + return simple.direct_to_template(request, template='boxes/current.html', + extra_context=extra_context) - return simple.direct_to_template(request, template='boxes/current.html', extra_context=extra_context) def week_schedule(request, year=None, week=None): if year is None and week is None: year, week = datetime.strftime(datetime.now(), '%G__%V').split('__') monday = tofirstdayinisoweek(int(year), int(week)) - tuesday = monday+timedelta(days=1) - wednesday = monday+timedelta(days=2) - thursday = monday+timedelta(days=3) - friday = monday+timedelta(days=4) - saturday = monday+timedelta(days=5) - sunday = monday+timedelta(days=6) + tuesday = monday + timedelta(days=1) + wednesday = monday + timedelta(days=2) + thursday = monday + timedelta(days=3) + friday = monday + timedelta(days=4) + saturday = monday + timedelta(days=5) + sunday = monday + timedelta(days=6) default_show = Show.objects.get(pk=1) - extra_context = dict(monday=monday, tuesday=tuesday, wednesday=wednesday, thursday=thursday, friday=friday, saturday=saturday, sunday=sunday, default_show=default_show) + extra_context = dict(monday=monday, tuesday=tuesday, wednesday=wednesday, + thursday=thursday, friday=friday, + saturday=saturday, sunday=sunday, + default_show=default_show) extra_context['monday_timeslots'] = TimeSlot.objects.get_day_timeslots(monday) extra_context['tuesday_timeslots'] = TimeSlot.objects.get_day_timeslots(tuesday) @@ -113,14 +139,21 @@ def week_schedule(request, year=None, week=None): extra_context['saturday_timeslots'] = TimeSlot.objects.get_day_timeslots(saturday) extra_context['sunday_timeslots'] = TimeSlot.objects.get_day_timeslots(sunday) - extra_context['last_w'] = datetime.strftime(monday-timedelta(days=7), '%G/%V') + extra_context['last_w'] = datetime.strftime(monday - timedelta(days=7), + '%G/%V') extra_context['cur_w'] = datetime.strftime(monday, '%G/%V') - extra_context['next_w1'] = datetime.strftime(monday+timedelta(days=7), '%G/%V') - extra_context['next_w2'] = datetime.strftime(monday+timedelta(days=14), '%G/%V') - extra_context['next_w3'] = datetime.strftime(monday+timedelta(days=21), '%G/%V') - extra_context['next_w4'] = datetime.strftime(monday+timedelta(days=28), '%G/%V') + extra_context['next_w1'] = datetime.strftime(monday + timedelta(days=7), + '%G/%V') + extra_context['next_w2'] = datetime.strftime(monday + timedelta(days=14), + '%G/%V') + extra_context['next_w3'] = datetime.strftime(monday + timedelta(days=21), + '%G/%V') + extra_context['next_w4'] = datetime.strftime(monday + timedelta(days=28), + '%G/%V') + + return simple.direct_to_template(request, template='week_schedule.html', + extra_context=extra_context) - return simple.direct_to_template(request, template='week_schedule.html', extra_context=extra_context) def styles(request): extra_context = dict() @@ -128,25 +161,37 @@ def styles(request): 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='styles.css', mimetype='text/css', extra_context=extra_context) + return simple.direct_to_template(request, template='styles.css', + mimetype='text/css', + extra_context=extra_context) + def json_day_schedule(request, year=None, month=None, day=None): if year is None and month is None and day is None: today = datetime.combine(date.today(), time(0, 0)) else: - today = datetime.strptime('%s__%s__%s__00__00' % (year, month, day), '%Y__%m__%d__%H__%M') + today = datetime.strptime('%s__%s__%s__00__00' % (year, month, day), + '%Y__%m__%d__%H__%M') timeslots = TimeSlot.objects.get_24h_timeslots(today) schedule = [] for ts in timeslots: if ts.programslot.automation_id: - schedule.append((ts.start.strftime('%H:%M:%S'), ts.programslot.show.name, ts.programslot.automation_id)) + schedule.append((ts.start.strftime('%H:%M:%S'), + ts.programslot.show.name, + ts.programslot.automation_id)) elif ts.programslot.show.automation_id: - schedule.append((ts.start.strftime('%H:%M:%S'), ts.programslot.show.name, ts.programslot.show.automation_id)) + schedule.append( + (ts.start.strftime('%H:%M:%S'), ts.programslot.show.name, + ts.programslot.show.automation_id)) else: - schedule.append((ts.start.strftime('%H:%M:%S'), ts.programslot.show.name, -1)) + schedule.append((ts.start.strftime('%H:%M:%S'), + ts.programslot.show.name, -1)) + + return HttpResponse(json.dumps(schedule, ensure_ascii=False, + encoding='utf8').encode('utf8'), + content_type="application/json; charset=utf-8") - return HttpResponse(json.dumps(schedule, ensure_ascii=False, encoding='utf8').encode('utf8'), content_type="application/json; charset=utf-8") def tofirstdayinisoweek(year, week): # http://stackoverflow.com/questions/5882405/get-date-from-iso-week-number-in-python diff --git a/pv/settings.py b/pv/settings.py index cf1da74..7ef0067 100644 --- a/pv/settings.py +++ b/pv/settings.py @@ -1,12 +1,13 @@ # Django settings for pv project. import os.path + PROJECT_DIR = os.path.dirname(__file__) DEBUG = True TEMPLATE_DEBUG = DEBUG -ADMINS = ( ) +ADMINS = () MANAGERS = ADMINS @@ -42,7 +43,7 @@ SECRET_KEY = '' TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', -# 'django.template.loaders.eggs.Loader', + # 'django.template.loaders.eggs.Loader', ) MIDDLEWARE_CLASSES = ( @@ -74,7 +75,7 @@ INSTALLED_APPS = ( TINYMCE_JS_URL = '/static/js/tiny_mce/tiny_mce.js' TINYMCE_DEFAULT_CONFIG = { - 'plugins' : 'contextmenu', + 'plugins': 'contextmenu', 'theme': 'advanced', 'theme_advanced_toolbar_location': 'top', } diff --git a/pv/urls.py b/pv/urls.py index e55dddc..792e9e9 100644 --- a/pv/urls.py +++ b/pv/urls.py @@ -5,15 +5,18 @@ from django.contrib import admin admin.autodiscover() from program.views import json_day_schedule -urlpatterns = patterns('', + +urlpatterns = patterns( + '', (r'^admin/', include(admin.site.urls)), (r'^program/', include('program.urls')), (r'^nop', include('nop.urls')), (r'^tinymce/', include('tinymce.urls')), - url(r'^export/day_schedule/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/$', json_day_schedule), -) + url(r'^export/day_schedule/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/$', + json_day_schedule)) if settings.DEBUG: - urlpatterns += patterns('', - (r'^site_media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}) - ) + urlpatterns += patterns( + '', + (r'^site_media/(?P.*)$', 'django.views.static.serve', + {'document_root': settings.MEDIA_ROOT})) diff --git a/pv/wsgi.py b/pv/wsgi.py index 2ba7fe3..0708263 100644 --- a/pv/wsgi.py +++ b/pv/wsgi.py @@ -13,7 +13,8 @@ middleware here, or combine a Django application with an application of another framework. """ -import os, sys +import os +import sys sys.path.append('/var/www/pv') -- cgit v0.10.2 From 329cd60b7f7dcf826e9cc4962453d2d90c27bd26 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Thu, 1 May 2014 20:40:10 +0200 Subject: updated german translation. diff --git a/locale/DE/LC_MESSAGES/django.mo b/locale/DE/LC_MESSAGES/django.mo index 6f1e394..9adeb17 100644 Binary files a/locale/DE/LC_MESSAGES/django.mo and b/locale/DE/LC_MESSAGES/django.mo differ diff --git a/locale/DE/LC_MESSAGES/django.po b/locale/DE/LC_MESSAGES/django.po index 063babb..509f0c1 100644 --- a/locale/DE/LC_MESSAGES/django.po +++ b/locale/DE/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: helsinki-program\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-12-28 16:28+0100\n" +"POT-Creation-Date: 2014-05-01 20:24+0200\n" "PO-Revision-Date: 2011-06-02 22:25+0200\n" "Last-Translator: Ernesto Rico-Schmidt \n" "Language-Team: LANGUAGE \n" @@ -18,279 +18,312 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -#: program/admin.py:55 +#: program/admin.py:64 msgid "Renew selected time slots" msgstr "Ausgewählte Sendezeiten verlängern" -#: program/models.py:13 +#: program/models.py:17 msgid "Format" msgstr "Format" -#: program/models.py:14 program/models.py:27 program/models.py:40 -#: program/models.py:53 program/models.py:89 +#: program/models.py:18 program/models.py:43 program/models.py:103 +#: program/models.py:163 program/models.py:260 msgid "Slug" msgstr "Slug" -#: program/models.py:18 program/models.py:84 +#: program/models.py:19 program/models.py:33 +msgid "Color" +msgstr "Farbe" + +#: program/models.py:20 +msgid "Text color" +msgstr "Textfarbe" + +#: program/models.py:22 +msgid "Enabled" +msgstr "Aktiviert" + +#: program/models.py:26 program/models.py:249 msgid "Broadcast format" msgstr "Sendungsformat" -#: program/models.py:19 +#: program/models.py:27 msgid "Broadcast formats" msgstr "Sendungsformate" -#: program/models.py:25 +#: program/models.py:41 msgid "Information" msgstr "Zusatzinformation" -#: program/models.py:26 program/models.py:39 program/models.py:52 +#: program/models.py:42 program/models.py:102 program/models.py:162 msgid "Abbreviation" msgstr "Abkürzung" -#: program/models.py:31 program/models.py:32 program/models.py:85 +#: program/models.py:44 program/models.py:104 program/models.py:164 +msgid "Button image" +msgstr "Bild-Button" + +#: program/models.py:46 program/models.py:106 program/models.py:166 +msgid "Button image (hover)" +msgstr "Bild-Button (hover)" + +#: program/models.py:48 program/models.py:108 program/models.py:168 +msgid "Big button image" +msgstr "Bild-Button groß" + +#: program/models.py:53 program/models.py:54 program/models.py:252 msgid "Show information" msgstr "Zusatzinformation" -#: program/models.py:38 program/models.py:44 program/models.py:86 +#: program/models.py:75 program/models.py:135 program/models.py:195 +msgid "Buttons" +msgstr "Buttonts" + +#: program/models.py:101 program/models.py:113 program/models.py:255 msgid "Show topic" msgstr "Thema/Schwerpunkt" -#: program/models.py:45 +#: program/models.py:114 msgid "Show topics" msgstr "Themen/Schwerpunkte" -#: program/models.py:51 +#: program/models.py:161 msgid "Focus" msgstr "Tendenz" -#: program/models.py:57 program/models.py:58 program/models.py:87 +#: program/models.py:173 program/models.py:174 program/models.py:258 msgid "Music focus" msgstr "Musiktendenz" -#: program/models.py:64 program/models.py:88 program/models.py:130 +#: program/models.py:221 program/models.py:259 program/models.py:310 msgid "Name" msgstr "Name" -#: program/models.py:65 program/models.py:93 +#: program/models.py:222 program/models.py:267 msgid "E-Mail" msgstr "E-Mail" -#: program/models.py:66 program/models.py:94 +#: program/models.py:223 program/models.py:268 msgid "Website" msgstr "Website" -#: program/models.py:70 +#: program/models.py:227 msgid "Host" msgstr "Sendungsmacher" -#: program/models.py:71 program/models.py:82 +#: program/models.py:228 program/models.py:244 msgid "Hosts" msgstr "Sendungsmacher" -#: program/models.py:81 +#: program/models.py:241 msgid "Predecessor" msgstr "Vorgänger" -#: program/models.py:83 +#: program/models.py:247 msgid "Owners" msgstr "Eingentümer" -#: program/models.py:90 +#: program/models.py:261 msgid "Image" msgstr "Bild" -#: program/models.py:91 +#: program/models.py:263 +#, fuzzy +msgid "show Image" +msgstr "Zeige Bild" + +#: program/models.py:264 msgid "Short description" msgstr "Kurzbeschreibung" -#: program/models.py:92 +#: program/models.py:265 msgid "Description" msgstr "Beschreibung" -#: program/models.py:95 +#: program/models.py:269 msgid "CBA series ID" msgstr "ID der Sendereihe auf CBA" -#: program/models.py:101 program/models.py:156 +#: program/models.py:271 program/models.py:346 +msgid "Automation ID" +msgstr "ID in der Automatiserung" + +#: program/models.py:279 program/models.py:340 msgid "Show" msgstr "Sendung" -#: program/models.py:102 +#: program/models.py:280 msgid "Shows" msgstr "Sendungen" -#: program/models.py:114 +#: program/models.py:293 msgid "Has active program slots" msgstr "Hat aktive Sendezeiten" -#: program/models.py:118 +#: program/models.py:298 msgid "Monthly" msgstr "monatlich" -#: program/models.py:119 +#: program/models.py:299 msgid "Weekly" msgstr "wöchentlich" -#: program/models.py:120 +#: program/models.py:300 msgid "Daily" msgstr "täglich" -#: program/models.py:123 +#: program/models.py:303 msgid "First" msgstr "Erster" -#: program/models.py:124 +#: program/models.py:304 msgid "Second" msgstr "Zweiter" -#: program/models.py:125 +#: program/models.py:305 msgid "Third" msgstr "Dritter" -#: program/models.py:126 +#: program/models.py:306 msgid "Fourth" msgstr "Vierter" -#: program/models.py:127 +#: program/models.py:307 msgid "Fifth" msgstr "Fünfter" -#: program/models.py:128 +#: program/models.py:308 msgid "Last" msgstr "Letzter" -#: program/models.py:131 +#: program/models.py:311 msgid "Frequency" msgstr "Häufigkeit" -#: program/models.py:132 +#: program/models.py:312 msgid "Interval" msgstr "Intervall" -#: program/models.py:133 +#: program/models.py:313 msgid "Set position" msgstr "Position" -#: program/models.py:134 +#: program/models.py:315 msgid "Count" msgstr "Zähler" -#: program/models.py:138 program/models.py:154 +#: program/models.py:319 program/models.py:337 msgid "Recurrence rule" msgstr "Wiederholungsregel" -#: program/models.py:139 +#: program/models.py:320 msgid "Recurrence rules" msgstr "Wiederholungsregel" -#: program/models.py:146 +#: program/models.py:328 msgid "Monday" msgstr "Montag" -#: program/models.py:147 +#: program/models.py:329 msgid "Tuesday" msgstr "Dienstag" -#: program/models.py:148 +#: program/models.py:330 msgid "Wednesday" msgstr "Mittwoch" -#: program/models.py:149 +#: program/models.py:331 msgid "Thursday" msgstr "Donnerstag" -#: program/models.py:150 +#: program/models.py:332 msgid "Friday" msgstr "Freitag" -#: program/models.py:151 +#: program/models.py:333 msgid "Saturday" msgstr "Samstag" -#: program/models.py:152 +#: program/models.py:334 msgid "Sunday" msgstr "Sonntag" -#: program/models.py:155 +#: program/models.py:338 msgid "Weekday" msgstr "Wochentag" -#: program/models.py:157 +#: program/models.py:341 msgid "First date" msgstr "Erstes Datum" -#: program/models.py:158 program/models.py:277 +#: program/models.py:342 program/models.py:501 msgid "Start time" msgstr "Beginnzeit" -#: program/models.py:159 program/models.py:278 +#: program/models.py:343 program/models.py:502 msgid "End time" msgstr "Endzeit" -#: program/models.py:160 +#: program/models.py:344 msgid "Last date" msgstr "Letztes Datum" -#: program/models.py:161 +#: program/models.py:345 msgid "Is repetition" msgstr "Is Wiederholung" -#: program/models.py:168 program/models.py:276 +#: program/models.py:355 program/models.py:500 msgid "Program slot" msgstr "Sendezeit" -#: program/models.py:169 +#: program/models.py:356 msgid "Program slots" msgstr "Sendezeiten" -#: program/models.py:241 +#: program/models.py:437 msgid "Time slot count" msgstr "Zeitschlitze" -#: program/models.py:285 program/models.py:308 +#: program/models.py:509 program/models.py:533 msgid "Time slot" msgstr "Zeitschlitz" -#: program/models.py:286 +#: program/models.py:510 msgid "Time slots" msgstr "Zeitschlitze" -#: program/models.py:304 +#: program/models.py:529 msgid "Cancellation" msgstr "Ausfall" -#: program/models.py:305 +#: program/models.py:530 msgid "Recommendation" msgstr "Empfehlung" -#: program/models.py:306 +#: program/models.py:531 msgid "Repetition" msgstr "Wiederholung" -#: program/models.py:309 -msgid "Owner" -msgstr "Eigentümer" - -#: program/models.py:310 +#: program/models.py:534 msgid "Title" msgstr "Titel" -#: program/models.py:311 +#: program/models.py:535 msgid "Content" msgstr "Inhalt" -#: program/models.py:312 +#: program/models.py:536 msgid "Status" msgstr "Status" -#: program/models.py:313 +#: program/models.py:538 msgid "CBA entry ID" msgstr "ID des Beitrags auf der CBA" -#: program/models.py:321 +#: program/models.py:547 msgid "Note" msgstr "Notiz" -#: program/models.py:322 +#: program/models.py:548 msgid "Notes" msgstr "Notizen" -- cgit v0.10.2 From f2c4d866489a4aef845d7c422b98febf402472dc Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Thu, 1 May 2014 23:42:21 +0200 Subject: added save_as to NoteAdmin and limited time slot to the last four weeks. made renew action inside a method diff --git a/program/admin.py b/program/admin.py index 7b52fa4..0fa7461 100644 --- a/program/admin.py +++ b/program/admin.py @@ -5,7 +5,7 @@ from models import (BroadcastFormat, MusicFocus, ShowInformation, ShowTopic, Host, Note, ProgramSlot, Show, TimeSlot) from forms import MusicFocusForm -from datetime import date +from datetime import date, datetime, timedelta class BroadcastFormatAdmin(admin.ModelAdmin): @@ -34,15 +34,18 @@ class NoteAdmin(admin.ModelAdmin): list_display = ('title', 'show', 'start', 'status') list_filter = ('status',) ordering = ('timeslot',) + save_as = True def queryset(self, request): shows = request.user.shows.all() return super(NoteAdmin, self).queryset(request).filter(show__in=shows) def formfield_for_foreignkey(self, db_field, request=None, **kwargs): + four_weeks = datetime.now() - timedelta(weeks=4) if db_field.name == 'timeslot': shows = request.user.shows.all() - kwargs['queryset'] = TimeSlot.objects.filter(show__in=shows) + kwargs['queryset'] = TimeSlot.objects.filter(show__in=shows, + start__gt=four_weeks) return super(NoteAdmin, self).formfield_for_foreignkey(db_field, request, @@ -56,16 +59,8 @@ class TimeSlotInline(admin.TabularInline): model = TimeSlot -def renew(modeladmin, request, queryset): - 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,) + actions = ('renew',) inlines = (TimeSlotInline,) list_display = ('show', 'byweekday', 'rrule', 'tstart', 'tend', 'until', 'timeslot_count') @@ -74,6 +69,17 @@ class ProgramSlotAdmin(admin.ModelAdmin): save_on_top = True search_fields = ('show__name',) + def renew(self, request, queryset): + next_year = date.today().year + 1 + until = date(next_year, 12, 31) + renewed = queryset.update(until=until) + if renewed == 1: + message = _("1 program slot was renewed until %s") % until + else: + message = _("%s program slots were renewed until %s") % until + self.message_user(request, message) + renew.short_description = _("Renew selected program slots") + class ProgramSlotInline(admin.TabularInline): model = ProgramSlot -- cgit v0.10.2 From bfcdf06fc0321f230fde9c542f793bd35dc6139b Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Thu, 1 May 2014 23:43:18 +0200 Subject: added always_visible to the Hosts and updated template and URLs diff --git a/program/models.py b/program/models.py index 50b5889..1541754 100644 --- a/program/models.py +++ b/program/models.py @@ -219,6 +219,7 @@ class MusicFocus(models.Model): class Host(models.Model): name = models.CharField(_("Name"), max_length=128) + always_visible = models.BooleanField(_("Always visible"), default=False) email = models.EmailField(_("E-Mail"), blank=True) website = models.URLField(_("Website"), blank=True) diff --git a/program/templates/host_detail.html b/program/templates/host_detail.html index bbe801e..3d8e862 100644 --- a/program/templates/host_detail.html +++ b/program/templates/host_detail.html @@ -11,7 +11,11 @@
Sendungen
{% for show in host.shows.all %} + {% if show.has_active_programslots %} + {% else %} +
{{ show }}
+ {% endif %} {% endfor %} diff --git a/program/urls.py b/program/urls.py index fbdc037..d5af119 100644 --- a/program/urls.py +++ b/program/urls.py @@ -1,5 +1,6 @@ from django.conf import settings from django.conf.urls.defaults import * +from django.db.models import Q from django.views.decorators.cache import cache_page from django.views.generic.list_detail import object_detail, object_list @@ -11,7 +12,8 @@ from datetime import date hosts_dict = { 'queryset': Host.objects.filter( - shows__programslots__until__gte=date.today()).distinct(), + Q(shows__programslots__until__gte=date.today()) | + Q(always_visible=True)).distinct(), 'template_object_name': 'host' } shows_dict = { -- cgit v0.10.2 From 47e373cb1502b8211773becfa88e1943d6abffc7 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Mon, 26 May 2014 22:13:22 +0200 Subject: updated Django version diff --git a/requirements.txt b/requirements.txt index f089112..49cfe6e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Django==1.4.12 +Django==1.4.13 MySQL-python==1.2.5 Pillow==2.4.0 PyYAML==3.11 -- cgit v0.10.2 From e0e8c8569a9355ea49b7c346605e450d6d474655 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 16 Jul 2014 11:31:56 +0200 Subject: updated Pillow version diff --git a/requirements.txt b/requirements.txt index 49cfe6e..dd63b40 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ Django==1.4.13 MySQL-python==1.2.5 -Pillow==2.4.0 +Pillow==2.5.1 PyYAML==3.11 django-tinymce==1.5.2 python-dateutil==1.5 -- cgit v0.10.2 From 821a356f1a8a36560f6731a716c65b5c80553379 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Mon, 21 Jul 2014 21:13:18 +0200 Subject: handle errors better diff --git a/program/utils.py b/program/utils.py index cdc6a09..9a086da 100644 --- a/program/utils.py +++ b/program/utils.py @@ -2,12 +2,27 @@ from django.conf import settings import json import urllib +from os.path import join def get_automation_id_choices(): base_url = getattr(settings, 'AUTOMATION_BASE_URL', None) + cache_dir = getattr(settings, 'AUTOMATION_CACHE_DIR', 'cache') + cached_shows = join(cache_dir, 'shows.json') shows = [] if base_url: - shows_list = json.load(urllib.urlopen(base_url))['shows'] + try: + shows_json = urllib.urlopen(base_url).read() + shows_list = json.loads(shows_json)['shows'] + except IOError: + try: + with open(cached_shows) as cache: + shows_list = json.loads(cache.read())['shows'] + except IOError: + shows_list = [] + else: + with open(cached_shows, 'w') as cache: + cache.write(shows_json) + shows = [(s['id'], s['title']) for s in shows_list] return shows -- cgit v0.10.2 From 2a40af2011cca2defd64254806970cf376a760a7 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 25 Sep 2015 20:52:36 +0200 Subject: fixed imports for django 1.7 diff --git a/nop/urls.py b/nop/urls.py index 0d7f279..85857ce 100644 --- a/nop/urls.py +++ b/nop/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url, include from views import get, get_current, nop_form import os diff --git a/program/urls.py b/program/urls.py index d5af119..94096ff 100644 --- a/program/urls.py +++ b/program/urls.py @@ -1,8 +1,8 @@ from django.conf import settings -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url, include from django.db.models import Q from django.views.decorators.cache import cache_page -from django.views.generic.list_detail import object_detail, object_list +from django.views.generic.detail import DetailView from models import Host, Show, TimeSlot from views import current_show, day_schedule, recommendations, show_list, \ @@ -33,21 +33,21 @@ urlpatterns = patterns('', day_schedule), url(r'^(?P\d{4})/(?P\d{1,2})/?$', week_schedule), - url(r'^current_box/?$', cache_page(current_show, 60)), + url(r'^current_box/?$', cache_page(60)(current_show)), url(r'^hosts/?$', - object_list, + DetailView, dict(hosts_dict, template_name='host_list.html')), - url(r'^hosts/(?P\d+)/?$', object_detail, + url(r'^hosts/(?P\d+)/?$', DetailView, dict(hosts_dict, template_name='host_detail.html'), name='host-detail'), url(r'^tips/?$', recommendations), url(r'^tips_box/?$', recommendations, recommendations_dict), url(r'^shows/?$', show_list), - url(r'^shows/(?P[\w-]+)/?$', object_detail, + url(r'^shows/(?P[\w-]+)/?$', DetailView, dict(shows_dict, template_name='show_detail.html'), name='show-detail'), - url(r'^(?P\d+)/?$', object_detail, + url(r'^(?P\d+)/?$', DetailView, dict(timeslots_dict, template_name='timeslot_detail.html'), name='timeslot-detail'), diff --git a/program/views.py b/program/views.py index e01868a..2305fdd 100644 --- a/program/views.py +++ b/program/views.py @@ -1,7 +1,8 @@ from datetime import date, datetime, time, timedelta import json -from django.views.generic import list_detail, simple +from django.views.generic.base import TemplateView +from django.views.generic.detail import DetailView from django.shortcuts import get_object_or_404 from django.db.models import Q from django.http import HttpResponse @@ -33,7 +34,7 @@ def show_list(request): queryset = queryset.filter(showtopic=showtopic) - return list_detail.object_list(request, queryset=queryset, + return DetailView(request, queryset=queryset, template_object_name='show', template_name='show_list.html') @@ -46,7 +47,7 @@ def recommendations(request, template_name='recommendations.html'): start__range=(now, end)) | Q(show__broadcastformat__slug='sondersendung', start__range=(now, end))).order_by('start')[:20] - return list_detail.object_list(request, queryset=queryset, + return DetailView(request, queryset=queryset, template_name=template_name, template_object_name='recommendation') @@ -93,7 +94,7 @@ def day_schedule(request, year=None, month=None, day=None): else: extra_context['timeslots'] = timeslots - return simple.direct_to_template(request, extra_context=extra_context, + return TemplateView(request, extra_context=extra_context, template='day_schedule.html') @@ -108,7 +109,7 @@ def current_show(request): next=next, after_next=after_next) - return simple.direct_to_template(request, template='boxes/current.html', + return TemplateView(request, template='boxes/current.html', extra_context=extra_context) @@ -151,7 +152,7 @@ def week_schedule(request, year=None, week=None): extra_context['next_w4'] = datetime.strftime(monday + timedelta(days=28), '%G/%V') - return simple.direct_to_template(request, template='week_schedule.html', + return TemplateView(request, template='week_schedule.html', extra_context=extra_context) @@ -161,7 +162,7 @@ def styles(request): 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='styles.css', + return TemplateView(request, template='styles.css', mimetype='text/css', extra_context=extra_context) diff --git a/pv/settings.py b/pv/settings.py index 7ef0067..de116c2 100644 --- a/pv/settings.py +++ b/pv/settings.py @@ -36,6 +36,7 @@ LOCALE_PATHS = os.path.join(PROJECT_DIR, 'locale') MEDIA_ROOT = os.path.join(PROJECT_DIR, 'site_media') MEDIA_URL = '/site_media/' +STATIC_ROOT = os.path.join(PROJECT_DIR, 'static') STATIC_URL = '/static/' SECRET_KEY = '' diff --git a/pv/urls.py b/pv/urls.py index 792e9e9..8d97fb3 100644 --- a/pv/urls.py +++ b/pv/urls.py @@ -1,5 +1,5 @@ from django.conf import settings -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url, include from django.contrib import admin admin.autodiscover() diff --git a/pv/wsgi.py b/pv/wsgi.py index 0708263..f704d30 100644 --- a/pv/wsgi.py +++ b/pv/wsgi.py @@ -16,7 +16,7 @@ framework. import os import sys -sys.path.append('/var/www/pv') +sys.path.append('/srv/pv/pv') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pv.settings") -- cgit v0.10.2 From 331aaeecc6627e5b9c58145ec34365152dbf6622 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 25 Sep 2015 21:14:59 +0200 Subject: fixed gitignore to include show_images and cache dir diff --git a/.gitignore b/.gitignore index 0d113a0..3cd3c48 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ pv/local_settings.py pv/site_media/buttons/b-*.png pv/site_media/buttons/s-*.png pv/site_media/buttons/r-*.png +pv/site_media/show_images/* +pv/cache/* -- cgit v0.10.2 From 885ad6327c53826c108d30ce74b47223b9e0afff Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 7 Oct 2015 13:07:23 +0200 Subject: enable song listing for Songbirds diff --git a/nop/views.py b/nop/views.py index 967a81c..a2bf224 100644 --- a/nop/views.py +++ b/nop/views.py @@ -19,7 +19,8 @@ MUSIKPROG_IDS = ( 203, # Hotel Passage 204, # Radyo Mezopotamya 206, # Abunda Lingva - 290 # styrian underground + 290, # styrian underground + 523 # Songbirds ) SPECIAL_PROGRAM_IDS = ( -- cgit v0.10.2 From d1310b341b0a187f957563da4de1fcb18c248f84 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Mon, 26 Oct 2015 10:33:40 +0100 Subject: updated requirements diff --git a/requirements.txt b/requirements.txt index dd63b40..f18b8dc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -Django==1.4.13 +Django==1.7.10 MySQL-python==1.2.5 -Pillow==2.5.1 +Pillow==3.0.0 PyYAML==3.11 -django-tinymce==1.5.2 -python-dateutil==1.5 +django-tinymce==2.0.5 +python-dateutil==2.4.2 -- cgit v0.10.2 From f9db1f1be7fdb42fc842d3cdba6fdac92fd5b896 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Mon, 28 Dec 2015 17:28:56 +0100 Subject: removed unused import diff --git a/nop/views.py b/nop/views.py index a2bf224..a8d7084 100644 --- a/nop/views.py +++ b/nop/views.py @@ -5,7 +5,7 @@ from django.shortcuts import render_to_response from django.http import HttpResponse from django import forms from models import Master, Standby, State -from program.models import TimeSlot, Note +from program.models import TimeSlot import json import time -- cgit v0.10.2 From 1ca6b2fc829b1605da634d74fd8c2a322ecc747f Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Mon, 28 Dec 2015 17:29:56 +0100 Subject: removed unused import, reformated code. diff --git a/nop/urls.py b/nop/urls.py index 85857ce..3cc97a4 100644 --- a/nop/urls.py +++ b/nop/urls.py @@ -1,16 +1,13 @@ -from django.conf.urls import patterns, url, include +from django.conf.urls import patterns, url from views import get, get_current, nop_form import os -NOP_STATIC_DIR = os.path.join(os.path.dirname(__file__), 'site_media') +NOP_SITE_MEDIA = os.path.join(os.path.dirname(__file__), 'site_media') -urlpatterns = patterns( - '', - url(r'^/get_current/?$', get_current), - url(r'^/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P\d{1,2})/(?P\d{1,2})/?$', - get), - url(r'^/?$', nop_form), - url(r'^/static/(?P.*)$', 'django.views.static.serve', - {'document_root': NOP_STATIC_DIR}), +urlpatterns = patterns('', + url(r'^/get_current/?$', get_current), + url(r'^/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P\d{1,2})/(?P\d{1,2})/?$', get), + url(r'^/?$', nop_form), + url(r'^/static/(?P.*)$', 'django.views.static.serve', {'document_root': NOP_SITE_MEDIA}), ) -- cgit v0.10.2 From cdbbdd0234f2548dd8cfe9de40ac94fd2f0594d9 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Mon, 28 Dec 2015 17:33:15 +0100 Subject: fixed LOCALE_PATHS setting diff --git a/pv/settings.py b/pv/settings.py index de116c2..ead2704 100644 --- a/pv/settings.py +++ b/pv/settings.py @@ -31,7 +31,9 @@ SITE_ID = 1 USE_I18N = True USE_L10N = True -LOCALE_PATHS = os.path.join(PROJECT_DIR, 'locale') +LOCALE_PATHS = ( + os.path.join(PROJECT_DIR, 'locale'), +) MEDIA_ROOT = os.path.join(PROJECT_DIR, 'site_media') MEDIA_URL = '/site_media/' -- cgit v0.10.2 From 97f0d0bcd2ad70630d5eae09ff63e8850538d39e Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Mon, 28 Dec 2015 17:33:52 +0100 Subject: reformated code. diff --git a/pv/urls.py b/pv/urls.py index 8d97fb3..b4f72ce 100644 --- a/pv/urls.py +++ b/pv/urls.py @@ -6,17 +6,15 @@ admin.autodiscover() from program.views import json_day_schedule -urlpatterns = patterns( - '', - (r'^admin/', include(admin.site.urls)), - (r'^program/', include('program.urls')), - (r'^nop', include('nop.urls')), - (r'^tinymce/', include('tinymce.urls')), - url(r'^export/day_schedule/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/$', - json_day_schedule)) +urlpatterns = patterns('', + (r'^admin/', include(admin.site.urls)), + (r'^program/', include('program.urls')), + (r'^nop', include('nop.urls')), + (r'^tinymce/', include('tinymce.urls')), + url(r'^export/day_schedule/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/$', json_day_schedule) +) if settings.DEBUG: - urlpatterns += patterns( - '', - (r'^site_media/(?P.*)$', 'django.views.static.serve', - {'document_root': settings.MEDIA_ROOT})) + urlpatterns += patterns('', + (r'^site_media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}) +) -- cgit v0.10.2 From 5b4e0ed7db7e3845cef065d74ad2b2dc3d36e102 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Mon, 28 Dec 2015 17:44:34 +0100 Subject: reformated code. diff --git a/program/admin.py b/program/admin.py index 0fa7461..3086dd5 100644 --- a/program/admin.py +++ b/program/admin.py @@ -1,8 +1,7 @@ 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, datetime, timedelta @@ -44,12 +43,9 @@ class NoteAdmin(admin.ModelAdmin): four_weeks = datetime.now() - timedelta(weeks=4) if db_field.name == 'timeslot': shows = request.user.shows.all() - kwargs['queryset'] = TimeSlot.objects.filter(show__in=shows, - start__gt=four_weeks) + kwargs['queryset'] = TimeSlot.objects.filter(show__in=shows, start__gt=four_weeks) - 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() @@ -62,8 +58,7 @@ class TimeSlotInline(admin.TabularInline): 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 @@ -86,22 +81,17 @@ class ProgramSlotInline(admin.TabularInline): 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', ) diff --git a/program/models.py b/program/models.py index 1541754..8bc0d6b 100644 --- a/program/models.py +++ b/program/models.py @@ -1,7 +1,7 @@ from django.contrib.auth.models import User -from django.core.exceptions import (ObjectDoesNotExist, ValidationError, - MultipleObjectsReturned) +from django.core.exceptions import ObjectDoesNotExist, ValidationError, MultipleObjectsReturned from django.db import models +from django.db.models import Q from django.utils.translation import ugettext_lazy as _ from tinymce import models as tinymce_models @@ -17,8 +17,7 @@ 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') - text_color = models.CharField(_("Text color"), max_length=7, - default='#000000') + text_color = models.CharField(_("Text color"), max_length=7, default='#000000') enabled = models.BooleanField(_("Enabled"), default=True) class Meta: @@ -41,12 +40,9 @@ 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') + 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',) @@ -101,12 +97,9 @@ 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') + 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',) @@ -161,12 +154,9 @@ 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') + 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',) @@ -237,41 +227,23 @@ class Host(models.Model): class Show(models.Model): - predecessor = models.ForeignKey('self', blank=True, null=True, - related_name='successors', - verbose_name=_("Predecessor")) - hosts = models.ManyToManyField(Host, blank=True, null=True, - related_name='shows', - verbose_name=_("Hosts")) - owners = models.ManyToManyField(User, blank=True, null=True, - related_name='shows', - verbose_name=_("Owners")) - broadcastformat = models.ForeignKey(BroadcastFormat, related_name='shows', - verbose_name=_("Broadcast format")) - showinformation = models.ManyToManyField(ShowInformation, blank=True, - null=True, related_name='shows', - verbose_name=_("Show information")) - showtopic = models.ManyToManyField(ShowTopic, blank=True, null=True, - related_name='shows', - verbose_name=_("Show topic")) - musicfocus = models.ManyToManyField(MusicFocus, blank=True, null=True, - related_name='shows', - verbose_name=_("Music focus")) + predecessor = models.ForeignKey('self', blank=True, null=True, related_name='successors', verbose_name=_("Predecessor")) + hosts = models.ManyToManyField(Host, blank=True, null=True, related_name='shows', verbose_name=_("Hosts")) + owners = models.ManyToManyField(User, blank=True, null=True, related_name='shows', verbose_name=_("Owners")) + broadcastformat = models.ForeignKey(BroadcastFormat, related_name='shows', verbose_name=_("Broadcast format")) + showinformation = models.ManyToManyField(ShowInformation, blank=True, null=True, related_name='shows', verbose_name=_("Show information")) + showtopic = models.ManyToManyField(ShowTopic, blank=True, null=True, related_name='shows', verbose_name=_("Show topic")) + musicfocus = models.ManyToManyField(MusicFocus, blank=True, null=True, related_name='shows', verbose_name=_("Music focus")) name = models.CharField(_("Name"), max_length=255) slug = models.CharField(_("Slug"), max_length=255, unique=True) - image = models.ImageField(_("Image"), blank=True, null=True, - upload_to='show_images') + image = models.ImageField(_("Image"), blank=True, null=True, upload_to='show_images') image_enabled = models.BooleanField(_("show Image"), default=True) short_description = models.CharField(_("Short description"), max_length=64) - description = tinymce_models.HTMLField(_("Description"), blank=True, - null=True) + description = tinymce_models.HTMLField(_("Description"), blank=True, null=True) email = models.EmailField(_("E-Mail"), blank=True, null=True) website = models.URLField(_("Website"), blank=True, null=True) - cba_series_id = models.IntegerField(_("CBA series ID"), blank=True, - null=True) - automation_id = models.IntegerField(_("Automation ID"), blank=True, - null=True, - choices=get_automation_id_choices()) + cba_series_id = models.IntegerField(_("CBA series ID"), blank=True, null=True) + automation_id = models.IntegerField(_("Automation ID"), blank=True, null=True, choices=get_automation_id_choices()) created = models.DateTimeField(auto_now_add=True, editable=False) last_updated = models.DateTimeField(auto_now=True, editable=False) @@ -334,19 +306,15 @@ class ProgramSlot(models.Model): (5, _("Saturday")), (6, _("Sunday")), ) - rrule = models.ForeignKey(RRule, related_name='programslots', - verbose_name=_("Recurrence rule")) + rrule = models.ForeignKey(RRule, related_name='programslots', verbose_name=_("Recurrence rule")) byweekday = models.IntegerField(_("Weekday"), choices=BYWEEKDAY_CHOICES) - show = models.ForeignKey(Show, related_name='programslots', - verbose_name=_("Show")) + show = models.ForeignKey(Show, related_name='programslots', verbose_name=_("Show")) dstart = models.DateField(_("First date")) tstart = models.TimeField(_("Start time")) tend = models.TimeField(_("End time")) until = models.DateField(_("Last date")) is_repetition = models.BooleanField(_("Is repetition"), default=False) - automation_id = models.IntegerField(_("Automation ID"), blank=True, - null=True, - choices=get_automation_id_choices()) + automation_id = models.IntegerField(_("Automation ID"), blank=True, null=True, choices=get_automation_id_choices()) created = models.DateTimeField(auto_now_add=True, editable=False) last_updated = models.DateTimeField(auto_now=True, editable=False) @@ -422,15 +390,11 @@ class ProgramSlot(models.Model): if not old: for k in range(min(len(starts), len(ends))): - timeslot = TimeSlot.objects.create(programslot=self, - start=starts[k], - end=ends[k]) + timeslot = TimeSlot.objects.create(programslot=self, start=starts[k], end=ends[k]) elif self.until > old.until: for k in range(min(len(starts), len(ends))): if starts[k].date() > old.until: - timeslot = TimeSlot.objects.create(programslot=self, - start=starts[k], - end=ends[k]) + timeslot = TimeSlot.objects.create(programslot=self, start=starts[k], end=ends[k]) def timeslot_count(self): return self.timeslots.count() @@ -450,11 +414,9 @@ class ProgramSlot(models.Model): class TimeSlotManager(models.Manager): def get_or_create_current(self): try: - return TimeSlot.objects.get(start__lte=datetime.now(), - end__gt=datetime.now()) + return TimeSlot.objects.get(start__lte=datetime.now(), end__gt=datetime.now()) except MultipleObjectsReturned: - return TimeSlot.objects.filter(start__lte=datetime.now(), - end__gt=datetime.now())[0] + return TimeSlot.objects.filter(start__lte=datetime.now(), end__gt=datetime.now())[0] except ObjectDoesNotExist: once = RRule.objects.get(pk=1) today = date.today().weekday() @@ -466,10 +428,8 @@ class TimeSlotManager(models.Manager): dstart, tstart = previous.end.date(), previous.end.time() until, tend = next.start.date(), next.start.time() - new_programslot = ProgramSlot(rrule=once, byweekday=today, - show=default, dstart=dstart, - tstart=tstart, tend=tend, - until=until) + new_programslot = ProgramSlot(rrule=once, byweekday=today, show=default, dstart=dstart, tstart=tstart, tend=tend, until=until) + try: new_programslot.validate_unique() new_programslot.save() @@ -482,23 +442,18 @@ class TimeSlotManager(models.Manager): today = datetime.combine(day, time(6, 0)) tomorrow = today + timedelta(days=1) - return TimeSlot.objects.filter(models.Q(start__lte=today, - end__gte=today) | - models.Q(start__gt=today, - start__lt=tomorrow)).exclude(end=today) + return TimeSlot.objects.filter(Q(start__lte=today, end__gte=today) | + Q(start__gt=today, start__lt=tomorrow)).exclude(end=today) def get_24h_timeslots(self, start): end = start + timedelta(hours=24) - return TimeSlot.objects.filter(models.Q(start__lte=start, - end__gte=start) | - models.Q(start__gt=start, - start__lt=end)).exclude(end=start) + return TimeSlot.objects.filter(Q(start__lte=start, end__gte=start) | + Q(start__gt=start, start__lt=end)).exclude(end=start) class TimeSlot(models.Model): - programslot = models.ForeignKey(ProgramSlot, related_name='timeslots', - verbose_name=_("Program slot")) + programslot = models.ForeignKey(ProgramSlot, related_name='timeslots', verbose_name=_("Program slot")) start = models.DateTimeField(_("Start time"), unique=True) end = models.DateTimeField(_("End time")) show = models.ForeignKey(Show, editable=False, related_name='timeslots') @@ -534,10 +489,8 @@ class Note(models.Model): timeslot = models.OneToOneField(TimeSlot, verbose_name=_("Time slot")) title = models.CharField(_("Title"), max_length=128) content = tinymce_models.HTMLField(_("Content")) - status = models.IntegerField(_("Status"), choices=STATUS_CHOICES, - default=1) - cba_entry_id = models.IntegerField(_("CBA entry ID"), blank=True, - null=True) + status = models.IntegerField(_("Status"), choices=STATUS_CHOICES, default=1) + cba_entry_id = models.IntegerField(_("CBA entry ID"), blank=True, null=True) start = models.DateTimeField(editable=False) show = models.ForeignKey(Show, editable=False, related_name='notes') created = models.DateTimeField(auto_now_add=True, editable=False) diff --git a/program/urls.py b/program/urls.py index 94096ff..e7217b8 100644 --- a/program/urls.py +++ b/program/urls.py @@ -1,65 +1,30 @@ from django.conf import settings -from django.conf.urls import patterns, url, include -from django.db.models import Q +from django.conf.urls import patterns, url from django.views.decorators.cache import cache_page -from django.views.generic.detail import DetailView -from models import Host, Show, TimeSlot -from views import current_show, day_schedule, recommendations, show_list, \ - week_schedule, styles +from views import current_show, day_schedule, recommendations, show_list, show_detail, timeslot_detail, week_schedule, styles, host_list, host_detail -from datetime import date +import os + +PROGRAM_SITE_MEDIA = os.path.join(os.path.dirname(__file__), '../site_media') -hosts_dict = { - 'queryset': Host.objects.filter( - Q(shows__programslots__until__gte=date.today()) | - Q(always_visible=True)).distinct(), - 'template_object_name': 'host' -} -shows_dict = { - 'queryset': Show.objects.filter( - programslots__until__gt=date.today()).exclude(id=1).distinct(), - 'template_object_name': 'show' -} -timeslots_dict = { - 'queryset': TimeSlot.objects.all(), - 'template_object_name': 'timeslot' -} recommendations_dict = {'template_name': 'boxes/recommendations.html'} urlpatterns = patterns('', url(r'^today/?$', day_schedule), - url(r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/?$', - day_schedule), - url(r'^(?P\d{4})/(?P\d{1,2})/?$', - week_schedule), - url(r'^current_box/?$', cache_page(60)(current_show)), - url(r'^hosts/?$', - DetailView, - dict(hosts_dict, template_name='host_list.html')), - url(r'^hosts/(?P\d+)/?$', DetailView, - dict(hosts_dict, template_name='host_detail.html'), - name='host-detail'), + url(r'^week/?$', week_schedule), + url(r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/?$', day_schedule), + url(r'^(?P\d{4})/(?P\d{1,2})/?$', week_schedule), + url(r'^current_box/?$', cache_page(current_show, 60)), + url(r'^hosts/?$', host_list), + url(r'^hosts/(?P\d+)/?$', host_detail, name='host-detail'), url(r'^tips/?$', recommendations), - url(r'^tips_box/?$', recommendations, - recommendations_dict), + url(r'^tips_box/?$', recommendations, recommendations_dict), url(r'^shows/?$', show_list), - url(r'^shows/(?P[\w-]+)/?$', DetailView, - dict(shows_dict, template_name='show_detail.html'), - name='show-detail'), - url(r'^(?P\d+)/?$', DetailView, - dict(timeslots_dict, - template_name='timeslot_detail.html'), - name='timeslot-detail'), - url(r'^week/?$', week_schedule), + url(r'^shows/(?P[\w-]+)/?$', show_detail, name='show-detail'), + url(r'^(?P\d+)/?$', timeslot_detail, name='timeslot-detail'), url(r'^styles.css$', styles)) if settings.DEBUG: - import os - - PROGRAM_STATIC_DIR = os.path.join(os.path.dirname(__file__), - '../site_media') urlpatterns += patterns('', - url(r'^static/(?P.*)$', - 'django.views.static.serve', - {'document_root': PROGRAM_STATIC_DIR})) + url(r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': PROGRAM_SITE_MEDIA})) diff --git a/program/views.py b/program/views.py index 2305fdd..cba3a25 100644 --- a/program/views.py +++ b/program/views.py @@ -3,99 +3,101 @@ import json from django.views.generic.base import TemplateView from django.views.generic.detail import DetailView +from django.views.generic.list import ListView from django.shortcuts import get_object_or_404 from django.db.models import Q from django.http import HttpResponse -from models import (BroadcastFormat, MusicFocus, Note, Show, ShowInformation, - ShowTopic, TimeSlot) +from models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, ShowTopic, TimeSlot, Host + + +def host_list(request): + queryset = Host.objects.filter(Q(shows__programslots__until__gte=date.today()) | + Q(always_visible=True)).distinct() + + return ListView.as_view(request, queryset=queryset, template_name='host_list.html') + + +def host_detail(request): + queryset = Host.objects.filter(Q(shows__programslots__until__gte=date.today()) | + Q(always_visible=True)).distinct() + + return DetailView.as_view(request, queryset=queryset, template_name='host_detail.html') def show_list(request): queryset = Show.objects.filter(programslots__until__gt=date.today()).exclude(id=1).distinct() if 'broadcastformat' in request.GET: - broadcastformat = get_object_or_404(BroadcastFormat, - slug=request.GET['broadcastformat']) - + broadcastformat = get_object_or_404(BroadcastFormat, slug=request.GET['broadcastformat']) queryset = queryset.filter(broadcastformat=broadcastformat) elif 'musicfocus' in request.GET: - musicfocus = get_object_or_404(MusicFocus, - slug=request.GET['musicfocus']) - + musicfocus = get_object_or_404(MusicFocus, slug=request.GET['musicfocus']) queryset = queryset.filter(musicfocus=musicfocus) elif 'showinformation' in request.GET: - showinformation = get_object_or_404(ShowInformation, - slug=request.GET['showinformation']) - + showinformation = get_object_or_404(ShowInformation, slug=request.GET['showinformation']) queryset = queryset.filter(showinformation=showinformation) elif 'showtopic' in request.GET: showtopic = get_object_or_404(ShowTopic, slug=request.GET['showtopic']) - queryset = queryset.filter(showtopic=showtopic) - return DetailView(request, queryset=queryset, - template_object_name='show', - template_name='show_list.html') + return ListView.as_view(request, queryset=queryset, template_object_name='show', template_name='show_list.html') + + +def show_detail(request): + queryset = Show.objects.filter(programslots__until__gt=date.today()).exclude(id=1).distinct() + + return DetailView.as_view(request, queryset=queryset, template_name='show_detail.html',) + + +def timeslot_detail(request): + queryset = TimeSlot.objects.all() + + return DetailView.as_view(request, queryset=queryset, template_name='timeslot_detail.html') def recommendations(request, template_name='recommendations.html'): now = datetime.now() end = now + timedelta(weeks=1) - queryset = TimeSlot.objects.filter(Q(note__isnull=False, note__status=1, - start__range=(now, end)) | - Q(show__broadcastformat__slug='sondersendung', - start__range=(now, end))).order_by('start')[:20] - return DetailView(request, queryset=queryset, - template_name=template_name, - template_object_name='recommendation') + queryset = TimeSlot.objects.filter(Q(note__isnull=False, note__status=1, start__range=(now, end)) | + Q(show__broadcastformat__slug='sondersendung', start__range=(now, end))).order_by('start')[:20] + + return DetailView.as_view(request, queryset=queryset, template_name=template_name, template_object_name='recommendation') def day_schedule(request, year=None, month=None, day=None): if year is None and month is None and day is None: today = datetime.combine(date.today(), time(6, 0)) else: - today = datetime.strptime('%s__%s__%s__06__00' % (year, month, day), - '%Y__%m__%d__%H__%M') + today = datetime.strptime('%s__%s__%s__06__00' % (year, month, day), '%Y__%m__%d__%H__%M') tomorrow = today + timedelta(days=1) - recommendations = Note.objects.filter(status=1, - timeslot__start__range=(today, - tomorrow)) + recommendations = Note.objects.filter(status=1, timeslot__start__range=(today, tomorrow)) default_show = Show.objects.get(pk=1) - extra_context = dict(day=today, recommendations=recommendations, - default_show=default_show) + extra_context = dict(day=today, recommendations=recommendations, default_show=default_show) timeslots = TimeSlot.objects.get_day_timeslots(today) if 'broadcastformat' in request.GET: - broadcastformat = get_object_or_404(BroadcastFormat, - slug=request.GET['broadcastformat']) - + broadcastformat = get_object_or_404(BroadcastFormat, slug=request.GET['broadcastformat']) extra_context['timeslots'] = timeslots.filter(show__broadcastformat=broadcastformat) elif 'musicfocus' in request.GET: - musicfocus = get_object_or_404(MusicFocus, - slug=request.GET['musicfocus']) - + musicfocus = get_object_or_404(MusicFocus, slug=request.GET['musicfocus']) extra_context['timeslots'] = timeslots.filter(show__musicfocus=musicfocus) elif 'showinformation' in request.GET: - showinformation = get_object_or_404(ShowInformation, - slug=request.GET['showinformation']) - + showinformation = get_object_or_404(ShowInformation, slug=request.GET['showinformation']) extra_context['timeslots'] = timeslots.filter(show__showinformation=showinformation) elif 'showtopic' in request.GET: showtopic = get_object_or_404(ShowTopic, slug=request.GET['showtopic']) - extra_context['showtopic'] = timeslots.filter(show__showtopic=showtopic) else: extra_context['timeslots'] = timeslots - return TemplateView(request, extra_context=extra_context, - template='day_schedule.html') + return TemplateView.as_view(request, extra_context=extra_context, template='day_schedule.html') def current_show(request): @@ -104,18 +106,14 @@ def current_show(request): next = current.get_next_by_start() after_next = next.get_next_by_start() - extra_context = dict(current=current, - previous=previous, - next=next, - after_next=after_next) + extra_context = dict(current=current, previous=previous, next=next, after_next=after_next) - return TemplateView(request, template='boxes/current.html', - extra_context=extra_context) + return TemplateView.as_view(request, template='boxes/current.html', extra_context=extra_context) def week_schedule(request, year=None, week=None): if year is None and week is None: - year, week = datetime.strftime(datetime.now(), '%G__%V').split('__') + year, week = datetime.now().strftime('%G__%V').split('__') monday = tofirstdayinisoweek(int(year), int(week)) tuesday = monday + timedelta(days=1) @@ -127,10 +125,8 @@ def week_schedule(request, year=None, week=None): default_show = Show.objects.get(pk=1) - extra_context = dict(monday=monday, tuesday=tuesday, wednesday=wednesday, - thursday=thursday, friday=friday, - saturday=saturday, sunday=sunday, - default_show=default_show) + extra_context = dict(monday=monday, tuesday=tuesday, wednesday=wednesday, thursday=thursday, friday=friday, + saturday=saturday, sunday=sunday, default_show=default_show) extra_context['monday_timeslots'] = TimeSlot.objects.get_day_timeslots(monday) extra_context['tuesday_timeslots'] = TimeSlot.objects.get_day_timeslots(tuesday) @@ -140,20 +136,14 @@ def week_schedule(request, year=None, week=None): extra_context['saturday_timeslots'] = TimeSlot.objects.get_day_timeslots(saturday) extra_context['sunday_timeslots'] = TimeSlot.objects.get_day_timeslots(sunday) - extra_context['last_w'] = datetime.strftime(monday - timedelta(days=7), - '%G/%V') + extra_context['last_w'] = datetime.strftime(monday - timedelta(days=7), '%G/%V') extra_context['cur_w'] = datetime.strftime(monday, '%G/%V') - extra_context['next_w1'] = datetime.strftime(monday + timedelta(days=7), - '%G/%V') - extra_context['next_w2'] = datetime.strftime(monday + timedelta(days=14), - '%G/%V') - extra_context['next_w3'] = datetime.strftime(monday + timedelta(days=21), - '%G/%V') - extra_context['next_w4'] = datetime.strftime(monday + timedelta(days=28), - '%G/%V') + extra_context['next_w1'] = datetime.strftime(monday + timedelta(days=7), '%G/%V') + extra_context['next_w2'] = datetime.strftime(monday + timedelta(days=14), '%G/%V') + extra_context['next_w3'] = datetime.strftime(monday + timedelta(days=21), '%G/%V') + extra_context['next_w4'] = datetime.strftime(monday + timedelta(days=28), '%G/%V') - return TemplateView(request, template='week_schedule.html', - extra_context=extra_context) + return TemplateView.as_view(request, template='week_schedule.html', extra_context=extra_context) def styles(request): @@ -162,36 +152,27 @@ def styles(request): extra_context['musicfocus'] = MusicFocus.objects.all() extra_context['showinformation'] = ShowInformation.objects.all() extra_context['showtopic'] = ShowTopic.objects.all() - return TemplateView(request, template='styles.css', - mimetype='text/css', - extra_context=extra_context) + + return TemplateView.as_view(request, template='styles.css', mimetype='text/css', extra_context=extra_context) def json_day_schedule(request, year=None, month=None, day=None): if year is None and month is None and day is None: today = datetime.combine(date.today(), time(0, 0)) else: - today = datetime.strptime('%s__%s__%s__00__00' % (year, month, day), - '%Y__%m__%d__%H__%M') + today = datetime.strptime('%s__%s__%s__00__00' % (year, month, day), '%Y__%m__%d__%H__%M') timeslots = TimeSlot.objects.get_24h_timeslots(today) schedule = [] for ts in timeslots: if ts.programslot.automation_id: - schedule.append((ts.start.strftime('%H:%M:%S'), - ts.programslot.show.name, - ts.programslot.automation_id)) + schedule.append((ts.start.strftime('%H:%M:%S'), ts.programslot.show.name, ts.programslot.automation_id)) elif ts.programslot.show.automation_id: - schedule.append( - (ts.start.strftime('%H:%M:%S'), ts.programslot.show.name, - ts.programslot.show.automation_id)) + schedule.append((ts.start.strftime('%H:%M:%S'), ts.programslot.show.name, ts.programslot.show.automation_id)) else: - schedule.append((ts.start.strftime('%H:%M:%S'), - ts.programslot.show.name, -1)) + schedule.append((ts.start.strftime('%H:%M:%S'), ts.programslot.show.name, -1)) - return HttpResponse(json.dumps(schedule, ensure_ascii=False, - encoding='utf8').encode('utf8'), - content_type="application/json; charset=utf-8") + return HttpResponse(json.dumps(schedule, ensure_ascii=False, encoding='utf8').encode('utf8'), content_type="application/json; charset=utf-8") def tofirstdayinisoweek(year, week): -- cgit v0.10.2 From 318e0003da75f9854d4149509194c8f344874800 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Mon, 28 Dec 2015 17:45:29 +0100 Subject: updated requirements diff --git a/requirements.txt b/requirements.txt index f18b8dc..3d00d3a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -Django==1.7.10 +Django==1.8.7 MySQL-python==1.2.5 Pillow==3.0.0 PyYAML==3.11 -django-tinymce==2.0.5 +django-tinymce==2.0.6 python-dateutil==2.4.2 -- cgit v0.10.2 From 87c905dbcec3d8c8587c832ed11abe1dc9fb8848 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 30 Dec 2015 09:42:12 +0100 Subject: added migrations for nop & program diff --git a/nop/migrations/0001_initial.py b/nop/migrations/0001_initial.py new file mode 100644 index 0000000..200241b --- /dev/null +++ b/nop/migrations/0001_initial.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Master', + fields=[ + ('timestamp', models.BigIntegerField(serialize=False, primary_key=True)), + ('cart', models.IntegerField()), + ('len', models.IntegerField(null=True, blank=True)), + ('showtitle', models.CharField(max_length=765, blank=True)), + ('title', models.CharField(max_length=765, blank=True)), + ('artist', models.CharField(max_length=765, blank=True)), + ('album', models.CharField(max_length=765, blank=True)), + ('ismusic', models.IntegerField(null=True, blank=True)), + ], + options={ + 'ordering': ['-timestamp'], + 'db_table': 'master', + }, + ), + migrations.CreateModel( + name='Standby', + fields=[ + ('timestamp', models.BigIntegerField(serialize=False, primary_key=True)), + ('cart', models.IntegerField()), + ('len', models.IntegerField(null=True, blank=True)), + ('showtitle', models.CharField(max_length=765, blank=True)), + ('title', models.CharField(max_length=765, blank=True)), + ('artist', models.CharField(max_length=765, blank=True)), + ('album', models.CharField(max_length=765, blank=True)), + ('ismusic', models.IntegerField(null=True, blank=True)), + ], + options={ + 'ordering': ['-timestamp'], + 'db_table': 'standby', + }, + ), + migrations.CreateModel( + name='State', + fields=[ + ('timestamp', models.BigIntegerField(serialize=False, primary_key=True)), + ('state', models.CharField(max_length=96, blank=True)), + ], + options={ + 'ordering': ['-timestamp'], + 'db_table': 'state', + }, + ), + ] diff --git a/nop/migrations/__init__.py b/nop/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/program/migrations/0001_initial.py b/program/migrations/0001_initial.py new file mode 100644 index 0000000..c99ca82 --- /dev/null +++ b/program/migrations/0001_initial.py @@ -0,0 +1,228 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import tinymce.models +from django.conf import settings + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='BroadcastFormat', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('format', models.CharField(max_length=32, verbose_name='Format')), + ('slug', models.SlugField(unique=True, max_length=32, verbose_name='Slug')), + ('color', models.CharField(default=b'#ffffff', max_length=7, verbose_name='Color')), + ('text_color', models.CharField(default=b'#000000', max_length=7, verbose_name='Text color')), + ('enabled', models.BooleanField(default=True, verbose_name='Enabled')), + ], + options={ + 'ordering': ('format',), + 'verbose_name': 'Broadcast format', + 'verbose_name_plural': 'Broadcast formats', + }, + ), + migrations.CreateModel( + name='Host', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('name', models.CharField(max_length=128, verbose_name='Name')), + ('email', models.EmailField(max_length=254, verbose_name='E-Mail', blank=True)), + ('website', models.URLField(verbose_name='Website', blank=True)), + ], + options={ + 'ordering': ('name',), + 'verbose_name': 'Host', + 'verbose_name_plural': 'Hosts', + }, + ), + migrations.CreateModel( + name='MusicFocus', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('focus', models.CharField(max_length=32, verbose_name='Focus')), + ('abbrev', models.CharField(unique=True, max_length=4, verbose_name='Abbreviation')), + ('slug', models.SlugField(unique=True, max_length=32, verbose_name='Slug')), + ('button', models.ImageField(upload_to=b'buttons', null=True, verbose_name='Button image', blank=True)), + ('button_hover', models.ImageField(upload_to=b'buttons', null=True, verbose_name='Button image (hover)', blank=True)), + ('big_button', models.ImageField(upload_to=b'buttons', null=True, verbose_name='Big button image', blank=True)), + ], + options={ + 'ordering': ('focus',), + 'verbose_name': 'Music focus', + 'verbose_name_plural': 'Music focus', + }, + ), + migrations.CreateModel( + name='Note', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('title', models.CharField(max_length=128, verbose_name='Title')), + ('content', tinymce.models.HTMLField(verbose_name='Content')), + ('status', models.IntegerField(default=1, verbose_name='Status', choices=[(0, 'Cancellation'), (1, 'Recommendation'), (2, 'Repetition')])), + ('cba_entry_id', models.IntegerField(null=True, verbose_name='CBA entry ID', blank=True)), + ('start', models.DateTimeField(editable=False)), + ('created', models.DateTimeField(auto_now_add=True)), + ('last_updated', models.DateTimeField(auto_now=True)), + ], + options={ + 'ordering': ('timeslot',), + 'verbose_name': 'Note', + 'verbose_name_plural': 'Notes', + }, + ), + migrations.CreateModel( + name='ProgramSlot', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('byweekday', models.IntegerField(verbose_name='Weekday', choices=[(0, 'Monday'), (1, 'Tuesday'), (2, 'Wednesday'), (3, 'Thursday'), (4, 'Friday'), (5, 'Saturday'), (6, 'Sunday')])), + ('dstart', models.DateField(verbose_name='First date')), + ('tstart', models.TimeField(verbose_name='Start time')), + ('tend', models.TimeField(verbose_name='End time')), + ('until', models.DateField(verbose_name='Last date')), + ('is_repetition', models.BooleanField(default=False, verbose_name='Is repetition')), + ('automation_id', models.IntegerField(blank=True, null=True, verbose_name='Automation ID', choices=[(52018, '926Hertz'), (52069, 'Abunda Lingva'), (52145, 'Aficionados on Air'), (52140, 'AFRICAN TIME'), (52015, 'Alo Cristina!'), (52193, 'Anarchistisches Radio'), (52097, 'Arbeitslosenstammtisch'), (52178, 'Arbeitslosenstammtisch (Wiederholung)'), (52124, 'artcore'), (52142, 'Audiotop'), (52019, 'AUS CHANGE'), (52000, 'Aus den freien Radios'), (52143, 'avant_jazz'), (52022, 'A_partment politi_X'), (52053, 'A_partment politi_X (Wiederholung)'), (52079, 'Barrikaden und Pfeffer'), (52162, 'Between the Jigs and the Reels'), (52211, 'Between the Jigs and the Reels'), (52154, 'Between The Lines'), (52131, 'bumbumtschak'), (52221, 'c/o'), (52222, 'c/o'), (52220, 'c/o'), (52020, 'c/o'), (52224, 'c/o (Wiederholung)'), (52225, 'c/o (Wiederholung)'), (52223, 'c/o (Wiederholung)'), (52059, 'c/o (Wiederholung)'), (52014, 'Cafe Manchester'), (52065, 'Champion Sound'), (52017, 'clash connect'), (52139, 'Club Station'), (52207, 'Das offene Wort'), (52226, 'Das rote Mikro'), (52122, 'Das rote Mikro'), (52218, 'Das rote Mikro'), (52219, 'Das rote Mikro'), (52233, 'Das rote Mikro (Wiederholung)'), (52229, 'Das rote Mikro (Wiederholung)'), (52227, 'Das rote Mikro (Wiederholung)'), (52232, 'Das rote Mikro (Wiederholung)'), (52165, 'Das wilde Denken'), (52234, 'Das wilde Denken (Wiederholung)'), (52007, 'Democracy Now!'), (52192, 'derive'), (52093, 'derive (Wiederholung)'), (52235, 'Deutsche Demokratische Populaermusik'), (52096, 'Die Neue Stadt'), (52125, 'Die Radiokometen - Wir sind Radio!'), (52182, 'Die Radiokometen - Wir sind Radio! (Wiederholung)'), (52208, 'Die Sendung mit der Katz'), (52239, 'Die Stadt der Zukunft - die Zukunft der Stadt'), (52177, 'disko404 radioshow'), (52185, 'disko404 radioshow (Wiederholung)'), (52166, 'Dream-Spotting'), (52054, 'Eigenklang'), (52200, 'Emigranti'), (52176, 'Emigranti (Wiederholung)'), (52141, 'Exquisite Corps'), (52203, 'Final Transmission'), (52195, 'fixe'), (52091, 'Fluxkompensator'), (52209, 'Fokus Bildung'), (52068, 'Fratls Forum'), (52086, 'freigangproduktionen'), (52046, 'freigangproduktionen (Wiederholung)'), (52197, 'fridayshow'), (52158, 'FROzine'), (52050, 'FROzine (Wiederholung 1)'), (52052, 'FROzine (Wiederholung 2)'), (52136, 'Fr\xfchst\xfcck ohne Illusionen'), (52231, 'Ganz bei Trost'), (52099, 'gender frequenz - sozialpolitisch, feministisch, unbeugsam!'), (52013, 'gender frequenz - sozialpolitisch, feministisch, unbeugsam! (Wiederholung)'), (52189, 'Graz Sozial'), (52048, 'Hannas bunte Kommode'), (52089, 'headroom'), (52070, 'Helga Maria - live line'), (52202, 'HelsinKIDS'), (52058, 'Hotel Passage'), (52119, 'In Graz Verstrickt'), (52181, 'In Graz Verstrickt (Wiederholung)'), (52100, 'Jackolope - Bearfish and Country-Music'), (52149, 'Jazz-News'), (52044, 'Jazzkartell'), (52160, 'Jazzkartell (Wiederholung)'), (52051, "Jester's Soundtracks"), (52201, 'Jeux On Air'), (52009, 'Just to get a Rap'), (52173, 'Klassik am Sonntag'), (52004, 'Klimanews'), (52212, 'Kultlabor'), (52137, 'KunstR\xe4ume'), (52049, "L'heure bleue"), (52072, 'lady music'), (52214, 'Lange Lieder'), (52010, 'literadio on air'), (52213, 'Literatursprechstunde'), (52066, 'M Punkt Klengele (oder) ekw14,90'), (52057, 'Martinland'), (52184, 'Martinland (Wiederholung)'), (52157, 'Megaphonuni'), (52183, 'Megaphonuni (Wiederholung)'), (52071, 'Mit den Ohren lesen und schreiben'), (52237, 'Mit den Ohren lesen und schreiben (Wiederholen)'), (52196, 'morgen'), (52094, 'Morgenrunde'), (52001, 'Musica Latinoamericana!'), (52132, 'Musica Latinoamericana! (Wiederholung)'), (52061, 'Natur im Aether'), (52153, 'Neue Literatur am Donnerstag'), (52187, 'Not only Latin'), (52188, 'Not only Latin (Wiederholung)'), (52191, 'NUOVA MUSICA INTERNZIONALE'), (52228, 'O94 Nachrichten'), (52204, 'Ohrenw\xe4rmer'), (52008, 'onda-info'), (52216, 'Oozing Music Show'), (52081, 'Probeb\xfchne'), (52028, 'Programmvorschau Dienstag Abend'), (52026, 'Programmvorschau Dienstag Fr\xfch'), (52027, 'Programmvorschau Dienstag Mittag'), (52034, 'Programmvorschau Donnerstag Abend'), (52032, 'Programmvorschau Donnerstag Fr\xfch'), (52033, 'Programmvorschau Donnerstag Mittag'), (52037, 'Programmvorschau Freitag Abend'), (52035, 'Programmvorschau Freitag Fr\xfch'), (52036, 'Programmvorschau Freitag Mittag'), (52031, 'Programmvorschau Mittwoch Abend'), (52029, 'Programmvorschau Mittwoch Fr\xfch'), (52030, 'Programmvorschau Mittwoch Mittag'), (52025, 'Programmvorschau Montag Abend'), (52023, 'Programmvorschau Montag Fr\xfch'), (52024, 'Programmvorschau Montag Mittag'), (52040, 'Programmvorschau Samstag Abend'), (52038, 'Programmvorschau Samstag Fr\xfch'), (52039, 'Programmvorschau Samstag Mittag'), (52043, 'Programmvorschau Sonntag Abend'), (52041, 'Programmvorschau Sonntag Fr\xfch'), (52042, 'Programmvorschau Sonntag Mittag'), (52021, 'Pura Vida Sounds'), (52064, 'Pythagoras oder die feste Winkelsumme des Lebens'), (52194, 'Pythagoras oder die feste Winkelsumme des Lebens (Wiederholung)'), (52016, 'Querbeet'), (52230, 'Radio Auslandsdienst'), (52127, 'Radio Lax'), (52199, 'Radio LoPas'), (52151, 'Radio Marmelade'), (52003, 'Radio Netwatcher'), (52063, 'radio radia - radiokunst zum selbsthineinh\xf6ren'), (52002, 'Radio Rinia'), (52047, 'Radio Stimme'), (52045, 'radio%attac'), (52174, 'radio%attac (Wiederholung)'), (52133, 'Radyo Mezopotamya'), (52130, 'raumfest'), (52175, 'raumfest (Wiederholung)'), (52215, 'Resonate Project'), (52150, 'Rivendell Test (\xd63 Simulator)'), (52210, 'Rocktime'), (52006, 'Romania astazi - Rum\xe4nien heute'), (52161, 'Saunafm'), (52164, "Scenesters' Special"), (52103, 'Sendeschiene1-01'), (52104, 'Sendeschiene1-02'), (52105, 'Sendeschiene1-03'), (52106, 'Sendeschiene1-04'), (52107, 'Sendeschiene1-05'), (52108, 'Sendeschiene1-06'), (52109, 'Sendeschiene1-07'), (52110, 'Sendeschiene1-08'), (52111, 'Sendeschiene1-09'), (52112, 'Sendeschiene1-10'), (52113, 'Sendeschiene2-01'), (52114, 'Sendeschiene2-02'), (52115, 'Sendeschiene2-03'), (52116, 'Sendeschiene2-04'), (52117, 'Sendeschiene2-05'), (52120, 'Sendeschiene2-06'), (52236, 'Sendung mit Akzent'), (52198, 'Sigs Seelenkiste'), (52073, 'Sondersendung 1'), (52074, 'Sondersendung 2'), (52075, 'Sondersendung 3'), (52076, 'Sondersendung 4'), (52077, 'Sondersendung 5'), (52163, 'songbirds'), (52055, 'SPACEfemFM'), (52092, 'SportLeit'), (52088, 'SportLeit (Wiederholung)'), (52123, 'Steinzeit'), (52238, 'Steinzeit (Wiederholung)'), (52067, 'Styrian Underground'), (52152, 'substral'), (52146, 'Substral (Wiederholung)'), (52085, 'Szenenwechsel'), (52148, 'Szenenwechsel (Wiederholung)'), (52169, 'Tagtraum/Nachtwache'), (52011, 'testsendung1'), (52012, 'testsendung2'), (52156, 'Theo Cola'), (52168, 'Theo Cola (Wiederholung)'), (52171, 'Tierrechtsradio'), (52056, 'Toningenieursforum'), (52005, 'Tonspur'), (52083, 'Tramina FM'), (52101, 'Transgenderradio'), (52159, 'Transgenderradio (Wiederholung)'), (52090, 'Unerh\xf6rt - Radio ohne Barrieren'), (52180, 'Unerh\xf6rt - Radio ohne Barrieren (Wiederholung)'), (52098, 'Ungarische Mosaiken'), (52147, 'Von Unten (Donnerstag)'), (52129, 'Von Unten (Donnerstag, Wiederholung 1)'), (52170, 'Von Unten (Donnerstag, Wiederholung 2)'), (52134, 'Von Unten (Mittwoch)'), (52082, 'Von Unten (Mittwoch, Wiederholung 1)'), (52128, 'Von Unten (Mittwoch, Wiederholung 2)'), (52060, 'Von Unten im Gespraech WH'), (52080, 'Von Unten im Gespr\xe4ch'), (52126, 'Von Unten im Gespr\xe4ch (Wiederholung)'), (52155, 'Werkskantine'), (52095, 'WERKSTATT KULTUR'), (52078, 'Women on Air presents: Globale Dialoge'), (52172, 'Women on Air presents: Globale Dialoge (Wiederholung)'), (52121, 'Zapatistas: Caminando preguntamos - Fragend schreiten wir voran'), (52206, 'Zapatistas: Caminando preguntamos - Fragend schreiten wir voran (Wiederholung)'), (52186, 'Zwischen Kl\xe4ngen')])), + ('created', models.DateTimeField(auto_now_add=True)), + ('last_updated', models.DateTimeField(auto_now=True)), + ], + options={ + 'ordering': ('dstart', 'tstart'), + 'verbose_name': 'Program slot', + 'verbose_name_plural': 'Program slots', + }, + ), + migrations.CreateModel( + name='RRule', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('name', models.CharField(unique=True, max_length=32, verbose_name='Name')), + ('freq', models.IntegerField(verbose_name='Frequency', choices=[(1, 'Monthly'), (2, 'Weekly'), (3, 'Daily')])), + ('interval', models.IntegerField(default=1, verbose_name='Interval')), + ('bysetpos', models.IntegerField(blank=True, null=True, verbose_name='Set position', choices=[(1, 'First'), (2, 'Second'), (3, 'Third'), (4, 'Fourth'), (5, 'Fifth'), (-1, 'Last')])), + ('count', models.IntegerField(null=True, verbose_name='Count', blank=True)), + ], + options={ + 'ordering': ('-freq', 'interval', 'bysetpos'), + 'verbose_name': 'Recurrence rule', + 'verbose_name_plural': 'Recurrence rules', + }, + ), + migrations.CreateModel( + name='Show', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('name', models.CharField(max_length=255, verbose_name='Name')), + ('slug', models.CharField(unique=True, max_length=255, verbose_name='Slug')), + ('image', models.ImageField(upload_to=b'show_images', null=True, verbose_name='Image', blank=True)), + ('image_enabled', models.BooleanField(default=True, verbose_name='show Image')), + ('short_description', models.CharField(max_length=64, verbose_name='Short description')), + ('description', tinymce.models.HTMLField(null=True, verbose_name='Description', blank=True)), + ('email', models.EmailField(max_length=254, null=True, verbose_name='E-Mail', blank=True)), + ('website', models.URLField(null=True, verbose_name='Website', blank=True)), + ('cba_series_id', models.IntegerField(null=True, verbose_name='CBA series ID', blank=True)), + ('automation_id', models.IntegerField(blank=True, null=True, verbose_name='Automation ID', choices=[(52018, '926Hertz'), (52069, 'Abunda Lingva'), (52145, 'Aficionados on Air'), (52140, 'AFRICAN TIME'), (52015, 'Alo Cristina!'), (52193, 'Anarchistisches Radio'), (52097, 'Arbeitslosenstammtisch'), (52178, 'Arbeitslosenstammtisch (Wiederholung)'), (52124, 'artcore'), (52142, 'Audiotop'), (52019, 'AUS CHANGE'), (52000, 'Aus den freien Radios'), (52143, 'avant_jazz'), (52022, 'A_partment politi_X'), (52053, 'A_partment politi_X (Wiederholung)'), (52079, 'Barrikaden und Pfeffer'), (52162, 'Between the Jigs and the Reels'), (52211, 'Between the Jigs and the Reels'), (52154, 'Between The Lines'), (52131, 'bumbumtschak'), (52221, 'c/o'), (52222, 'c/o'), (52220, 'c/o'), (52020, 'c/o'), (52224, 'c/o (Wiederholung)'), (52225, 'c/o (Wiederholung)'), (52223, 'c/o (Wiederholung)'), (52059, 'c/o (Wiederholung)'), (52014, 'Cafe Manchester'), (52065, 'Champion Sound'), (52017, 'clash connect'), (52139, 'Club Station'), (52207, 'Das offene Wort'), (52226, 'Das rote Mikro'), (52122, 'Das rote Mikro'), (52218, 'Das rote Mikro'), (52219, 'Das rote Mikro'), (52233, 'Das rote Mikro (Wiederholung)'), (52229, 'Das rote Mikro (Wiederholung)'), (52227, 'Das rote Mikro (Wiederholung)'), (52232, 'Das rote Mikro (Wiederholung)'), (52165, 'Das wilde Denken'), (52234, 'Das wilde Denken (Wiederholung)'), (52007, 'Democracy Now!'), (52192, 'derive'), (52093, 'derive (Wiederholung)'), (52235, 'Deutsche Demokratische Populaermusik'), (52096, 'Die Neue Stadt'), (52125, 'Die Radiokometen - Wir sind Radio!'), (52182, 'Die Radiokometen - Wir sind Radio! (Wiederholung)'), (52208, 'Die Sendung mit der Katz'), (52239, 'Die Stadt der Zukunft - die Zukunft der Stadt'), (52177, 'disko404 radioshow'), (52185, 'disko404 radioshow (Wiederholung)'), (52166, 'Dream-Spotting'), (52054, 'Eigenklang'), (52200, 'Emigranti'), (52176, 'Emigranti (Wiederholung)'), (52141, 'Exquisite Corps'), (52203, 'Final Transmission'), (52195, 'fixe'), (52091, 'Fluxkompensator'), (52209, 'Fokus Bildung'), (52068, 'Fratls Forum'), (52086, 'freigangproduktionen'), (52046, 'freigangproduktionen (Wiederholung)'), (52197, 'fridayshow'), (52158, 'FROzine'), (52050, 'FROzine (Wiederholung 1)'), (52052, 'FROzine (Wiederholung 2)'), (52136, 'Fr\xfchst\xfcck ohne Illusionen'), (52231, 'Ganz bei Trost'), (52099, 'gender frequenz - sozialpolitisch, feministisch, unbeugsam!'), (52013, 'gender frequenz - sozialpolitisch, feministisch, unbeugsam! (Wiederholung)'), (52189, 'Graz Sozial'), (52048, 'Hannas bunte Kommode'), (52089, 'headroom'), (52070, 'Helga Maria - live line'), (52202, 'HelsinKIDS'), (52058, 'Hotel Passage'), (52119, 'In Graz Verstrickt'), (52181, 'In Graz Verstrickt (Wiederholung)'), (52100, 'Jackolope - Bearfish and Country-Music'), (52149, 'Jazz-News'), (52044, 'Jazzkartell'), (52160, 'Jazzkartell (Wiederholung)'), (52051, "Jester's Soundtracks"), (52201, 'Jeux On Air'), (52009, 'Just to get a Rap'), (52173, 'Klassik am Sonntag'), (52004, 'Klimanews'), (52212, 'Kultlabor'), (52137, 'KunstR\xe4ume'), (52049, "L'heure bleue"), (52072, 'lady music'), (52214, 'Lange Lieder'), (52010, 'literadio on air'), (52213, 'Literatursprechstunde'), (52066, 'M Punkt Klengele (oder) ekw14,90'), (52057, 'Martinland'), (52184, 'Martinland (Wiederholung)'), (52157, 'Megaphonuni'), (52183, 'Megaphonuni (Wiederholung)'), (52071, 'Mit den Ohren lesen und schreiben'), (52237, 'Mit den Ohren lesen und schreiben (Wiederholen)'), (52196, 'morgen'), (52094, 'Morgenrunde'), (52001, 'Musica Latinoamericana!'), (52132, 'Musica Latinoamericana! (Wiederholung)'), (52061, 'Natur im Aether'), (52153, 'Neue Literatur am Donnerstag'), (52187, 'Not only Latin'), (52188, 'Not only Latin (Wiederholung)'), (52191, 'NUOVA MUSICA INTERNZIONALE'), (52228, 'O94 Nachrichten'), (52204, 'Ohrenw\xe4rmer'), (52008, 'onda-info'), (52216, 'Oozing Music Show'), (52081, 'Probeb\xfchne'), (52028, 'Programmvorschau Dienstag Abend'), (52026, 'Programmvorschau Dienstag Fr\xfch'), (52027, 'Programmvorschau Dienstag Mittag'), (52034, 'Programmvorschau Donnerstag Abend'), (52032, 'Programmvorschau Donnerstag Fr\xfch'), (52033, 'Programmvorschau Donnerstag Mittag'), (52037, 'Programmvorschau Freitag Abend'), (52035, 'Programmvorschau Freitag Fr\xfch'), (52036, 'Programmvorschau Freitag Mittag'), (52031, 'Programmvorschau Mittwoch Abend'), (52029, 'Programmvorschau Mittwoch Fr\xfch'), (52030, 'Programmvorschau Mittwoch Mittag'), (52025, 'Programmvorschau Montag Abend'), (52023, 'Programmvorschau Montag Fr\xfch'), (52024, 'Programmvorschau Montag Mittag'), (52040, 'Programmvorschau Samstag Abend'), (52038, 'Programmvorschau Samstag Fr\xfch'), (52039, 'Programmvorschau Samstag Mittag'), (52043, 'Programmvorschau Sonntag Abend'), (52041, 'Programmvorschau Sonntag Fr\xfch'), (52042, 'Programmvorschau Sonntag Mittag'), (52021, 'Pura Vida Sounds'), (52064, 'Pythagoras oder die feste Winkelsumme des Lebens'), (52194, 'Pythagoras oder die feste Winkelsumme des Lebens (Wiederholung)'), (52016, 'Querbeet'), (52230, 'Radio Auslandsdienst'), (52127, 'Radio Lax'), (52199, 'Radio LoPas'), (52151, 'Radio Marmelade'), (52003, 'Radio Netwatcher'), (52063, 'radio radia - radiokunst zum selbsthineinh\xf6ren'), (52002, 'Radio Rinia'), (52047, 'Radio Stimme'), (52045, 'radio%attac'), (52174, 'radio%attac (Wiederholung)'), (52133, 'Radyo Mezopotamya'), (52130, 'raumfest'), (52175, 'raumfest (Wiederholung)'), (52215, 'Resonate Project'), (52150, 'Rivendell Test (\xd63 Simulator)'), (52210, 'Rocktime'), (52006, 'Romania astazi - Rum\xe4nien heute'), (52161, 'Saunafm'), (52164, "Scenesters' Special"), (52103, 'Sendeschiene1-01'), (52104, 'Sendeschiene1-02'), (52105, 'Sendeschiene1-03'), (52106, 'Sendeschiene1-04'), (52107, 'Sendeschiene1-05'), (52108, 'Sendeschiene1-06'), (52109, 'Sendeschiene1-07'), (52110, 'Sendeschiene1-08'), (52111, 'Sendeschiene1-09'), (52112, 'Sendeschiene1-10'), (52113, 'Sendeschiene2-01'), (52114, 'Sendeschiene2-02'), (52115, 'Sendeschiene2-03'), (52116, 'Sendeschiene2-04'), (52117, 'Sendeschiene2-05'), (52120, 'Sendeschiene2-06'), (52236, 'Sendung mit Akzent'), (52198, 'Sigs Seelenkiste'), (52073, 'Sondersendung 1'), (52074, 'Sondersendung 2'), (52075, 'Sondersendung 3'), (52076, 'Sondersendung 4'), (52077, 'Sondersendung 5'), (52163, 'songbirds'), (52055, 'SPACEfemFM'), (52092, 'SportLeit'), (52088, 'SportLeit (Wiederholung)'), (52123, 'Steinzeit'), (52238, 'Steinzeit (Wiederholung)'), (52067, 'Styrian Underground'), (52152, 'substral'), (52146, 'Substral (Wiederholung)'), (52085, 'Szenenwechsel'), (52148, 'Szenenwechsel (Wiederholung)'), (52169, 'Tagtraum/Nachtwache'), (52011, 'testsendung1'), (52012, 'testsendung2'), (52156, 'Theo Cola'), (52168, 'Theo Cola (Wiederholung)'), (52171, 'Tierrechtsradio'), (52056, 'Toningenieursforum'), (52005, 'Tonspur'), (52083, 'Tramina FM'), (52101, 'Transgenderradio'), (52159, 'Transgenderradio (Wiederholung)'), (52090, 'Unerh\xf6rt - Radio ohne Barrieren'), (52180, 'Unerh\xf6rt - Radio ohne Barrieren (Wiederholung)'), (52098, 'Ungarische Mosaiken'), (52147, 'Von Unten (Donnerstag)'), (52129, 'Von Unten (Donnerstag, Wiederholung 1)'), (52170, 'Von Unten (Donnerstag, Wiederholung 2)'), (52134, 'Von Unten (Mittwoch)'), (52082, 'Von Unten (Mittwoch, Wiederholung 1)'), (52128, 'Von Unten (Mittwoch, Wiederholung 2)'), (52060, 'Von Unten im Gespraech WH'), (52080, 'Von Unten im Gespr\xe4ch'), (52126, 'Von Unten im Gespr\xe4ch (Wiederholung)'), (52155, 'Werkskantine'), (52095, 'WERKSTATT KULTUR'), (52078, 'Women on Air presents: Globale Dialoge'), (52172, 'Women on Air presents: Globale Dialoge (Wiederholung)'), (52121, 'Zapatistas: Caminando preguntamos - Fragend schreiten wir voran'), (52206, 'Zapatistas: Caminando preguntamos - Fragend schreiten wir voran (Wiederholung)'), (52186, 'Zwischen Kl\xe4ngen')])), + ('created', models.DateTimeField(auto_now_add=True)), + ('last_updated', models.DateTimeField(auto_now=True)), + ('broadcastformat', models.ForeignKey(related_name='shows', verbose_name='Broadcast format', to='program.BroadcastFormat')), + ('hosts', models.ManyToManyField(related_name='shows', verbose_name='Hosts', to='program.Host')), + ('musicfocus', models.ManyToManyField(related_name='shows', verbose_name='Music focus', to='program.MusicFocus')), + ('owners', models.ManyToManyField(related_name='shows', verbose_name='Owners', to=settings.AUTH_USER_MODEL)), + ('predecessor', models.ForeignKey(related_name='successors', verbose_name='Predecessor', blank=True, to='program.Show', null=True)), + ], + options={ + 'ordering': ('slug',), + 'verbose_name': 'Show', + 'verbose_name_plural': 'Shows', + }, + ), + migrations.CreateModel( + name='ShowInformation', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('information', models.CharField(max_length=32, verbose_name='Information')), + ('abbrev', models.CharField(unique=True, max_length=4, verbose_name='Abbreviation')), + ('slug', models.SlugField(unique=True, max_length=32, verbose_name='Slug')), + ('button', models.ImageField(upload_to=b'buttons', null=True, verbose_name='Button image', blank=True)), + ('button_hover', models.ImageField(upload_to=b'buttons', null=True, verbose_name='Button image (hover)', blank=True)), + ('big_button', models.ImageField(upload_to=b'buttons', null=True, verbose_name='Big button image', blank=True)), + ], + options={ + 'ordering': ('information',), + 'verbose_name': 'Show information', + 'verbose_name_plural': 'Show information', + }, + ), + migrations.CreateModel( + name='ShowTopic', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('topic', models.CharField(max_length=32, verbose_name='Show topic')), + ('abbrev', models.CharField(unique=True, max_length=4, verbose_name='Abbreviation')), + ('slug', models.SlugField(unique=True, max_length=32, verbose_name='Slug')), + ('button', models.ImageField(upload_to=b'buttons', null=True, verbose_name='Button image', blank=True)), + ('button_hover', models.ImageField(upload_to=b'buttons', null=True, verbose_name='Button image (hover)', blank=True)), + ('big_button', models.ImageField(upload_to=b'buttons', null=True, verbose_name='Big button image', blank=True)), + ], + options={ + 'ordering': ('topic',), + 'verbose_name': 'Show topic', + 'verbose_name_plural': 'Show topics', + }, + ), + migrations.CreateModel( + name='TimeSlot', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('start', models.DateTimeField(unique=True, verbose_name='Start time')), + ('end', models.DateTimeField(verbose_name='End time')), + ('programslot', models.ForeignKey(related_name='timeslots', verbose_name='Program slot', to='program.ProgramSlot')), + ('show', models.ForeignKey(related_name='timeslots', editable=False, to='program.Show')), + ], + options={ + 'ordering': ('start', 'end'), + 'verbose_name': 'Time slot', + 'verbose_name_plural': 'Time slots', + }, + ), + migrations.AddField( + model_name='show', + name='showinformation', + field=models.ManyToManyField(related_name='shows', verbose_name='Show information', to='program.ShowInformation'), + ), + migrations.AddField( + model_name='show', + name='showtopic', + field=models.ManyToManyField(related_name='shows', verbose_name='Show topic', to='program.ShowTopic'), + ), + migrations.AddField( + model_name='programslot', + name='rrule', + field=models.ForeignKey(related_name='programslots', verbose_name='Recurrence rule', to='program.RRule'), + ), + migrations.AddField( + model_name='programslot', + name='show', + field=models.ForeignKey(related_name='programslots', verbose_name='Show', to='program.Show'), + ), + migrations.AddField( + model_name='note', + name='show', + field=models.ForeignKey(related_name='notes', editable=False, to='program.Show'), + ), + migrations.AddField( + model_name='note', + name='timeslot', + field=models.OneToOneField(verbose_name='Time slot', to='program.TimeSlot'), + ), + migrations.AlterUniqueTogether( + name='programslot', + unique_together=set([('rrule', 'byweekday', 'dstart', 'tstart')]), + ), + ] diff --git a/program/migrations/0002_host_always_visible.py b/program/migrations/0002_host_always_visible.py new file mode 100644 index 0000000..a0f81ab --- /dev/null +++ b/program/migrations/0002_host_always_visible.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('program', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='host', + name='always_visible', + field=models.BooleanField(default=False, verbose_name='Always visible'), + ), + ] diff --git a/program/migrations/__init__.py b/program/migrations/__init__.py new file mode 100644 index 0000000..e69de29 -- cgit v0.10.2 From 27cc9438ae7d5ecaeef1599ad40cda39e8d56999 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 30 Dec 2015 09:43:52 +0100 Subject: fixed current_box URL diff --git a/program/urls.py b/program/urls.py index e7217b8..d02ee31 100644 --- a/program/urls.py +++ b/program/urls.py @@ -15,7 +15,7 @@ urlpatterns = patterns('', url(r'^week/?$', week_schedule), url(r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/?$', day_schedule), url(r'^(?P\d{4})/(?P\d{1,2})/?$', week_schedule), - url(r'^current_box/?$', cache_page(current_show, 60)), + url(r'^current_box/?$', cache_page(60)(current_show)), url(r'^hosts/?$', host_list), url(r'^hosts/(?P\d+)/?$', host_detail, name='host-detail'), url(r'^tips/?$', recommendations), -- cgit v0.10.2 From 6fb0d0a1b9be8ffb2ecce4ed87fd74ef684f2ef4 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 30 Dec 2015 09:44:53 +0100 Subject: added fields to forms diff --git a/program/forms.py b/program/forms.py index 0c33b20..9bfb7ad 100644 --- a/program/forms.py +++ b/program/forms.py @@ -33,13 +33,16 @@ class FormWithButton(ModelForm): class MusicFocusForm(FormWithButton): class Meta: model = MusicFocus + fields = '__all__' class ShowInformationForm(FormWithButton): class Meta: model = ShowInformation + fields = '__all__' class ShowTopicForm(FormWithButton): class Meta: model = ShowTopic + fields = '__all__' -- cgit v0.10.2 From 35bf6baf07aeca3b1ea085939b60497e10c9a71f Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 30 Dec 2015 09:46:55 +0100 Subject: replaced permalink calls, cleaned-up Show model diff --git a/program/models.py b/program/models.py index 8bc0d6b..8013b84 100644 --- a/program/models.py +++ b/program/models.py @@ -1,5 +1,6 @@ from django.contrib.auth.models import User from django.core.exceptions import ObjectDoesNotExist, ValidationError, MultipleObjectsReturned +from django.core.urlresolvers import reverse from django.db import models from django.db.models import Q from django.utils.translation import ugettext_lazy as _ @@ -221,19 +222,18 @@ class Host(models.Model): def __unicode__(self): return u'%s' % self.name - @models.permalink def get_absolute_url(self): - return ('host-detail', [str(self.id)]) + return reverse('host-detail', args=[self.id]) class Show(models.Model): predecessor = models.ForeignKey('self', blank=True, null=True, related_name='successors', verbose_name=_("Predecessor")) - hosts = models.ManyToManyField(Host, blank=True, null=True, related_name='shows', verbose_name=_("Hosts")) - owners = models.ManyToManyField(User, blank=True, null=True, related_name='shows', verbose_name=_("Owners")) + hosts = models.ManyToManyField(Host, related_name='shows', verbose_name=_("Hosts")) + owners = models.ManyToManyField(User, related_name='shows', verbose_name=_("Owners")) broadcastformat = models.ForeignKey(BroadcastFormat, related_name='shows', verbose_name=_("Broadcast format")) - showinformation = models.ManyToManyField(ShowInformation, blank=True, null=True, related_name='shows', verbose_name=_("Show information")) - showtopic = models.ManyToManyField(ShowTopic, blank=True, null=True, related_name='shows', verbose_name=_("Show topic")) - musicfocus = models.ManyToManyField(MusicFocus, blank=True, null=True, related_name='shows', verbose_name=_("Music focus")) + showinformation = models.ManyToManyField(ShowInformation, related_name='shows', verbose_name=_("Show information")) + showtopic = models.ManyToManyField(ShowTopic, related_name='shows', verbose_name=_("Show topic")) + musicfocus = models.ManyToManyField(MusicFocus, related_name='shows', verbose_name=_("Music focus")) name = models.CharField(_("Name"), max_length=255) slug = models.CharField(_("Slug"), max_length=255, unique=True) image = models.ImageField(_("Image"), blank=True, null=True, upload_to='show_images') @@ -255,9 +255,8 @@ class Show(models.Model): def __unicode__(self): return u'%s' % self.name - @models.permalink def get_absolute_url(self): - return ('show-detail', [self.slug]) + return reverse('show-detail', args=[self.slug]) def has_active_programslots(self): return self.programslots.filter(until__gt=date.today()).count() > 0 @@ -475,9 +474,8 @@ class TimeSlot(models.Model): self.show = self.programslot.show super(TimeSlot, self).save(*args, **kwargs) - @models.permalink def get_absolute_url(self): - return ('timeslot-detail', [self.id]) + return reverse('timeslot-detail', args=[self.id]) class Note(models.Model): -- cgit v0.10.2 From 54611a97d636238e9bba65e6d96690ac1446de09 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 19:59:46 +0100 Subject: renamed model field diff --git a/program/migrations/0002_host_always_visible.py b/program/migrations/0002_host_always_visible.py deleted file mode 100644 index a0f81ab..0000000 --- a/program/migrations/0002_host_always_visible.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('program', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='host', - name='always_visible', - field=models.BooleanField(default=False, verbose_name='Always visible'), - ), - ] diff --git a/program/migrations/0002_host_is_always_visible.py b/program/migrations/0002_host_is_always_visible.py new file mode 100644 index 0000000..9abf2bd --- /dev/null +++ b/program/migrations/0002_host_is_always_visible.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('program', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='host', + name='is_always_visible', + field=models.BooleanField(default=False, verbose_name='Is always visible'), + ), + ] diff --git a/program/templates/boxes/recommendation.html b/program/templates/boxes/recommendation.html new file mode 100644 index 0000000..d2bb7d2 --- /dev/null +++ b/program/templates/boxes/recommendation.html @@ -0,0 +1,40 @@ + + + + + Recomendations box + + + {% if recommendation_list %} +
+
Programmhinweise
+
+ + {% for item in recommendation_list %} + + + + + + {% endfor %} +
   + {{ item.start|date:"d.m. H:i" }} - + {{ item.end|date:"H:i" }}
+

+ {{ item.show.name }} +

+

+ {% if item.note %} + {{ item.note.title }}
+ {% else %} + {{ item.show.broadcastformat.format }}
+ {% endif %} + [weiter] +

+
+
+
+ {% endif %} + + diff --git a/program/templates/boxes/recommendations.html b/program/templates/boxes/recommendations.html deleted file mode 100644 index 2174654..0000000 --- a/program/templates/boxes/recommendations.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - Recomendations box - - - {% if recommendation_list %} -
-
Programmhinweise
-
- - {% for item in recommendation_list %} - - - - - - {% endfor %} -
   - {{ item.start|date:"d.m. H:i" }} - - {{ item.end|date:"H:i" }}
-

- {{ item.show.name }} -

-

- {% if item.note %} - {{ item.note.title }}
- {% else %} - {{ item.show.broadcastformat.format }}
- {% endif %} - [weiter] -

-
-
-
- {% endif %} - - diff --git a/program/templates/recommendation_list.html b/program/templates/recommendation_list.html new file mode 100644 index 0000000..3836a35 --- /dev/null +++ b/program/templates/recommendation_list.html @@ -0,0 +1,45 @@ + + + Tipps — Radio Helsinki - Freies Radio Graz + + + +
+

Programmhinweise

+
+{% for recommendation in recommendation_list %} +
+
+ {% for si in recommendation.show.showinformation.all %} + {{ si.abbrev }} + {% endfor %} + {% for st in recommendation.show.showtopic.all %} + {{ st.abbrev }} + {% endfor %} + {% for mf in recommendation.show.musicfocus.all %} + {{ mf.abbrev }} + {% endfor %} +
+
+

+ {{ recommendation.show.name }}
+ vom {{ recommendation.start|date:"d.m. H:i" }}-{{ recommendation.end|date:"H:i" }} +

+ {% if recommendation.note %} +

+ {{ recommendation.note.title }} +

+
{{ recommendation.note.content|safe}}
+ {% else %} +

+ {{ recommendation.show.broadcastformat.format }} +

+ {% endif %} +
+
+{% endfor %} +
+
+ + + diff --git a/program/templates/recommendations.html b/program/templates/recommendations.html deleted file mode 100644 index ba9a719..0000000 --- a/program/templates/recommendations.html +++ /dev/null @@ -1,45 +0,0 @@ - - - Tipps — Radio Helsinki - Freies Radio Graz - - - -
-

Programmhinweise

-
-{% for item in recommendation_list %} -
-
- {% for ab in item.show.showinformation.all %} - {{ ab.abbrev }} - {% endfor %} - {% for ab in item.show.showtopic.all %} - {{ ab.abbrev }} - {% endfor %} - {% for ab in item.show.musicfocus.all %} - {{ ab.abbrev }} - {% endfor %} -
-
-

- {{ item.show.name }}
- vom {{ item.start|date:"d.m. H:i" }}-{{ item.end|date:"H:i" }} -

- {% if item.note %} -

- {{ item.note.title }} -

-
{{ item.note.content|safe}}
- {% else %} -

- {{ item.show.broadcastformat.format }} -

- {% endif %} -
-
-{% endfor %} -
-
- - - -- cgit v0.10.2 From 8c50b529e7f14096d5efb92553dedbdf27bd74d7 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 20:00:07 +0100 Subject: added is_active model field diff --git a/program/migrations/0003_host_is_active.py b/program/migrations/0003_host_is_active.py new file mode 100644 index 0000000..28c1049 --- /dev/null +++ b/program/migrations/0003_host_is_active.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('program', '0002_host_is_always_visible'), + ] + + operations = [ + migrations.AddField( + model_name='host', + name='is_active', + field=models.BooleanField(default=True, verbose_name='Is active', editable=False), + ), + ] -- cgit v0.10.2 From b8d4c16285aa294846c7b9066ed3bb9293802f06 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 20:00:25 +0100 Subject: added is_active model field diff --git a/program/migrations/0004_show_is_active.py b/program/migrations/0004_show_is_active.py new file mode 100644 index 0000000..26e3205 --- /dev/null +++ b/program/migrations/0004_show_is_active.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('program', '0003_host_is_active'), + ] + + operations = [ + migrations.AddField( + model_name='show', + name='is_active', + field=models.BooleanField(default=True, verbose_name='Is active', editable=False), + ), + ] -- cgit v0.10.2 From b1b142c22135543e01a8dede7f2c70522d29d933 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 20:00:42 +0100 Subject: added is_active model field diff --git a/program/migrations/0005_programslot_is_active.py b/program/migrations/0005_programslot_is_active.py new file mode 100644 index 0000000..31975c8 --- /dev/null +++ b/program/migrations/0005_programslot_is_active.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('program', '0004_show_is_active'), + ] + + operations = [ + migrations.AddField( + model_name='programslot', + name='is_active', + field=models.BooleanField(default=True, verbose_name='Is active', editable=False), + ), + ] -- cgit v0.10.2 From 49cd6812d07c4ee1519ade5ea4d20578c25a91c3 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 20:01:45 +0100 Subject: added commands to update new model fields diff --git a/program/management/commands/update_hosts.py b/program/management/commands/update_hosts.py new file mode 100644 index 0000000..22e0596 --- /dev/null +++ b/program/management/commands/update_hosts.py @@ -0,0 +1,21 @@ +from django.core.management.base import NoArgsCommand + +from program.models import Host + + +class Command(NoArgsCommand): + help = 'update host by setting is_active' + + def handle_noargs(self, **options): + for host in Host.objects.all(): + for show in host.shows.all(): + hosts_active_show = None + if show.has_active_programslots: + hosts_active_show = True + else: + hosts_active_show = False + + host.hosts_active_show = hosts_active_show + + if not hosts_active_show: + host.save() diff --git a/program/management/commands/update_programslots.py b/program/management/commands/update_programslots.py new file mode 100644 index 0000000..62de064 --- /dev/null +++ b/program/management/commands/update_programslots.py @@ -0,0 +1,14 @@ +from django.core.management.base import NoArgsCommand + +from program.models import ProgramSlot + +from datetime import date + + +class Command(NoArgsCommand): + help = 'update programslots by setting is_active' + + def handle_noargs(self, **options): + for programslot in ProgramSlot.objects.all(): + programslot.is_active = programslot.until > date.today() + programslot.save() diff --git a/program/management/commands/update_shows.py b/program/management/commands/update_shows.py new file mode 100644 index 0000000..d582bb5 --- /dev/null +++ b/program/management/commands/update_shows.py @@ -0,0 +1,22 @@ +from django.core.management.base import NoArgsCommand + +from program.models import Show + +from datetime import date + + +class Command(NoArgsCommand): + help = 'update shows by setting is_active' + + def handle_noargs(self, **options): + for show in Show.objects.exclude(pk=1): + has_active_programslots = None + for programslot in show.programslots.all(): + if programslot.until > date.today(): + has_active_programslots = True + else: + has_active_programslots = False + show.has_active_programslots = has_active_programslots + + if not has_active_programslots: + show.save() -- cgit v0.10.2 From 1471381dfe74411934ec51f88bb5c4e7e47f2c36 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 20:02:27 +0100 Subject: added new model fields and updated admin diff --git a/program/admin.py b/program/admin.py index 3086dd5..8a9799c 100644 --- a/program/admin.py +++ b/program/admin.py @@ -28,6 +28,11 @@ class ShowTopicAdmin(admin.ModelAdmin): prepopulated_fields = {'slug': ('topic',)} +class HostAdmin(admin.ModelAdmin): + list_display = ('name',) + list_filter = ('always_visible', 'is_active') + + class NoteAdmin(admin.ModelAdmin): date_hierarchy = 'start' list_display = ('title', 'show', 'start', 'status') @@ -58,8 +63,8 @@ class TimeSlotInline(admin.TabularInline): class ProgramSlotAdmin(admin.ModelAdmin): actions = ('renew',) inlines = (TimeSlotInline,) - list_display = ('show', 'byweekday', 'rrule', 'tstart', 'tend', 'until', 'timeslot_count') - list_filter = ('byweekday', 'rrule', 'is_repetition') + list_display = ('show', 'byweekday', 'rrule', 'tstart', 'tend', 'until') + list_filter = ('byweekday', 'rrule', 'is_repetition', 'is_active') ordering = ('byweekday', 'dstart') save_on_top = True search_fields = ('show__name',) @@ -83,8 +88,8 @@ class ProgramSlotInline(admin.TabularInline): class ShowAdmin(admin.ModelAdmin): 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') + list_filter = ('broadcastformat', 'showinformation', 'showtopic', 'musicfocus', 'is_active') ordering = ('slug',) prepopulated_fields = {'slug': ('name',)} search_fields = ('name', 'short_description', 'description') @@ -94,13 +99,11 @@ class ShowAdmin(admin.ModelAdmin): 'musicfocus', ) - admin.site.register(BroadcastFormat, BroadcastFormatAdmin) admin.site.register(MusicFocus, MusicFocusAdmin) admin.site.register(ShowInformation, ShowInformationAdmin) admin.site.register(ShowTopic, ShowTopicAdmin) +admin.site.register(Host, HostAdmin) admin.site.register(Note, NoteAdmin) admin.site.register(ProgramSlot, ProgramSlotAdmin) admin.site.register(Show, ShowAdmin) - -admin.site.register(Host) diff --git a/program/models.py b/program/models.py index 8013b84..11ec7f1 100644 --- a/program/models.py +++ b/program/models.py @@ -211,6 +211,7 @@ class MusicFocus(models.Model): class Host(models.Model): name = models.CharField(_("Name"), max_length=128) always_visible = models.BooleanField(_("Always visible"), default=False) + is_active = models.BooleanField(_("Is active"), default=True, editable=False) email = models.EmailField(_("E-Mail"), blank=True) website = models.URLField(_("Website"), blank=True) @@ -223,7 +224,7 @@ class Host(models.Model): return u'%s' % self.name def get_absolute_url(self): - return reverse('host-detail', args=[self.id]) + return reverse('host-detail', args=[str(self.id)]) class Show(models.Model): @@ -242,6 +243,7 @@ class Show(models.Model): description = tinymce_models.HTMLField(_("Description"), blank=True, null=True) email = models.EmailField(_("E-Mail"), blank=True, null=True) website = models.URLField(_("Website"), blank=True, null=True) + is_active = models.BooleanField(_("Is active"), default=True, editable=False) cba_series_id = models.IntegerField(_("CBA series ID"), blank=True, null=True) automation_id = models.IntegerField(_("Automation ID"), blank=True, null=True, choices=get_automation_id_choices()) created = models.DateTimeField(auto_now_add=True, editable=False) @@ -258,12 +260,6 @@ class Show(models.Model): def get_absolute_url(self): return reverse('show-detail', args=[self.slug]) - def has_active_programslots(self): - return self.programslots.filter(until__gt=date.today()).count() > 0 - - has_active_programslots.boolean = True - has_active_programslots.short_description = _("Has active program slots") - class RRule(models.Model): FREQ_CHOICES = ( @@ -312,6 +308,7 @@ class ProgramSlot(models.Model): tstart = models.TimeField(_("Start time")) tend = models.TimeField(_("End time")) until = models.DateField(_("Last date")) + is_active = models.BooleanField(_("Is active"), default=True, editable=False) is_repetition = models.BooleanField(_("Is repetition"), default=False) automation_id = models.IntegerField(_("Automation ID"), blank=True, null=True, choices=get_automation_id_choices()) created = models.DateTimeField(auto_now_add=True, editable=False) @@ -350,6 +347,9 @@ class ProgramSlot(models.Model): else: old = False + self.is_active = self.until > date.today() + self.show.is_active = self.until > date.today() + super(ProgramSlot, self).save(*args, **kwargs) if self.rrule.freq == 0: @@ -389,29 +389,16 @@ class ProgramSlot(models.Model): if not old: for k in range(min(len(starts), len(ends))): - timeslot = TimeSlot.objects.create(programslot=self, start=starts[k], end=ends[k]) + TimeSlot.objects.create(programslot=self, start=starts[k], end=ends[k]) elif self.until > old.until: for k in range(min(len(starts), len(ends))): if starts[k].date() > old.until: - timeslot = TimeSlot.objects.create(programslot=self, start=starts[k], end=ends[k]) - - def timeslot_count(self): - return self.timeslots.count() - - timeslot_count.description = _("Time slot count") - - def has_active_timeslot(self): - if self.timeslots.count() > 0: - start = self.timeslots.all().order_by("start")[0].start - end = self.timeslots.all().order_by("-end")[0].end - now = datetime.now() - return (start < now and end > now) - else: - return False + TimeSlot.objects.create(programslot=self, start=starts[k], end=ends[k]) class TimeSlotManager(models.Manager): - def get_or_create_current(self): + @staticmethod + def get_or_create_current(): try: return TimeSlot.objects.get(start__lte=datetime.now(), end__gt=datetime.now()) except MultipleObjectsReturned: @@ -421,13 +408,19 @@ class TimeSlotManager(models.Manager): today = date.today().weekday() default = Show.objects.get(pk=1) - previous = TimeSlot.objects.filter(end__lte=datetime.now()).order_by('-start')[0] - next = TimeSlot.objects.filter(start__gte=datetime.now())[0] + previous_timeslot = TimeSlot.objects.filter(end__lte=datetime.now()).order_by('-start')[0] + next_timeslot = TimeSlot.objects.filter(start__gte=datetime.now())[0] - dstart, tstart = previous.end.date(), previous.end.time() - until, tend = next.start.date(), next.start.time() + dstart, tstart = previous_timeslot.end.date(), previous_timeslot.end.time() + until, tend = next_timeslot.start.date(), next_timeslot.start.time() - new_programslot = ProgramSlot(rrule=once, byweekday=today, show=default, dstart=dstart, tstart=tstart, tend=tend, until=until) + new_programslot = ProgramSlot(rrule=once, + byweekday=today, + show=default, + dstart=dstart, + tstart=tstart, + tend=tend, + until=until) try: new_programslot.validate_unique() @@ -437,14 +430,16 @@ class TimeSlotManager(models.Manager): else: return new_programslot.timeslots.all()[0] - def get_day_timeslots(self, day): + @staticmethod + def get_day_timeslots(day): today = datetime.combine(day, time(6, 0)) tomorrow = today + timedelta(days=1) return TimeSlot.objects.filter(Q(start__lte=today, end__gte=today) | Q(start__gt=today, start__lt=tomorrow)).exclude(end=today) - def get_24h_timeslots(self, start): + @staticmethod + def get_24h_timeslots(start): end = start + timedelta(hours=24) return TimeSlot.objects.filter(Q(start__lte=start, end__gte=start) | @@ -475,7 +470,7 @@ class TimeSlot(models.Model): super(TimeSlot, self).save(*args, **kwargs) def get_absolute_url(self): - return reverse('timeslot-detail', args=[self.id]) + return reverse('timeslot-detail', args=[str(self.id)]) class Note(models.Model): -- cgit v0.10.2 From c547dce30366b3a6097008086cbc0b917c6a2f85 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 20:03:56 +0100 Subject: formated templates and updated templatetags diff --git a/program/templates/boxes/broadcastformat.html b/program/templates/boxes/broadcastformat.html index 76ee382..c12e635 100644 --- a/program/templates/boxes/broadcastformat.html +++ b/program/templates/boxes/broadcastformat.html @@ -1,10 +1,11 @@ {% if broadcastformats %} -
-
Legende
- {% for broadcastformat in broadcastformats %} -
- {{ broadcastformat.format }} -
- {% endfor %} -
+
+
Legende
+ {% for bf in broadcastformat_list %} +
+ {{ bf.format }} +
+ {% endfor %} +
{% endif %} diff --git a/program/templates/boxes/current.html b/program/templates/boxes/current.html index ba1df21..4f81906 100644 --- a/program/templates/boxes/current.html +++ b/program/templates/boxes/current.html @@ -1,60 +1,65 @@ - - Current program box + + Current program box - - {% if previous or current or next or after_next %} -
-
Programm derzeit
-
- - - - - - - - - - - - - - - - - - - - - - - - -
{{ previous.start|date:"H:i" }}  -

{{ previous.show.name }}

-
{{ current.start|date:"H:i" }} -

{{ current.show.name }}

- {% if current.note %} -

{{ current.note.title }}

- {% else %} -

{{ current.show.short_description }}

- {% endif %} -
{{ next.start|date:"H:i" }}  -

{{ next.show.name }}

-
{{ after_next.start|date:"H:i" }}  -

{{ after_next.show.name }}

-
-
-
- {% endif %} - +{% if previous_timeslot or current_timeslot or next_timeslot or after_next_timeslot %} +
+
Programm derzeit
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
{{ previous_timeslot.start|date:"H:i" }}  +

+ {{ previous_timeslot.show.name }} +

+
{{ current_timeslot.start|date:"H:i" }} +

+ {{ current_timeslot.show.name }} +

+ {% if current_timeslot.note %} +

{{ current_timeslot.note.title }}

+ {% else %} +

{{ current_timeslot.show.short_description }}

+ {% endif %} +
{{ next_timeslot.start|date:"H:i" }}  +

{{ next_timeslot.show.name }} +

+
{{ after_next_timeslot.start|date:"H:i" }}  +

+ {{ after_next_timeslot.show.name }} +

+
+
+
+{% endif %} diff --git a/program/templates/boxes/musicfocus.html b/program/templates/boxes/musicfocus.html index 01fffae..292cea0 100644 --- a/program/templates/boxes/musicfocus.html +++ b/program/templates/boxes/musicfocus.html @@ -1,14 +1,15 @@ {% if musicfoci %} -
-
Musiktendenz
-
-
    - {% for item in musicfoci %} -
  • - {{ item }} -
  • - {% endfor %} -
-
-
+
+
Musiktendenz
+
+
    + {% for mf in musicfocus_list %} +
  • + {{ mf.focus }} +
  • + {% endfor %} +
+
+
{% endif %} diff --git a/program/templates/boxes/recommendation.html b/program/templates/boxes/recommendation.html index d2bb7d2..3f4429e 100644 --- a/program/templates/boxes/recommendation.html +++ b/program/templates/boxes/recommendation.html @@ -1,40 +1,39 @@ - - Recomendations box + + Recomendations box - {% if recommendation_list %} -
-
Programmhinweise
-
- - {% for item in recommendation_list %} - - - - - - {% endfor %} -
   - {{ item.start|date:"d.m. H:i" }} - - {{ item.end|date:"H:i" }}
-

- {{ item.show.name }} -

-

- {% if item.note %} - {{ item.note.title }}
- {% else %} - {{ item.show.broadcastformat.format }}
- {% endif %} - [weiter] -

-
-
-
- {% endif %} +{% if recommendation_list %} +
+
Programmhinweise
+
+ + {% for recommendation in recommendation_list %} + + + + + + {% endfor %} +
   + {{ recommendation.start|date:"d.m. H:i" }} - {{ recommendation.end|date:"H:i" }}
+

+ {{ recommendation.show.name }} +

+

+ {% if recommendation.note %} + {{ recommendation.note.title }}
+ {% else %} + {{ recommendation.show.broadcastformat.format }}
+ {% endif %} + [weiter] +

+
+
+
+{% endif %} diff --git a/program/templates/boxes/showinformation.html b/program/templates/boxes/showinformation.html index ac4dc2c..52c40e0 100644 --- a/program/templates/boxes/showinformation.html +++ b/program/templates/boxes/showinformation.html @@ -1,14 +1,16 @@ {% if showinformations %} -
-
Sendungsinfo
-
-
    - {% for item in showinformations %} -
  • - {{ item }} -
  • - {% endfor %} -
-
-
+
+
Sendungsinfo
+
+ +
+
{% endif %} diff --git a/program/templates/boxes/showtopic.html b/program/templates/boxes/showtopic.html index 3a1938d..8561343 100644 --- a/program/templates/boxes/showtopic.html +++ b/program/templates/boxes/showtopic.html @@ -1,14 +1,16 @@ {% if showtopics %} -
-
Thema / Schwerpunkt
-
-
    - {% for item in showtopics %} -
  • - {{ item }} -
  • - {% endfor %} -
-
-
+
+
Thema / Schwerpunkt
+
+ +
+
{% endif %} diff --git a/program/templates/day_schedule.html b/program/templates/day_schedule.html index f338940..7a371e6 100644 --- a/program/templates/day_schedule.html +++ b/program/templates/day_schedule.html @@ -1,43 +1,42 @@ - Tagesansicht {{ day|date:"l, d.m.Y" }} — Radio Helsinki - Freies Radio Graz - - - - - - + Tagesansicht {{ day|date:"l, d.m.Y" }} — Radio Helsinki - Freies Radio Graz + + + + +
-
Kalender
-
-
-
+
Kalender
+
+
+
{% load content_boxes %}
-{% broadcastformat %} + {% broadcastformat %}
{% comment %} @@ -56,70 +55,76 @@ jQuery(document).ready(function() {

{{ day|date:"l, d.m.Y" }}

- {% for timeslot in timeslots %} - {% if forloop.first and timeslot.start != timeslot.get_previous_by_start.end %} -
-
{{ timeslot.get_previous_by_start.end|date:"H:i" }}
-
- {% for item in default_show.showinformation.all %} - {{ item.abbrev }} - {% endfor %} - {% for item in default_show.showtopic.all %} - {{ item.abbrev }} - {% endfor %} - {% for item in default_show.musicfocus.all %} - {{ item.abbrev }} - {% endfor %} -
-
-

{{ default_show.name }}

-

{{ default_show.short_description }}

-
-
- {% endif %} -
-
{{ timeslot.start|date:"H:i" }}
-
- {% for item in timeslot.show.showinformation.all %} - {{ item.abbrev }} - {% endfor %} - {% for item in timeslot.show.showtopic.all %} - {{ item.abbrev }} - {% endfor %} - {% for item in timeslot.show.musicfocus.all %} - {{ item.abbrev }} - {% endfor %} -
-
-

{{ timeslot.show.name }}

- {% if timeslot.note %} -

Heute: {{ timeslot.note.title }}

- {% else %} -

{{ timeslot.show.short_description }}

+ {% for timeslot in timeslots %} + {% if forloop.first and timeslot.start != timeslot.get_previous_by_start.end %} +
+
{{ timeslot.get_previous_by_start.end|date:"H:i" }}
+
+ {% for si in default_show.showinformation.all %} + {{ si.abbrev }} + {% endfor %} + {% for st in default_show.showtopic.all %} + {{ st.abbrev }} + {% endfor %} + {% for mf in default_show.musicfocus.all %} + {{ mf.abbrev }} + {% endfor %} +
+
+

{{ default_show.name }}

+

{{ default_show.short_description }}

+
+
{% endif %} -
-
- {% if timeslot.end != timeslot.get_next_by_start.start %} -
-
{{ timeslot.end|date:"H:i" }}
+
+
{{ timeslot.start|date:"H:i" }}
- {% for item in default_show.showinformation.all %} - {{ item.abbrev }} - {% endfor %} - {% for item in default_show.showtopic.all %} - {{ item.abbrev }} - {% endfor %} - {% for item in default_show.musicfocus.all %} - {{ item.abbrev }} - {% endfor %} + {% for si in timeslot.show.showinformation.all %} + {{ si.abbrev }} + {% endfor %} + {% for st in timeslot.show.showtopic.all %} + {{ st.abbrev }} + {% endfor %} + {% for mf in timeslot.show.musicfocus.all %} + {{ mf.abbrev }} + {% endfor %}
-

{{ default_show.name }}

-

{{ default_show.short_description }}

+

{{ timeslot.show.name }}

+ {% if timeslot.note %} +

Heute: {{ timeslot.note.title }}

+ {% else %} +

{{ timeslot.show.short_description }}

+ {% endif %}
- {% endif %} - {% endfor %} + {% if timeslot.end != timeslot.get_next_by_start.start %} +
+
{{ timeslot.end|date:"H:i" }}
+
+ {% for si in default_show.showinformation.all %} + {{ si.abbrev }} + {% endfor %} + {% for st in default_show.showtopic.all %} + {{ st.abbrev }} + {% endfor %} + {% for mf in default_show.musicfocus.all %} + {{ mf.abbrev }} + {% endfor %} +
+
+

{{ default_show.name }}

+

{{ default_show.short_description }}

+
+
+ {% endif %} + {% endfor %}
diff --git a/program/templates/host_detail.html b/program/templates/host_detail.html index 3d8e862..73182d6 100644 --- a/program/templates/host_detail.html +++ b/program/templates/host_detail.html @@ -9,22 +9,22 @@
Sendungen
- - {% for show in host.shows.all %} - {% if show.has_active_programslots %} - - {% else %} -
{{ show }}
- {% endif %} - {% endfor %} + {% for show in host.shows.all %} + {% if show.is_active %} + + {% else %} +
{{ show }}
+ {% endif %} + {% endfor %}
{% if host.email %} -
E-Mail Adresse: {{ host.email }}
+
E-Mail Adresse: {{ host.email }}
{% endif %} {% if host.website %} - + {% endif %} diff --git a/program/templates/host_list.html b/program/templates/host_list.html index d1c8427..ada9bf1 100644 --- a/program/templates/host_list.html +++ b/program/templates/host_list.html @@ -5,14 +5,14 @@
-

Sendungsmachende A-Z

-
-{% for host in host_list %} -
- {{ host.name }} +

Sendungsmachende A-Z

+
+ {% for host in host_list %} + + {% endfor %}
-{% endfor %} -
diff --git a/program/templates/recommendation_list.html b/program/templates/recommendation_list.html index 3836a35..8070b29 100644 --- a/program/templates/recommendation_list.html +++ b/program/templates/recommendation_list.html @@ -5,40 +5,41 @@
-

Programmhinweise

-
-{% for recommendation in recommendation_list %} -
-
- {% for si in recommendation.show.showinformation.all %} - {{ si.abbrev }} +

Programmhinweise

+
+ {% for recommendation in recommendation_list %} +
+
+ {% for si in recommendation.show.showinformation.all %} + {{ si.abbrev }} + {% endfor %} + {% for st in recommendation.show.showtopic.all %} + {{ st.abbrev }} + {% endfor %} + {% for mf in recommendation.show.musicfocus.all %} + {{ mf.abbrev }} + {% endfor %} +
+
+

+ {{ recommendation.show.name }}
+ vom {{ recommendation.start|date:"d.m. H:i" }}-{{ recommendation.end|date:"H:i" }}

+ {% if recommendation.note %} +

+ {{ recommendation.note.title }} +
{{ recommendation.note.content|safe }}
+ {% else %} +

{{ recommendation.show.broadcastformat.format }} +

+ {% endif %} +
+
{% endfor %} - {% for st in recommendation.show.showtopic.all %} - {{ st.abbrev }} - {% endfor %} - {% for mf in recommendation.show.musicfocus.all %} - {{ mf.abbrev }} - {% endfor %} -
-
-

- {{ recommendation.show.name }}
- vom {{ recommendation.start|date:"d.m. H:i" }}-{{ recommendation.end|date:"H:i" }} -

- {% if recommendation.note %} -

- {{ recommendation.note.title }} -

-
{{ recommendation.note.content|safe}}
- {% else %} -

- {{ recommendation.show.broadcastformat.format }} -

- {% endif %} -
-{% endfor %} -
diff --git a/program/templates/show_detail.html b/program/templates/show_detail.html index 0f4b302..3ab80ed 100644 --- a/program/templates/show_detail.html +++ b/program/templates/show_detail.html @@ -8,72 +8,73 @@
-
-
-

{{ show.name }}

- {% if show.id != 1 %} -

- {% for slot in show.programslots.all %} - {% if slot.has_active_timeslot %} - {{ slot }}
- {% endif %} - {% endfor %} -

- {% endif %} -
+
+
+

{{ show.name }}

+ {% if show.id != 1 %} +

+ {% for slot in show.programslots.all %} + {% if slot.is_active %} + {{ slot }}
+ {% endif %} + {% endfor %} +

+ {% endif %} +
-
-

{{ show.broadcastformat.format }}

- {% for item in show.showinformation.all %} - {{ item.abbrev }} - {% endfor %} - {% for item in show.showtopic.all %} - {{ item.abbrev }} - {% endfor %} - {% for item in show.musicfocus.all %} - {{ item.abbrev }} - {% endfor %} -
+
+

{{ show.broadcastformat.format }}

+ {% for item in show.showinformation.all %} + {{ item.abbrev }} + {% endfor %} + {% for item in show.showtopic.all %} + {{ item.abbrev }} + {% endfor %} + {% for item in show.musicfocus.all %} + {{ item.abbrev }} + {% endfor %} +
-
+
{{ show.short_description }}
{% if show.description %} -
{{ show.description|safe }}
+
{{ show.description|safe }}
{% endif %} {% if show.image and show.image_enabled %} -
image
+
image
{% endif %}

- {% for host in show.hosts.all %} - {{ host }}
- {% endfor %} - {% if show.email %} - Email: {{ show.email }}
- {% endif %} - {% if show.website %} - Website: {{ show.website }}
- {% endif %} - {% if show.cba_series_id %} - CBA-Link: CBA
- {% endif %} + {% for host in show.hosts.all %} + {{ host }}
+ {% endfor %} + {% if show.email %} + Email: {{ show.email }}
+ {% endif %} + {% if show.website %} + Website: {{ show.website }}
+ {% endif %} + {% if show.cba_series_id %} + CBA-Link: CBA
+ {% endif %}

{% if show.notes.all %} -
-

Sendungstipps

- - {% endif %} +
+

Sendungstipps

+ + {% endif %}
diff --git a/program/templates/show_list.html b/program/templates/show_list.html index 167a470..136930d 100644 --- a/program/templates/show_list.html +++ b/program/templates/show_list.html @@ -6,48 +6,51 @@ {% load content_boxes %}
-{% broadcastformat %} + {% broadcastformat %}
-
-
Filter
-
-{% musicfocus %} -{% showinformation %} -{% showtopic %} +
+
Filter
+
+ {% musicfocus %} + {% showinformation %} + {% showtopic %}
-

Sendungen A-Z

+

Sendungen A-Z

-
- {% for show in show_list %} -
-
- {% for item in show.showinformation.all %} - {{ item.abbrev }} +
+ {% for show in show_list %} +
+
+ {% for item in show.showinformation.all %} + {{ item.abbrev }} + {% endfor %} + {% for item in show.showtopic.all %} + {{ item.abbrev }} + {% endfor %} + {% for item in show.musicfocus.all %} + {{ item.abbrev }} + {% endfor %} +
+
+

{{ show.name }}

+
    + {% for slot in show.programslots.all %} + {% if slot.has_active_timeslot %} +
  • {{ slot }}
  • + {% endif %} + {% endfor %} +
+

{{ show.short_description }}

+
+
{% endfor %} - {% for item in show.showtopic.all %} - {{ item.abbrev }} - {% endfor %} - {% for item in show.musicfocus.all %} - {{ item.abbrev }} - {% endfor %} -
-
-

{{ show.name }}

-
    - {% for slot in show.programslots.all %} - {% if slot.has_active_timeslot %} -
  • {{ slot }}
  • - {% endif %} - {% endfor %} -
-

{{ show.short_description }}

-
- {% endfor %} -
diff --git a/program/templates/styles.css b/program/templates/styles.css index 2934a7f..395be34 100644 --- a/program/templates/styles.css +++ b/program/templates/styles.css @@ -6,10 +6,12 @@ .mf-{{ mf.abbrev }} { background-image:url({{ mf.button_url }}); } .filterbox .mf-{{ mf.abbrev }}:hover { background-image:url({{ mf.button_hover_url }}); } {% endfor %} + {% for si in showinformation %} .si-{{ si.abbrev }} { background-image:url({{ si.button_url }}); } .filterbox .si-{{ si.abbrev }}:hover { background-image:url({{ si.button_hover_url }}); } {% endfor %} + {% for st in showtopic %} .st-{{ st.abbrev }} { background-image:url({{ st.button_url }}); } .filterbox .st-{{ st.abbrev }}:hover { background-image:url({{ st.button_hover_url }}); } @@ -18,9 +20,11 @@ {% for mf in musicfocus %} .show-detail-header .mf-{{ mf.abbrev }} { background-image:url({{ mf.big_button_url }}); } {% endfor %} + {% for si in showinformation %} .show-detail-header .si-{{ si.abbrev }} { background-image:url({{ si.big_button_url }}); } {% endfor %} + {% for st in showtopic %} .show-detail-header .st-{{ st.abbrev }} { background-image:url({{ st.big_button_url }}); } {% endfor %} diff --git a/program/templates/timeslot_detail.html b/program/templates/timeslot_detail.html index 856aef3..c899c32 100644 --- a/program/templates/timeslot_detail.html +++ b/program/templates/timeslot_detail.html @@ -6,53 +6,53 @@
-
-

- {{ timeslot.show.name }} -

- {% if timeslot.note %} -

{{ timeslot.note.title }}

- {% endif %} - Sendung am {{ timeslot.start|date:"d.m. H:i" }} bis {{ timeslot.end|date:"H:i" }} - -
- {% for item in timeslot.show.showinformation.all %} - {{ item.abbrev }} - {% endfor %} - {% for item in timeslot.show.showtopic.all %} - {{ item.abbrev }} - {% endfor %} - {% for item in timeslot.show.musicfocus.all %} - {{ item.abbrev }} - {% endfor %} -
- -

{{ timeslot.show.broadcastformat.format }}

+
+

+ {{ timeslot.show.name }} +

+ {% if timeslot.note %} +

{{ timeslot.note.title }}

+ {% endif %} + Sendung am {{ timeslot.start|date:"d.m. H:i" }} bis {{ timeslot.end|date:"H:i" }} + +
+ {% for si in timeslot.show.showinformation.all %} + {{ si.abbrev }} + {% endfor %} + {% for st in timeslot.show.showtopic.all %} + {{ st.abbrev }} + {% endfor %} + {% for mf in timeslot.show.musicfocus.all %} + {{ mf.abbrev }} + {% endfor %} +
+ +

{{ timeslot.show.broadcastformat.format }}

{% if timeslot.note %} -

{{ timeslot.note.content|safe }}

+

{{ timeslot.note.content|safe }}

{% endif %}
{{ timeslot.show.short_description }}
{% if timeslot.show.description %} -
{{ timeslot.show.description|safe }}
+
{{ timeslot.show.description|safe }}
{% endif %}

- {% for host in timeslot.show.hosts.all %} - {{ host }}
- {% endfor %} - {% if timeslot.show.email %} - Email: {{ timeslot.show.email }}
- {% endif %} - {% if timeslot.show.website %} - Website: {{ timeslot.show.website }}
- {% endif %} - {% if timeslot.show.cba_series_id %} - CBA-Link: CBA
- {% endif %} + {% for host in timeslot.show.hosts.all %} + {{ host }}
+ {% endfor %} + {% if timeslot.show.email %} + Email: {{ timeslot.show.email }}
+ {% endif %} + {% if timeslot.show.website %} + Website: {{ timeslot.show.website }}
+ {% endif %} + {% if timeslot.show.cba_series_id %} + CBA-Link: CBA
+ {% endif %}

diff --git a/program/templates/week_schedule.html b/program/templates/week_schedule.html index a10a4c1..ad6b012 100644 --- a/program/templates/week_schedule.html +++ b/program/templates/week_schedule.html @@ -6,17 +6,17 @@
- - - - - - - - - - -
<--{{ cur_w }}{{ next_w1 }}{{ next_w2 }}{{ next_w3 }}{{ next_w4 }}-->
+ + + + + + + + + + +
<--{{ cur_w }}{{ next_w1 }}{{ next_w2 }}{{ next_w3 }}{{ next_w4 }}-->
 
06:00
@@ -119,8 +119,8 @@
03:00
04:00
05:00
-
- +
+
diff --git a/program/templates/week_schedule_timeslot.html b/program/templates/week_schedule_timeslot.html index 852466b..8942327 100644 --- a/program/templates/week_schedule_timeslot.html +++ b/program/templates/week_schedule_timeslot.html @@ -1,54 +1,54 @@ {% load timeslots %} {% if forloop.first and timeslot.start != timeslot.get_previous_by_start.end %} -
-
{{ default_show.name }}
-
+
+
{{ default_show.name }}
+
{% endif %} {% if forloop.first and timeslot.start == timeslot.get_next_by_start.end and timeslot.start != "06:00" %} - + {% endif %} {% if forloop.first and timeslot.start != "06:00" and timeslot.show == default_show %} - + {% endif %} {% if forloop.first and timeslot.start != "06:00" and timeslot.show != default_show %} - + {% endif %} {% if not forloop.first and not forloop.last %} - - {% if timeslot.end != timeslot.get_next_by_start.start %} -
-
{{ default_show.name }}
+ + {% if timeslot.end != timeslot.get_next_by_start.start %} +
+
{{ default_show.name }}
+
{% endif %} {% endif %} {% if forloop.last and timeslot.end != "06:00" and timeslot.show == default_show %} - + {% endif %} {% if forloop.last and timeslot.end != "06:00" and timeslot.show != default_show %} - + {% endif %} {% if forloop.last and timeslot.end != timeslot.get_next_by_start.start %} -
-
{{ default_show.name }}
-
-{% endif %} +
+
{{ default_show.name }}
+
+{% endif %} diff --git a/program/templatetags/content_boxes.py b/program/templatetags/content_boxes.py index 6e2b6c7..7f176c6 100644 --- a/program/templatetags/content_boxes.py +++ b/program/templatetags/content_boxes.py @@ -8,23 +8,19 @@ from program.models import BroadcastFormat, MusicFocus, ShowInformation, ShowTop @register.inclusion_tag('boxes/broadcastformat.html') def broadcastformat(): - broadcastformats = BroadcastFormat.objects.filter(enabled=True) - return {'broadcastformats': broadcastformats} + return {'broadcastformat_list': BroadcastFormat.objects.filter(enabled=True)} @register.inclusion_tag('boxes/musicfocus.html') def musicfocus(): - musicfoci = MusicFocus.objects.all() - return {'musicfoci': musicfoci} + return {'musicfocus_list': MusicFocus.objects.all()} @register.inclusion_tag('boxes/showinformation.html') def showinformation(): - showinformations = ShowInformation.objects.all() - return {'showinformations': showinformations} + return {'showinformation_list': ShowInformation.objects.all()} @register.inclusion_tag('boxes/showtopic.html') def showtopic(): - showtopics = ShowTopic.objects.all() - return {'showtopics': showtopics} + return {'showtopic_list': ShowTopic.objects.all()} -- cgit v0.10.2 From f4edd054b264ffe0002dad2ef41bf45a95e4928a Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 20:04:39 +0100 Subject: moved tofirstdayinisoweek to utils diff --git a/program/utils.py b/program/utils.py index 9a086da..587e83d 100644 --- a/program/utils.py +++ b/program/utils.py @@ -3,6 +3,7 @@ from django.conf import settings import json import urllib from os.path import join +from datetime import datetime, date, timedelta def get_automation_id_choices(): @@ -26,3 +27,11 @@ def get_automation_id_choices(): shows = [(s['id'], s['title']) for s in shows_list] return shows + + +def tofirstdayinisoweek(year, week): + # http://stackoverflow.com/questions/5882405/get-date-from-iso-week-number-in-python + ret = datetime.strptime('%04d-%02d-1' % (year, week), '%Y-%W-%w') + if date(year, 1, 4).isoweekday() > 4: + ret -= timedelta(days=7) + return ret -- cgit v0.10.2 From 7a172c49277a17008f4f6c3303501b86f6df2118 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 20:05:44 +0100 Subject: updated TEMPLATE settings to new style diff --git a/pv/settings.py b/pv/settings.py index ead2704..d966f2c 100644 --- a/pv/settings.py +++ b/pv/settings.py @@ -43,11 +43,26 @@ STATIC_URL = '/static/' SECRET_KEY = '' -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', - # 'django.template.loaders.eggs.Loader', -) +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + 'templates' + ], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.contrib.auth.context_processors.auth', + 'django.template.context_processors.debug', + 'django.template.context_processors.i18n', + 'django.template.context_processors.media', + 'django.template.context_processors.static', + 'django.template.context_processors.tz', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', -- cgit v0.10.2 From 7f505ce017f7e28e4e3e7f55f26c425b1d1375a7 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 20:12:21 +0100 Subject: moved to class based generic views diff --git a/program/urls.py b/program/urls.py index d02ee31..49d0488 100644 --- a/program/urls.py +++ b/program/urls.py @@ -1,30 +1,43 @@ from django.conf import settings from django.conf.urls import patterns, url +from django.db.models import Q from django.views.decorators.cache import cache_page +from django.views.generic.detail import DetailView +from django.views.generic.list import ListView -from views import current_show, day_schedule, recommendations, show_list, show_detail, timeslot_detail, week_schedule, styles, host_list, host_detail +from views import ShowListView, CurrentShowBoxView, RecommendationsListView, RecommendationsBoxView, DayScheduleView, StylesView, WeekScheduleView +from models import Host, Show, TimeSlot import os +from datetime import date, datetime, timedelta PROGRAM_SITE_MEDIA = os.path.join(os.path.dirname(__file__), '../site_media') -recommendations_dict = {'template_name': 'boxes/recommendations.html'} +now = datetime.now() +end = now + timedelta(weeks=1) -urlpatterns = patterns('', - url(r'^today/?$', day_schedule), - url(r'^week/?$', week_schedule), - url(r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/?$', day_schedule), - url(r'^(?P\d{4})/(?P\d{1,2})/?$', week_schedule), - url(r'^current_box/?$', cache_page(60)(current_show)), - url(r'^hosts/?$', host_list), - url(r'^hosts/(?P\d+)/?$', host_detail, name='host-detail'), - url(r'^tips/?$', recommendations), - url(r'^tips_box/?$', recommendations, recommendations_dict), - url(r'^shows/?$', show_list), - url(r'^shows/(?P[\w-]+)/?$', show_detail, name='show-detail'), - url(r'^(?P\d+)/?$', timeslot_detail, name='timeslot-detail'), - url(r'^styles.css$', styles)) +hosts = Host.objects.filter(Q(shows__programslots__until__gte=date.today()) | + Q(always_visible=True)).distinct() +shows = Show.objects.filter(programslots__until__gt=date.today()).exclude(id=1).distinct() +timeslots = TimeSlot.objects.all() +recommendations = TimeSlot.objects.filter(Q(note__isnull=False, note__status=1, start__range=(now, end)) | + Q(show__broadcastformat__slug='sondersendung', start__range=(now, end))).order_by('start')[:20] +urlpatterns = patterns('', + url(r'^today/?$', DayScheduleView.as_view()), + url(r'^week/?$', WeekScheduleView.as_view()), + url(r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/?$', DayScheduleView.as_view()), + url(r'^(?P\d{4})/(?P\d{1,2})/?$', WeekScheduleView.as_view()), + url(r'^current_box/?$', cache_page(60)(CurrentShowBoxView.as_view())), + url(r'^hosts/?$', ListView.as_view(context_object_name='host_list', queryset=hosts, template_name='host_list.html')), + url(r'^hosts/(?P\d+)/?$', DetailView.as_view(context_object_name='host', queryset=hosts, template_name='host_detail.html'), name='host-detail'), + url(r'^tips/?$', RecommendationsListView.as_view()), + url(r'^tips_box/?$', RecommendationsBoxView.as_view()), + url(r'^shows/?$', ShowListView.as_view(context_object_name='show_list', queryset=shows, template_name='show_list.html')), + url(r'^shows/(?P[\w-]+)/?$', DetailView.as_view(queryset=shows, template_name='show_detail.html'), name='show-detail'), + url(r'^(?P\d+)/?$', DetailView.as_view(queryset=timeslots, template_name='timeslot_detail.html'), name='timeslot-detail'), + url(r'^styles.css$', StylesView.as_view()) + ) if settings.DEBUG: urlpatterns += patterns('', url(r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': PROGRAM_SITE_MEDIA})) diff --git a/program/views.py b/program/views.py index cba3a25..7e70175 100644 --- a/program/views.py +++ b/program/views.py @@ -1,115 +1,149 @@ -from datetime import date, datetime, time, timedelta import json +from datetime import date, datetime, time, timedelta -from django.views.generic.base import TemplateView -from django.views.generic.detail import DetailView -from django.views.generic.list import ListView -from django.shortcuts import get_object_or_404 from django.db.models import Q from django.http import HttpResponse +from django.shortcuts import get_object_or_404 +from django.views.generic.base import TemplateView +from django.views.generic.list import ListView -from models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, ShowTopic, TimeSlot, Host - - -def host_list(request): - queryset = Host.objects.filter(Q(shows__programslots__until__gte=date.today()) | - Q(always_visible=True)).distinct() - - return ListView.as_view(request, queryset=queryset, template_name='host_list.html') - - -def host_detail(request): - queryset = Host.objects.filter(Q(shows__programslots__until__gte=date.today()) | - Q(always_visible=True)).distinct() - - return DetailView.as_view(request, queryset=queryset, template_name='host_detail.html') - - -def show_list(request): - queryset = Show.objects.filter(programslots__until__gt=date.today()).exclude(id=1).distinct() - - if 'broadcastformat' in request.GET: - broadcastformat = get_object_or_404(BroadcastFormat, slug=request.GET['broadcastformat']) - queryset = queryset.filter(broadcastformat=broadcastformat) - elif 'musicfocus' in request.GET: - musicfocus = get_object_or_404(MusicFocus, slug=request.GET['musicfocus']) - queryset = queryset.filter(musicfocus=musicfocus) - elif 'showinformation' in request.GET: - showinformation = get_object_or_404(ShowInformation, slug=request.GET['showinformation']) - queryset = queryset.filter(showinformation=showinformation) - elif 'showtopic' in request.GET: - showtopic = get_object_or_404(ShowTopic, slug=request.GET['showtopic']) - queryset = queryset.filter(showtopic=showtopic) - - return ListView.as_view(request, queryset=queryset, template_object_name='show', template_name='show_list.html') - +from models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, ShowTopic, TimeSlot +from program.utils import tofirstdayinisoweek -def show_detail(request): - queryset = Show.objects.filter(programslots__until__gt=date.today()).exclude(id=1).distinct() - return DetailView.as_view(request, queryset=queryset, template_name='show_detail.html',) +class ShowListView(ListView): + def get_queryset(self): + queryset = Show.objects.filter(programslots__until__gt=date.today()).exclude(id=1).distinct() + if 'broadcastformat' in self.request.GET: + broadcastformat = get_object_or_404(BroadcastFormat, slug=self.request.GET['broadcastformat']) + queryset = queryset.filter(broadcastformat=broadcastformat) + elif 'musicfocus' in self.request.GET: + musicfocus = get_object_or_404(MusicFocus, slug=self.request.GET['musicfocus']) + queryset = queryset.filter(musicfocus=musicfocus) + elif 'showinformation' in self.request.GET: + showinformation = get_object_or_404(ShowInformation, slug=self.request.GET['showinformation']) + queryset = queryset.filter(showinformation=showinformation) + elif 'showtopic' in self.request.GET: + showtopic = get_object_or_404(ShowTopic, slug=self.request.GET['showtopic']) + queryset = queryset.filter(showtopic=showtopic) -def timeslot_detail(request): - queryset = TimeSlot.objects.all() + return queryset - return DetailView.as_view(request, queryset=queryset, template_name='timeslot_detail.html') +class RecommendationsListView(ListView): + context_object_name = 'recommendation_list' + template_name = 'recommendation_list.html' -def recommendations(request, template_name='recommendations.html'): now = datetime.now() end = now + timedelta(weeks=1) queryset = TimeSlot.objects.filter(Q(note__isnull=False, note__status=1, start__range=(now, end)) | Q(show__broadcastformat__slug='sondersendung', start__range=(now, end))).order_by('start')[:20] - return DetailView.as_view(request, queryset=queryset, template_name=template_name, template_object_name='recommendation') - - -def day_schedule(request, year=None, month=None, day=None): - if year is None and month is None and day is None: - today = datetime.combine(date.today(), time(6, 0)) - else: - today = datetime.strptime('%s__%s__%s__06__00' % (year, month, day), '%Y__%m__%d__%H__%M') - tomorrow = today + timedelta(days=1) +class RecommendationsBoxView(RecommendationsListView): + template_name='boxes/recommendation.html' - recommendations = Note.objects.filter(status=1, timeslot__start__range=(today, tomorrow)) - - default_show = Show.objects.get(pk=1) - - extra_context = dict(day=today, recommendations=recommendations, default_show=default_show) - - timeslots = TimeSlot.objects.get_day_timeslots(today) - - if 'broadcastformat' in request.GET: - broadcastformat = get_object_or_404(BroadcastFormat, slug=request.GET['broadcastformat']) - extra_context['timeslots'] = timeslots.filter(show__broadcastformat=broadcastformat) - elif 'musicfocus' in request.GET: - musicfocus = get_object_or_404(MusicFocus, slug=request.GET['musicfocus']) - extra_context['timeslots'] = timeslots.filter(show__musicfocus=musicfocus) - elif 'showinformation' in request.GET: - showinformation = get_object_or_404(ShowInformation, slug=request.GET['showinformation']) - extra_context['timeslots'] = timeslots.filter(show__showinformation=showinformation) - elif 'showtopic' in request.GET: - showtopic = get_object_or_404(ShowTopic, slug=request.GET['showtopic']) - extra_context['showtopic'] = timeslots.filter(show__showtopic=showtopic) - else: - extra_context['timeslots'] = timeslots - return TemplateView.as_view(request, extra_context=extra_context, template='day_schedule.html') +class DayScheduleView(TemplateView): + template_name = 'day_schedule.html' + def get_context_data(self, **kwargs): + year = self.kwargs.get('year', None) + month = self.kwargs.get('month', None) + day = self.kwargs.get('day', None) -def current_show(request): - current = TimeSlot.objects.get_or_create_current() - previous = current.get_previous_by_start() - next = current.get_next_by_start() - after_next = next.get_next_by_start() - - extra_context = dict(current=current, previous=previous, next=next, after_next=after_next) - - return TemplateView.as_view(request, template='boxes/current.html', extra_context=extra_context) - + if year is None and month is None and day is None: + today = datetime.combine(date.today(), time(6, 0)) + else: + today = datetime.strptime('%s__%s__%s__06__00' % (year, month, day), '%Y__%m__%d__%H__%M') + + tomorrow = today + timedelta(days=1) + + context = super(DayScheduleView, self).get_context_data(**kwargs) + context['day'] = today + context['recommendations'] = Note.objects.filter(status=1, timeslot__start__range=(today, tomorrow)) + context['default_show'] = Show.objects.get(pk=1) + + timeslots = TimeSlot.objects.get_day_timeslots(today) + + if 'broadcastformat' in self.request.GET: + broadcastformat = get_object_or_404(BroadcastFormat, slug=self.request.GET['broadcastformat']) + context['timeslots'] = timeslots.filter(show__broadcastformat=broadcastformat) + elif 'musicfocus' in self.request.GET: + musicfocus = get_object_or_404(MusicFocus, slug=self.request.GET['musicfocus']) + context['timeslots'] = timeslots.filter(show__musicfocus=musicfocus) + elif 'showinformation' in self.request.GET: + showinformation = get_object_or_404(ShowInformation, slug=self.request.GET['showinformation']) + context['timeslots'] = timeslots.filter(show__showinformation=showinformation) + elif 'showtopic' in self.request.GET: + showtopic = get_object_or_404(ShowTopic, slug=self.request.GET['showtopic']) + context['showtopic'] = timeslots.filter(show__showtopic=showtopic) + else: + context['timeslots'] = timeslots + return context + + +class CurrentShowBoxView(TemplateView): + context_object_name = 'recommendation_list' + template_name = 'boxes/current.html' + + def get_context_data(self, **kwargs): + current_timeslot = TimeSlot.objects.get_or_create_current() + previuos_timeslot = current_timeslot.get_previous_by_start() + next_timeslot = current_timeslot.get_next_by_start() + after_next_timeslot = next_timeslot.get_next_by_start() + + context = super(CurrentShowBoxView, self).get_context_data(**kwargs) + context['current_timeslot'] = current_timeslot + context['previuos_timeslot'] = previuos_timeslot + context['next_timeslot'] = next_timeslot + context['after_next_timeslot'] = after_next_timeslot + return context + + +class WeekScheduleView(TemplateView): + template_name = 'week_schedule.html' + + def get_context_data(self, **kwargs): + year = self.kwargs.get('year', None) + week = self.kwargs.get('week', None) + + if year is None and week is None: + year, week = datetime.now().strftime('%G__%V').split('__') + + monday = tofirstdayinisoweek(int(year), int(week)) + tuesday = monday + timedelta(days=1) + wednesday = monday + timedelta(days=2) + thursday = monday + timedelta(days=3) + friday = monday + timedelta(days=4) + saturday = monday + timedelta(days=5) + sunday = monday + timedelta(days=6) + + context = super(WeekScheduleView, self).get_context_data() + context['monday'] = monday + context['tuesday'] = tuesday + context['wednesday'] = wednesday + context['thursday'] = thursday + context['friday'] = friday + context['saturday'] = saturday + context['sunday'] = sunday + context['default_show'] = Show.objects.get(pk=1) + context['monday_timeslots'] = TimeSlot.objects.get_day_timeslots(monday) + context['tuesday_timeslots'] = TimeSlot.objects.get_day_timeslots(tuesday) + context['wednesday_timeslots'] = TimeSlot.objects.get_day_timeslots(wednesday) + context['thursday_timeslots'] = TimeSlot.objects.get_day_timeslots(thursday) + context['friday_timeslots'] = TimeSlot.objects.get_day_timeslots(friday) + context['saturday_timeslots'] = TimeSlot.objects.get_day_timeslots(saturday) + context['sunday_timeslots'] = TimeSlot.objects.get_day_timeslots(sunday) + context['last_w'] = datetime.strftime(monday - timedelta(days=7), '%G/%V') + context['cur_w'] = datetime.strftime(monday, '%G/%V') + context['next_w1'] = datetime.strftime(monday + timedelta(days=7), '%G/%V') + context['next_w2'] = datetime.strftime(monday + timedelta(days=14), '%G/%V') + context['next_w3'] = datetime.strftime(monday + timedelta(days=21), '%G/%V') + context['next_w4'] = datetime.strftime(monday + timedelta(days=28), '%G/%V') + return context def week_schedule(request, year=None, week=None): if year is None and week is None: @@ -143,17 +177,21 @@ def week_schedule(request, year=None, week=None): extra_context['next_w3'] = datetime.strftime(monday + timedelta(days=21), '%G/%V') extra_context['next_w4'] = datetime.strftime(monday + timedelta(days=28), '%G/%V') - return TemplateView.as_view(request, template='week_schedule.html', extra_context=extra_context) + return TemplateView.as_view(template='week_schedule.html', extra_context=extra_context)(request) + -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() +class StylesView(TemplateView): + template_name = 'styles.css' + content_type = 'text/css' - return TemplateView.as_view(request, template='styles.css', mimetype='text/css', extra_context=extra_context) + def get_context_data(self, **kwargs): + context = super(StylesView, self).get_context_data(**kwargs) + context['broadcastformats'] = BroadcastFormat.objects.filter(enabled=True) + context['musicfocus'] = MusicFocus.objects.all() + context['showinformation'] = ShowInformation.objects.all() + context['showtopic'] = ShowTopic.objects.all() + return context def json_day_schedule(request, year=None, month=None, day=None): @@ -173,11 +211,3 @@ def json_day_schedule(request, year=None, month=None, day=None): schedule.append((ts.start.strftime('%H:%M:%S'), ts.programslot.show.name, -1)) return HttpResponse(json.dumps(schedule, ensure_ascii=False, encoding='utf8').encode('utf8'), content_type="application/json; charset=utf-8") - - -def tofirstdayinisoweek(year, week): - # http://stackoverflow.com/questions/5882405/get-date-from-iso-week-number-in-python - ret = datetime.strptime('%04d-%02d-1' % (year, week), '%Y-%W-%w') - if date(year, 1, 4).isoweekday() > 4: - ret -= timedelta(days=7) - return ret -- cgit v0.10.2 From a93a112e11aeeaa2aa7913318617f8c1ce97be32 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 20:13:06 +0100 Subject: cleaned-up URLs diff --git a/program/urls.py b/program/urls.py index 49d0488..c125de3 100644 --- a/program/urls.py +++ b/program/urls.py @@ -9,19 +9,12 @@ from views import ShowListView, CurrentShowBoxView, RecommendationsListView, Rec from models import Host, Show, TimeSlot import os -from datetime import date, datetime, timedelta PROGRAM_SITE_MEDIA = os.path.join(os.path.dirname(__file__), '../site_media') -now = datetime.now() -end = now + timedelta(weeks=1) - -hosts = Host.objects.filter(Q(shows__programslots__until__gte=date.today()) | - Q(always_visible=True)).distinct() -shows = Show.objects.filter(programslots__until__gt=date.today()).exclude(id=1).distinct() +hosts = Host.objects.filter(Q(is_active=True) | Q(always_visible=True)).distinct() +shows = Show.objects.filter(is_active=True).exclude(id=1).distinct() timeslots = TimeSlot.objects.all() -recommendations = TimeSlot.objects.filter(Q(note__isnull=False, note__status=1, start__range=(now, end)) | - Q(show__broadcastformat__slug='sondersendung', start__range=(now, end))).order_by('start')[:20] urlpatterns = patterns('', url(r'^today/?$', DayScheduleView.as_view()), -- cgit v0.10.2 From 3501d7b838cd08b7e87029d9fb155fd1193ab2c1 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 20:13:33 +0100 Subject: clened-up URLs diff --git a/pv/urls.py b/pv/urls.py index b4f72ce..ec1cdff 100644 --- a/pv/urls.py +++ b/pv/urls.py @@ -7,10 +7,10 @@ admin.autodiscover() from program.views import json_day_schedule urlpatterns = patterns('', - (r'^admin/', include(admin.site.urls)), - (r'^program/', include('program.urls')), - (r'^nop', include('nop.urls')), - (r'^tinymce/', include('tinymce.urls')), + url(r'^admin/', include(admin.site.urls)), + url(r'^program/', include('program.urls')), + url(r'^nop', include('nop.urls')), + url(r'^tinymce/', include('tinymce.urls')), url(r'^export/day_schedule/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/$', json_day_schedule) ) -- cgit v0.10.2 From 2daad5da6dd2315d826dc30018c7abd42f94ccfc Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 20:13:54 +0100 Subject: updated to Django 1.8.8 diff --git a/requirements.txt b/requirements.txt index 3d00d3a..22470f4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Django==1.8.7 +Django==1.8.8 MySQL-python==1.2.5 Pillow==3.0.0 PyYAML==3.11 -- cgit v0.10.2 From efffafdc2843118ad810062b568593c0b1dda662 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 20:16:02 +0100 Subject: removed old week_schedule view diff --git a/program/views.py b/program/views.py index 7e70175..b642423 100644 --- a/program/views.py +++ b/program/views.py @@ -145,41 +145,6 @@ class WeekScheduleView(TemplateView): context['next_w4'] = datetime.strftime(monday + timedelta(days=28), '%G/%V') return context -def week_schedule(request, year=None, week=None): - if year is None and week is None: - year, week = datetime.now().strftime('%G__%V').split('__') - - monday = tofirstdayinisoweek(int(year), int(week)) - tuesday = monday + timedelta(days=1) - wednesday = monday + timedelta(days=2) - thursday = monday + timedelta(days=3) - friday = monday + timedelta(days=4) - saturday = monday + timedelta(days=5) - sunday = monday + timedelta(days=6) - - default_show = Show.objects.get(pk=1) - - extra_context = dict(monday=monday, tuesday=tuesday, wednesday=wednesday, thursday=thursday, friday=friday, - saturday=saturday, sunday=sunday, default_show=default_show) - - extra_context['monday_timeslots'] = TimeSlot.objects.get_day_timeslots(monday) - extra_context['tuesday_timeslots'] = TimeSlot.objects.get_day_timeslots(tuesday) - extra_context['wednesday_timeslots'] = TimeSlot.objects.get_day_timeslots(wednesday) - extra_context['thursday_timeslots'] = TimeSlot.objects.get_day_timeslots(thursday) - extra_context['friday_timeslots'] = TimeSlot.objects.get_day_timeslots(friday) - extra_context['saturday_timeslots'] = TimeSlot.objects.get_day_timeslots(saturday) - extra_context['sunday_timeslots'] = TimeSlot.objects.get_day_timeslots(sunday) - - extra_context['last_w'] = datetime.strftime(monday - timedelta(days=7), '%G/%V') - extra_context['cur_w'] = datetime.strftime(monday, '%G/%V') - extra_context['next_w1'] = datetime.strftime(monday + timedelta(days=7), '%G/%V') - extra_context['next_w2'] = datetime.strftime(monday + timedelta(days=14), '%G/%V') - extra_context['next_w3'] = datetime.strftime(monday + timedelta(days=21), '%G/%V') - extra_context['next_w4'] = datetime.strftime(monday + timedelta(days=28), '%G/%V') - - return TemplateView.as_view(template='week_schedule.html', extra_context=extra_context)(request) - - class StylesView(TemplateView): template_name = 'styles.css' -- cgit v0.10.2 From 3fa080dec496c07fa7d2a8f86d75e66c7c9be6f2 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 20:48:56 +0100 Subject: fixed commands diff --git a/program/management/commands/update_hosts.py b/program/management/commands/update_hosts.py index 22e0596..e19d8ed 100644 --- a/program/management/commands/update_hosts.py +++ b/program/management/commands/update_hosts.py @@ -9,13 +9,13 @@ class Command(NoArgsCommand): def handle_noargs(self, **options): for host in Host.objects.all(): for show in host.shows.all(): - hosts_active_show = None - if show.has_active_programslots: - hosts_active_show = True + is_active = None + if show.is_active: + is_active = True else: - hosts_active_show = False + is_active = False - host.hosts_active_show = hosts_active_show + host.is_active = is_active - if not hosts_active_show: + if not is_active: host.save() diff --git a/program/management/commands/update_shows.py b/program/management/commands/update_shows.py index d582bb5..805c51e 100644 --- a/program/management/commands/update_shows.py +++ b/program/management/commands/update_shows.py @@ -10,13 +10,13 @@ class Command(NoArgsCommand): def handle_noargs(self, **options): for show in Show.objects.exclude(pk=1): - has_active_programslots = None + is_active = None for programslot in show.programslots.all(): if programslot.until > date.today(): - has_active_programslots = True + is_active = True else: - has_active_programslots = False - show.has_active_programslots = has_active_programslots + is_active = False + show.is_active = is_active - if not has_active_programslots: + if not is_active: show.save() -- cgit v0.10.2 From 1d44cd892ad9c3f0b02a4fe883c6e7cd92abe8e5 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 20:49:23 +0100 Subject: moved views diff --git a/program/urls.py b/program/urls.py index c125de3..18625a4 100644 --- a/program/urls.py +++ b/program/urls.py @@ -1,35 +1,28 @@ from django.conf import settings from django.conf.urls import patterns, url -from django.db.models import Q from django.views.decorators.cache import cache_page -from django.views.generic.detail import DetailView -from django.views.generic.list import ListView -from views import ShowListView, CurrentShowBoxView, RecommendationsListView, RecommendationsBoxView, DayScheduleView, StylesView, WeekScheduleView -from models import Host, Show, TimeSlot +import views import os PROGRAM_SITE_MEDIA = os.path.join(os.path.dirname(__file__), '../site_media') -hosts = Host.objects.filter(Q(is_active=True) | Q(always_visible=True)).distinct() -shows = Show.objects.filter(is_active=True).exclude(id=1).distinct() -timeslots = TimeSlot.objects.all() urlpatterns = patterns('', - url(r'^today/?$', DayScheduleView.as_view()), - url(r'^week/?$', WeekScheduleView.as_view()), - url(r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/?$', DayScheduleView.as_view()), - url(r'^(?P\d{4})/(?P\d{1,2})/?$', WeekScheduleView.as_view()), - url(r'^current_box/?$', cache_page(60)(CurrentShowBoxView.as_view())), - url(r'^hosts/?$', ListView.as_view(context_object_name='host_list', queryset=hosts, template_name='host_list.html')), - url(r'^hosts/(?P\d+)/?$', DetailView.as_view(context_object_name='host', queryset=hosts, template_name='host_detail.html'), name='host-detail'), - url(r'^tips/?$', RecommendationsListView.as_view()), - url(r'^tips_box/?$', RecommendationsBoxView.as_view()), - url(r'^shows/?$', ShowListView.as_view(context_object_name='show_list', queryset=shows, template_name='show_list.html')), - url(r'^shows/(?P[\w-]+)/?$', DetailView.as_view(queryset=shows, template_name='show_detail.html'), name='show-detail'), - url(r'^(?P\d+)/?$', DetailView.as_view(queryset=timeslots, template_name='timeslot_detail.html'), name='timeslot-detail'), - url(r'^styles.css$', StylesView.as_view()) + url(r'^today/?$', views.DayScheduleView.as_view()), + url(r'^week/?$', views.WeekScheduleView.as_view()), + url(r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/?$', views.DayScheduleView.as_view()), + url(r'^(?P\d{4})/(?P\d{1,2})/?$', views.WeekScheduleView.as_view()), + url(r'^current_box/?$', cache_page(60)(views.CurrentShowBoxView.as_view())), + url(r'^hosts/?$', views.HostListView.as_view()), + url(r'^hosts/(?P\d+)/?$', views.HostDetailView.as_view(), name='host-detail'), + url(r'^tips/?$', views.RecommendationsListView.as_view()), + url(r'^tips_box/?$', views.RecommendationsBoxView.as_view()), + url(r'^shows/?$', views.ShowListView.as_view()), + url(r'^shows/(?P[\w-]+)/?$', views.ShowDetailView.as_view(), name='show-detail'), + url(r'^(?P\d+)/?$', views.TimeSlotDetailView.as_view(), name='timeslot-detail'), + url(r'^styles.css$', views.StylesView.as_view()) ) if settings.DEBUG: urlpatterns += patterns('', diff --git a/program/views.py b/program/views.py index b642423..dcfaca9 100644 --- a/program/views.py +++ b/program/views.py @@ -5,13 +5,31 @@ from django.db.models import Q from django.http import HttpResponse from django.shortcuts import get_object_or_404 from django.views.generic.base import TemplateView +from django.views.generic.detail import DetailView from django.views.generic.list import ListView -from models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, ShowTopic, TimeSlot +from models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, ShowTopic, TimeSlot, Host + from program.utils import tofirstdayinisoweek +class HostListView(ListView): + context_object_name = 'host_list' + queryset = Host.objects.filter(Q(is_active=True) | Q(always_visible=True)).distinct() + template_name = 'host_list.html' + + +class HostDetailView(DetailView): + context_object_name = 'host' + queryset = Host.objects.filter(Q(is_active=True) | Q(always_visible=True)).distinct() + template_name = 'host_detail.html' + + class ShowListView(ListView): + context_object_name = 'show_list' + queryset = Show.objects.filter(is_active=True).exclude(id=1).distinct() + template_name = 'show_list.html' + def get_queryset(self): queryset = Show.objects.filter(programslots__until__gt=date.today()).exclude(id=1).distinct() @@ -31,6 +49,15 @@ class ShowListView(ListView): return queryset +class ShowDetailView(DetailView): + queryset = Show.objects.filter(is_active=True).exclude(id=1).distinct() + template_name = 'show_detail.html' + +class TimeSlotDetailView(DetailView): + queryset = TimeSlot.objects.all() + template_name = 'timeslot_detail.html' + + class RecommendationsListView(ListView): context_object_name = 'recommendation_list' template_name = 'recommendation_list.html' @@ -43,7 +70,7 @@ class RecommendationsListView(ListView): class RecommendationsBoxView(RecommendationsListView): - template_name='boxes/recommendation.html' + template_name = 'boxes/recommendation.html' class DayScheduleView(TemplateView): -- cgit v0.10.2 From 10d92b42bd5bb174e37076a83d4af047e733155c Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 21:17:27 +0100 Subject: fixed warnings diff --git a/pv/settings.py b/pv/settings.py index d966f2c..5d23ab9 100644 --- a/pv/settings.py +++ b/pv/settings.py @@ -5,7 +5,6 @@ import os.path PROJECT_DIR = os.path.dirname(__file__) DEBUG = True -TEMPLATE_DEBUG = DEBUG ADMINS = () @@ -47,7 +46,7 @@ TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ - 'templates' + os.path.join(PROJECT_DIR, 'templates') ], 'APP_DIRS': True, 'OPTIONS': { @@ -74,10 +73,6 @@ MIDDLEWARE_CLASSES = ( ROOT_URLCONF = 'pv.urls' -TEMPLATE_DIRS = ( - os.path.join(PROJECT_DIR, "templates"), -) - INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', -- cgit v0.10.2 From 7abeccf4a01c3340610e9c92b7ecfdb4e00a2171 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Jan 2016 21:17:43 +0100 Subject: fixed command diff --git a/program/management/commands/update_hosts.py b/program/management/commands/update_hosts.py index e19d8ed..64619cd 100644 --- a/program/management/commands/update_hosts.py +++ b/program/management/commands/update_hosts.py @@ -8,14 +8,14 @@ class Command(NoArgsCommand): def handle_noargs(self, **options): for host in Host.objects.all(): + is_active = None for show in host.shows.all(): - is_active = None if show.is_active: is_active = True else: is_active = False - host.is_active = is_active + host.is_active = is_active - if not is_active: - host.save() + if not is_active: + host.save() -- cgit v0.10.2 From 4653abe588ab43fa77482a112dcd1c0f887caaa1 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Thu, 7 Jan 2016 09:20:53 +0100 Subject: updated german localization messages diff --git a/locale/DE/LC_MESSAGES/django.po b/locale/DE/LC_MESSAGES/django.po index 509f0c1..1838efe 100644 --- a/locale/DE/LC_MESSAGES/django.po +++ b/locale/DE/LC_MESSAGES/django.po @@ -1,16 +1,16 @@ # Radio Helsinki program/schedule management # Copyright (C) 2011, Ernesto Rico-Schmidt # This file is distributed under the same license as the helsinki package. -# Ernesto Rico-Schmidt , 2011. +# Ernesto Rico-Schmidt , 2011-2016. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: helsinki-program\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-01 20:24+0200\n" +"POT-Creation-Date: 2016-01-07 09:10+0100\n" "PO-Revision-Date: 2011-06-02 22:25+0200\n" -"Last-Translator: Ernesto Rico-Schmidt \n" +"Last-Translator: Ernesto Rico-Schmidt \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" @@ -18,24 +18,34 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -#: program/admin.py:64 -msgid "Renew selected time slots" +#: program/admin.py:77 +#, python-format +msgid "1 program slot was renewed until %s" +msgstr "eine Sendezeit wurde verlängert bis %s" + +#: program/admin.py:79 +#, python-format +msgid "%s program slots were renewed until %s" +msgstr "%s Sendezeiten wurden verlängert bis %s" + +#: program/admin.py:81 +msgid "Renew selected program slots" msgstr "Ausgewählte Sendezeiten verlängern" -#: program/models.py:17 +#: program/models.py:18 msgid "Format" msgstr "Format" -#: program/models.py:18 program/models.py:43 program/models.py:103 -#: program/models.py:163 program/models.py:260 +#: program/models.py:19 program/models.py:43 program/models.py:100 +#: program/models.py:157 program/models.py:239 msgid "Slug" msgstr "Slug" -#: program/models.py:19 program/models.py:33 +#: program/models.py:20 program/models.py:33 msgid "Color" msgstr "Farbe" -#: program/models.py:20 +#: program/models.py:21 msgid "Text color" msgstr "Textfarbe" @@ -43,7 +53,7 @@ msgstr "Textfarbe" msgid "Enabled" msgstr "Aktiviert" -#: program/models.py:26 program/models.py:249 +#: program/models.py:26 program/models.py:234 msgid "Broadcast format" msgstr "Sendungsformat" @@ -55,275 +65,274 @@ msgstr "Sendungsformate" msgid "Information" msgstr "Zusatzinformation" -#: program/models.py:42 program/models.py:102 program/models.py:162 +#: program/models.py:42 program/models.py:99 program/models.py:156 msgid "Abbreviation" msgstr "Abkürzung" -#: program/models.py:44 program/models.py:104 program/models.py:164 +#: program/models.py:44 program/models.py:101 program/models.py:158 msgid "Button image" msgstr "Bild-Button" -#: program/models.py:46 program/models.py:106 program/models.py:166 +#: program/models.py:45 program/models.py:102 program/models.py:159 msgid "Button image (hover)" msgstr "Bild-Button (hover)" -#: program/models.py:48 program/models.py:108 program/models.py:168 +#: program/models.py:46 program/models.py:103 program/models.py:160 msgid "Big button image" msgstr "Bild-Button groß" -#: program/models.py:53 program/models.py:54 program/models.py:252 +#: program/models.py:50 program/models.py:51 program/models.py:235 msgid "Show information" msgstr "Zusatzinformation" -#: program/models.py:75 program/models.py:135 program/models.py:195 +#: program/models.py:72 program/models.py:129 program/models.py:186 msgid "Buttons" msgstr "Buttonts" -#: program/models.py:101 program/models.py:113 program/models.py:255 +#: program/models.py:98 program/models.py:107 program/models.py:236 msgid "Show topic" msgstr "Thema/Schwerpunkt" -#: program/models.py:114 +#: program/models.py:108 msgid "Show topics" msgstr "Themen/Schwerpunkte" -#: program/models.py:161 +#: program/models.py:155 msgid "Focus" msgstr "Tendenz" -#: program/models.py:173 program/models.py:174 program/models.py:258 +#: program/models.py:164 program/models.py:165 program/models.py:237 msgid "Music focus" msgstr "Musiktendenz" -#: program/models.py:221 program/models.py:259 program/models.py:310 +#: program/models.py:212 program/models.py:238 program/models.py:278 msgid "Name" msgstr "Name" -#: program/models.py:222 program/models.py:267 +#: program/models.py:213 +msgid "Always visible" +msgstr "Immer sichtbar" + +#: program/models.py:214 program/models.py:246 program/models.py:311 +msgid "Is active" +msgstr "Is aktiv" + +#: program/models.py:215 program/models.py:244 msgid "E-Mail" msgstr "E-Mail" -#: program/models.py:223 program/models.py:268 +#: program/models.py:216 program/models.py:245 msgid "Website" msgstr "Website" -#: program/models.py:227 +#: program/models.py:220 msgid "Host" msgstr "Sendungsmacher" -#: program/models.py:228 program/models.py:244 +#: program/models.py:221 program/models.py:232 msgid "Hosts" msgstr "Sendungsmacher" -#: program/models.py:241 +#: program/models.py:231 msgid "Predecessor" msgstr "Vorgänger" -#: program/models.py:247 +#: program/models.py:233 msgid "Owners" msgstr "Eingentümer" -#: program/models.py:261 +#: program/models.py:240 msgid "Image" msgstr "Bild" -#: program/models.py:263 -#, fuzzy +#: program/models.py:241 msgid "show Image" msgstr "Zeige Bild" -#: program/models.py:264 +#: program/models.py:242 msgid "Short description" msgstr "Kurzbeschreibung" -#: program/models.py:265 +#: program/models.py:243 msgid "Description" msgstr "Beschreibung" -#: program/models.py:269 +#: program/models.py:247 msgid "CBA series ID" msgstr "ID der Sendereihe auf CBA" -#: program/models.py:271 program/models.py:346 +#: program/models.py:248 program/models.py:313 msgid "Automation ID" msgstr "ID in der Automatiserung" -#: program/models.py:279 program/models.py:340 +#: program/models.py:254 program/models.py:306 msgid "Show" msgstr "Sendung" -#: program/models.py:280 +#: program/models.py:255 msgid "Shows" msgstr "Sendungen" -#: program/models.py:293 -msgid "Has active program slots" -msgstr "Hat aktive Sendezeiten" - -#: program/models.py:298 +#: program/models.py:266 msgid "Monthly" msgstr "monatlich" -#: program/models.py:299 +#: program/models.py:267 msgid "Weekly" msgstr "wöchentlich" -#: program/models.py:300 +#: program/models.py:268 msgid "Daily" msgstr "täglich" -#: program/models.py:303 +#: program/models.py:271 msgid "First" msgstr "Erster" -#: program/models.py:304 +#: program/models.py:272 msgid "Second" msgstr "Zweiter" -#: program/models.py:305 +#: program/models.py:273 msgid "Third" msgstr "Dritter" -#: program/models.py:306 +#: program/models.py:274 msgid "Fourth" msgstr "Vierter" -#: program/models.py:307 +#: program/models.py:275 msgid "Fifth" msgstr "Fünfter" -#: program/models.py:308 +#: program/models.py:276 msgid "Last" msgstr "Letzter" -#: program/models.py:311 +#: program/models.py:279 msgid "Frequency" msgstr "Häufigkeit" -#: program/models.py:312 +#: program/models.py:280 msgid "Interval" msgstr "Intervall" -#: program/models.py:313 +#: program/models.py:281 msgid "Set position" msgstr "Position" -#: program/models.py:315 +#: program/models.py:283 msgid "Count" msgstr "Zähler" -#: program/models.py:319 program/models.py:337 +#: program/models.py:287 program/models.py:304 msgid "Recurrence rule" msgstr "Wiederholungsregel" -#: program/models.py:320 +#: program/models.py:288 msgid "Recurrence rules" msgstr "Wiederholungsregel" -#: program/models.py:328 +#: program/models.py:296 msgid "Monday" msgstr "Montag" -#: program/models.py:329 +#: program/models.py:297 msgid "Tuesday" msgstr "Dienstag" -#: program/models.py:330 +#: program/models.py:298 msgid "Wednesday" msgstr "Mittwoch" -#: program/models.py:331 +#: program/models.py:299 msgid "Thursday" msgstr "Donnerstag" -#: program/models.py:332 +#: program/models.py:300 msgid "Friday" msgstr "Freitag" -#: program/models.py:333 +#: program/models.py:301 msgid "Saturday" msgstr "Samstag" -#: program/models.py:334 +#: program/models.py:302 msgid "Sunday" msgstr "Sonntag" -#: program/models.py:338 +#: program/models.py:305 msgid "Weekday" msgstr "Wochentag" -#: program/models.py:341 +#: program/models.py:307 msgid "First date" msgstr "Erstes Datum" -#: program/models.py:342 program/models.py:501 +#: program/models.py:308 program/models.py:451 msgid "Start time" msgstr "Beginnzeit" -#: program/models.py:343 program/models.py:502 +#: program/models.py:309 program/models.py:452 msgid "End time" msgstr "Endzeit" -#: program/models.py:344 +#: program/models.py:310 msgid "Last date" msgstr "Letztes Datum" -#: program/models.py:345 +#: program/models.py:312 msgid "Is repetition" msgstr "Is Wiederholung" -#: program/models.py:355 program/models.py:500 +#: program/models.py:320 program/models.py:450 msgid "Program slot" msgstr "Sendezeit" -#: program/models.py:356 +#: program/models.py:321 msgid "Program slots" msgstr "Sendezeiten" -#: program/models.py:437 -msgid "Time slot count" -msgstr "Zeitschlitze" - -#: program/models.py:509 program/models.py:533 +#: program/models.py:459 program/models.py:482 msgid "Time slot" msgstr "Zeitschlitz" -#: program/models.py:510 +#: program/models.py:460 msgid "Time slots" msgstr "Zeitschlitze" -#: program/models.py:529 +#: program/models.py:478 msgid "Cancellation" msgstr "Ausfall" -#: program/models.py:530 +#: program/models.py:479 msgid "Recommendation" msgstr "Empfehlung" -#: program/models.py:531 +#: program/models.py:480 msgid "Repetition" msgstr "Wiederholung" -#: program/models.py:534 +#: program/models.py:483 msgid "Title" msgstr "Titel" -#: program/models.py:535 +#: program/models.py:484 msgid "Content" msgstr "Inhalt" -#: program/models.py:536 +#: program/models.py:485 msgid "Status" msgstr "Status" -#: program/models.py:538 +#: program/models.py:486 msgid "CBA entry ID" msgstr "ID des Beitrags auf der CBA" -#: program/models.py:547 +#: program/models.py:494 msgid "Note" msgstr "Notiz" -#: program/models.py:548 +#: program/models.py:495 msgid "Notes" msgstr "Notizen" -- cgit v0.10.2 From c8ae3f3e402ca38e2d755061125ab570aef842cb Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Fri, 12 Feb 2016 19:45:47 +0100 Subject: added is_ diff --git a/program/models.py b/program/models.py index 11ec7f1..db82377 100644 --- a/program/models.py +++ b/program/models.py @@ -210,7 +210,7 @@ class MusicFocus(models.Model): class Host(models.Model): name = models.CharField(_("Name"), max_length=128) - always_visible = models.BooleanField(_("Always visible"), default=False) + is_always_visible = models.BooleanField(_("Is always visible"), default=False) is_active = models.BooleanField(_("Is active"), default=True, editable=False) email = models.EmailField(_("E-Mail"), blank=True) website = models.URLField(_("Website"), blank=True) diff --git a/program/views.py b/program/views.py index dcfaca9..3248507 100644 --- a/program/views.py +++ b/program/views.py @@ -15,13 +15,13 @@ from program.utils import tofirstdayinisoweek class HostListView(ListView): context_object_name = 'host_list' - queryset = Host.objects.filter(Q(is_active=True) | Q(always_visible=True)).distinct() + queryset = Host.objects.filter(Q(is_active=True) | Q(is_always_visible=True)).distinct() template_name = 'host_list.html' class HostDetailView(DetailView): context_object_name = 'host' - queryset = Host.objects.filter(Q(is_active=True) | Q(always_visible=True)).distinct() + queryset = Host.objects.filter(Q(is_active=True) | Q(is_always_visible=True)).distinct() template_name = 'host_detail.html' -- cgit v0.10.2 From 94af0c6f391fc21f14047a8d649d4d4e8697afea Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 12 Feb 2016 19:58:12 +0100 Subject: added is_ diff --git a/program/admin.py b/program/admin.py index 8a9799c..5faaf4b 100644 --- a/program/admin.py +++ b/program/admin.py @@ -30,7 +30,7 @@ class ShowTopicAdmin(admin.ModelAdmin): class HostAdmin(admin.ModelAdmin): list_display = ('name',) - list_filter = ('always_visible', 'is_active') + list_filter = ('is_always_visible', 'is_active') class NoteAdmin(admin.ModelAdmin): -- cgit v0.10.2 From 6c29ea12d96094cf1b71e6c2f22043bf92d32bcb Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sun, 27 Mar 2016 20:38:29 +0200 Subject: fixed update commands diff --git a/program/management/commands/update_hosts.py b/program/management/commands/update_hosts.py index 64619cd..3cb143b 100644 --- a/program/management/commands/update_hosts.py +++ b/program/management/commands/update_hosts.py @@ -7,15 +7,23 @@ class Command(NoArgsCommand): help = 'update host by setting is_active' def handle_noargs(self, **options): + activated = 0 + deactivated = 0 + for host in Host.objects.all(): - is_active = None + active_shows = 0 for show in host.shows.all(): if show.is_active: - is_active = True + active_shows += 1 else: - is_active = False + active_shows -= 1 + + host.is_active = active_shows > 0 + host.save() - host.is_active = is_active + if host.is_active: + activated += 1 + else: + deactivated += 1 - if not is_active: - host.save() + print "%s hosts activated, %s hosts de-activated " % (activated, deactivated) diff --git a/program/management/commands/update_programslots.py b/program/management/commands/update_programslots.py index 62de064..f0cc59d 100644 --- a/program/management/commands/update_programslots.py +++ b/program/management/commands/update_programslots.py @@ -9,6 +9,16 @@ class Command(NoArgsCommand): help = 'update programslots by setting is_active' def handle_noargs(self, **options): + activated = 0 + deactivated = 0 + for programslot in ProgramSlot.objects.all(): programslot.is_active = programslot.until > date.today() programslot.save() + + if programslot.is_active: + activated += 1 + else: + deactivated += 1 + + print "%s program slots activated, %s program slots de-activated" % (activated, deactivated) diff --git a/program/management/commands/update_shows.py b/program/management/commands/update_shows.py index 805c51e..a337f21 100644 --- a/program/management/commands/update_shows.py +++ b/program/management/commands/update_shows.py @@ -2,21 +2,28 @@ from django.core.management.base import NoArgsCommand from program.models import Show -from datetime import date - class Command(NoArgsCommand): help = 'update shows by setting is_active' def handle_noargs(self, **options): + activated = 0 + deactivated = 0 + for show in Show.objects.exclude(pk=1): - is_active = None for programslot in show.programslots.all(): - if programslot.until > date.today(): - is_active = True + active_programslots = 0 + if programslot.is_active: + active_programslots += 1 else: - is_active = False - show.is_active = is_active + active_programslots -= 1 + + show.is_active = active_programslots > 0 + show.save() + + if show.is_active: + activated += 1 + else: + deactivated += 1 - if not is_active: - show.save() + print "%s shows activated, %s shows de-activated" % (activated, deactivated) -- cgit v0.10.2 From 43fa018afbade0085ffae9734eedd8de75a5fdf9 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sun, 27 Mar 2016 20:56:59 +0200 Subject: fixed templates diff --git a/program/templates/show_detail.html b/program/templates/show_detail.html index 3ab80ed..7993287 100644 --- a/program/templates/show_detail.html +++ b/program/templates/show_detail.html @@ -24,14 +24,14 @@

{{ show.broadcastformat.format }}

- {% for item in show.showinformation.all %} - {{ item.abbrev }} + {% for si in show.showinformation.all %} + {{ si.abbrev }} {% endfor %} - {% for item in show.showtopic.all %} - {{ item.abbrev }} + {% for st in show.showtopic.all %} + {{ st.abbrev }} {% endfor %} - {% for item in show.musicfocus.all %} - {{ item.abbrev }} + {% for mf in show.musicfocus.all %} + {{ mf.abbrev }} {% endfor %}
diff --git a/program/templates/show_list.html b/program/templates/show_list.html index 136930d..62594e9 100644 --- a/program/templates/show_list.html +++ b/program/templates/show_list.html @@ -10,7 +10,7 @@
-
Filter
+
Filter
{% musicfocus %} {% showinformation %} @@ -24,25 +24,25 @@ {% for show in show_list %}
- {% for item in show.showinformation.all %} - {{ item.abbrev }} + {% for si in show.showinformation.all %} + {{ si.abbrev }} {% endfor %} - {% for item in show.showtopic.all %} - {{ item.abbrev }} + {% for st in show.showtopic.all %} + {{ st.abbrev }} {% endfor %} - {% for item in show.musicfocus.all %} - {{ item.abbrev }} + {% for mf in show.musicfocus.all %} + {{ mf.abbrev }} {% endfor %}

{{ show.name }}

    - {% for slot in show.programslots.all %} - {% if slot.has_active_timeslot %} -
  • {{ slot }}
  • + {% for programslot in show.programslots.all %} + {% if programslot.is_active %} +
  • {{ programslot }}
  • {% endif %} {% endfor %}
diff --git a/program/templates/timeslot_detail.html b/program/templates/timeslot_detail.html index c899c32..a3b62af 100644 --- a/program/templates/timeslot_detail.html +++ b/program/templates/timeslot_detail.html @@ -55,7 +55,13 @@ {% endif %}

+ {% load comments %} +
+ {% render_comment_list for timeslot %} + + {% render_comment_form for timeslot %} +
-- cgit v0.10.2 From ad67fdc73e0c25531431a6172b7d7e841ed027ae Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sun, 27 Mar 2016 21:05:51 +0200 Subject: restored blank & null for hosts diff --git a/program/models.py b/program/models.py index db82377..e80385c 100644 --- a/program/models.py +++ b/program/models.py @@ -229,12 +229,12 @@ class Host(models.Model): class Show(models.Model): predecessor = models.ForeignKey('self', blank=True, null=True, related_name='successors', verbose_name=_("Predecessor")) - hosts = models.ManyToManyField(Host, related_name='shows', verbose_name=_("Hosts")) - owners = models.ManyToManyField(User, related_name='shows', verbose_name=_("Owners")) + hosts = models.ManyToManyField(Host, blank=True, null=True, related_name='shows', verbose_name=_("Hosts")) + owners = models.ManyToManyField(User, blank=True, null=True, related_name='shows', verbose_name=_("Owners")) broadcastformat = models.ForeignKey(BroadcastFormat, related_name='shows', verbose_name=_("Broadcast format")) - showinformation = models.ManyToManyField(ShowInformation, related_name='shows', verbose_name=_("Show information")) - showtopic = models.ManyToManyField(ShowTopic, related_name='shows', verbose_name=_("Show topic")) - musicfocus = models.ManyToManyField(MusicFocus, related_name='shows', verbose_name=_("Music focus")) + showinformation = models.ManyToManyField(ShowInformation, blank=True, null=True, related_name='shows', verbose_name=_("Show information")) + showtopic = models.ManyToManyField(ShowTopic, blank=True, null=True, related_name='shows', verbose_name=_("Show topic")) + musicfocus = models.ManyToManyField(MusicFocus, blank=True, null=True, related_name='shows', verbose_name=_("Music focus")) name = models.CharField(_("Name"), max_length=255) slug = models.CharField(_("Slug"), max_length=255, unique=True) image = models.ImageField(_("Image"), blank=True, null=True, upload_to='show_images') -- cgit v0.10.2 From d25c5ff943e2c9124edd9ea32207db94f721798a Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Tue, 29 Mar 2016 15:31:31 +0200 Subject: fixed warning 340 diff --git a/program/models.py b/program/models.py index e80385c..d755248 100644 --- a/program/models.py +++ b/program/models.py @@ -229,12 +229,12 @@ class Host(models.Model): class Show(models.Model): predecessor = models.ForeignKey('self', blank=True, null=True, related_name='successors', verbose_name=_("Predecessor")) - hosts = models.ManyToManyField(Host, blank=True, null=True, related_name='shows', verbose_name=_("Hosts")) - owners = models.ManyToManyField(User, blank=True, null=True, related_name='shows', verbose_name=_("Owners")) + hosts = models.ManyToManyField(Host, blank=True, related_name='shows', verbose_name=_("Hosts")) + owners = models.ManyToManyField(User, blank=True, related_name='shows', verbose_name=_("Owners")) broadcastformat = models.ForeignKey(BroadcastFormat, related_name='shows', verbose_name=_("Broadcast format")) - showinformation = models.ManyToManyField(ShowInformation, blank=True, null=True, related_name='shows', verbose_name=_("Show information")) - showtopic = models.ManyToManyField(ShowTopic, blank=True, null=True, related_name='shows', verbose_name=_("Show topic")) - musicfocus = models.ManyToManyField(MusicFocus, blank=True, null=True, related_name='shows', verbose_name=_("Music focus")) + showinformation = models.ManyToManyField(ShowInformation, blank=True, related_name='shows', verbose_name=_("Show information")) + showtopic = models.ManyToManyField(ShowTopic, blank=True, related_name='shows', verbose_name=_("Show topic")) + musicfocus = models.ManyToManyField(MusicFocus, blank=True, related_name='shows', verbose_name=_("Music focus")) name = models.CharField(_("Name"), max_length=255) slug = models.CharField(_("Slug"), max_length=255, unique=True) image = models.ImageField(_("Image"), blank=True, null=True, upload_to='show_images') -- cgit v0.10.2 From 65efbfa1afb6161f0a4220b9da49904abf86e121 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Tue, 29 Mar 2016 15:33:04 +0200 Subject: removed unused comments template stuff diff --git a/program/templates/timeslot_detail.html b/program/templates/timeslot_detail.html index a3b62af..5133320 100644 --- a/program/templates/timeslot_detail.html +++ b/program/templates/timeslot_detail.html @@ -54,14 +54,6 @@ CBA-Link: CBA
{% endif %}

- - {% load comments %} - -
- {% render_comment_list for timeslot %} - - {% render_comment_form for timeslot %} -
-- cgit v0.10.2 From 64b0ff9e529ef47afa3c7583fb12d2fd43f1c7d7 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 30 Mar 2016 18:14:56 +0200 Subject: fixed jquery-ui path in day_schedule template, fixed recommendations template diff --git a/program/templates/day_schedule.html b/program/templates/day_schedule.html index 7a371e6..61005dd 100644 --- a/program/templates/day_schedule.html +++ b/program/templates/day_schedule.html @@ -1,10 +1,9 @@ Tagesansicht {{ day|date:"l, d.m.Y" }} — Radio Helsinki - Freies Radio Graz - - - + +