From d5394e0444461627f04407c0c85539c18be94cb1 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 c895afbebf5fc32b6ce94a258fc2c3cd34ffa1de Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Fri, 15 Aug 2014 20:35:42 +0200 Subject: simplified and fixed week schedule diff --git a/program/templates/week_schedule_timeslot.html b/program/templates/week_schedule_timeslot.html index 852466b..f1f6918 100644 --- a/program/templates/week_schedule_timeslot.html +++ b/program/templates/week_schedule_timeslot.html @@ -1,54 +1,51 @@ {% load timeslots %} -{% if forloop.first and timeslot.start != timeslot.get_previous_by_start.end %} -
-
{{ 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 forloop.first %} + {% if timeslot.start.hour < 6 %} + {# the day starts with the first show until its end #} + + {% else %} + {# the day starts with a default show until the start of first show #} +
+
{{ default_show.name }}
+
+ + {% endif %} {% if timeslot.end != timeslot.get_next_by_start.start %} -
-
{{ default_show.name }}
+ {# a default show is needed to fill the time until the next show #} +
+
{{ default_show.name }}
+
+ {% endif %} +{% elif forloop.last %} + {% if timeslot.end.hour < 6 %} + {# the day ends with this show and a default show until 6 #} + +
+
{{ default_show.name }}
+
+ {% else %} + {# the days ends with this show #} + + {% endif %} +{% else %} + + {% if timeslot.end != timeslot.get_next_by_start.start %} + {# a default show is needed to fill the time until the next show #} +
+
{{ 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 %} -- cgit v0.10.2 From ddf39c403eef01d5c53883221fb2f5ddf0e92acc Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sat, 16 Aug 2014 18:53:53 +0200 Subject: fixed the list of shows diff --git a/program/urls.py b/program/urls.py index 59caa2a..328f4a1 100644 --- a/program/urls.py +++ b/program/urls.py @@ -13,7 +13,7 @@ hosts_dict = { 'template_object_name': 'host' } shows_dict = { - 'queryset': Show.objects.filter(programslots__until__gt=date.today()).exclude(id=1).distinct(), + 'queryset': Show.objects.all(), 'template_object_name': 'show' } timeslots_dict = { @@ -23,24 +23,29 @@ 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') 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}), ) -- cgit v0.10.2 From b5bf6bd0e132e7f9a7cb50d39fc4507977cbc70d Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Fri, 5 Sep 2014 20:56:39 +0200 Subject: updated Django, Pillow and PyYAML diff --git a/requirements.txt b/requirements.txt index 8567bc6..83303bc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -Django==1.4.10 +Django==1.4.15 MySQL-python==1.2.5 -Pillow==2.3.0 -PyYAML==3.10 +Pillow==2.5.3 +PyYAML==3.11 django-tinymce==1.5.2 python-dateutil==1.5 -- cgit v0.10.2 From 1d521e1c65babb8412b4959bd476596e0aa36aa6 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 9d71379..6bbdcf8 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 0386ab3ed2ea15385adab932c93f87f28464de1e Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Wed, 20 Apr 2016 14:58:20 +0200 Subject: Hotfix: add end time to json day schedule, also include date in start/end diff --git a/program/views.py b/program/views.py index 5218ce7..09e08b0 100644 --- a/program/views.py +++ b/program/views.py @@ -198,7 +198,7 @@ def json_day_schedule(request, year=None, month=None, day=None): timeslots = TimeSlot.objects.get_24h_timeslots(today) schedule = [] for ts in timeslots: - entry = { 'start': ts.start.strftime('%H:%M:%S'), 'title': ts.programslot.show.name, 'id': ts.programslot.show.id, 'automation-id': -1 } + entry = { 'start': ts.start.strftime('%Y-%m-%d_%H:%M:%S'), 'end': ts.end.strftime('%Y-%m-%d_%H:%M:%S'), 'title': ts.programslot.show.name, 'id': ts.programslot.show.id, 'automation-id': -1 } if ts.programslot.automation_id: entry['automation-id'] = ts.programslot.automation_id elif ts.programslot.show.automation_id: -- cgit v0.10.2 From 36dffe4825bbf34435785aabdee67101cef725c4 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sun, 1 May 2016 15:46:50 +0200 Subject: minor cosmetics. diff --git a/program/views.py b/program/views.py index 09e08b0..eaba951 100644 --- a/program/views.py +++ b/program/views.py @@ -198,12 +198,20 @@ def json_day_schedule(request, year=None, month=None, day=None): timeslots = TimeSlot.objects.get_24h_timeslots(today) schedule = [] for ts in timeslots: - entry = { 'start': ts.start.strftime('%Y-%m-%d_%H:%M:%S'), 'end': ts.end.strftime('%Y-%m-%d_%H:%M:%S'), 'title': ts.programslot.show.name, 'id': ts.programslot.show.id, 'automation-id': -1 } + entry = { + 'start': ts.start.strftime('%Y-%m-%d_%H:%M:%S'), + 'end': ts.end.strftime('%Y-%m-%d_%H:%M:%S'), + 'title': ts.programslot.show.name, + 'id': ts.programslot.show.id, + 'automation-id': -1 + } + if ts.programslot.automation_id: entry['automation-id'] = ts.programslot.automation_id elif ts.programslot.show.automation_id: entry['automation-id'] = ts.programslot.show.automation_id - schedule.append(entry) + schedule.append(entry) - 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") -- cgit v0.10.2 From 18d04533b13fc19267e73e7cd20fe9223b96286a Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sun, 1 May 2016 15:47:38 +0200 Subject: updated requirements. diff --git a/requirements.txt b/requirements.txt index 22470f4..7a1f664 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -Django==1.8.8 +Django==1.8.12 MySQL-python==1.2.5 -Pillow==3.0.0 +Pillow==3.2.0 PyYAML==3.11 -django-tinymce==2.0.6 -python-dateutil==2.4.2 +django-tinymce==2.3.0 +python-dateutil==2.5.3 -- cgit v0.10.2 From b96eecc7b8d67ba51b3c3683b80b2cf64b7378e6 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sun, 1 May 2016 15:48:38 +0200 Subject: be explicit about what is not allowed to change while updating. diff --git a/program/models.py b/program/models.py index d755248..c3bc468 100644 --- a/program/models.py +++ b/program/models.py @@ -336,14 +336,20 @@ 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: - raise ValidationError(u"only until can be changed") + if self.rrule != old.rrule: + raise ValidationError(u"Recurrence rule cannot ba changed") + if self.byweekday != old.byweekday: + raise ValidationError(u"Weekday cannot be changed") + if self.show != old.show: + raise ValidationError(u"Show cannot be changed") + if self.dstart != old.dstart: + raise ValidationError(u"First date cannot ba changed") + if self.tstart != old.tstart: + raise ValidationError(u"Start time cannot be changed") + if self.tend != old.tend: + raise ValidationError(u"End time cannot be changed") + if self.is_repetition != old.is_repetition: + raise ValidationError(u"Is repetition cannot be changed") else: old = False -- cgit v0.10.2 From 094aa869116847d7941ab6fbf18b176dec1665d1 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sun, 1 May 2016 17:14:24 +0200 Subject: include notes of predecessor show if available. diff --git a/program/templates/show_detail.html b/program/templates/show_detail.html index 7993287..04ad976 100644 --- a/program/templates/show_detail.html +++ b/program/templates/show_detail.html @@ -73,9 +73,20 @@
{{ note.title }}
{% endfor %} + {% if show.predecessor and show.predecessor.notes.all %} + {% if show.name != show.predecessor.name %} +

Davor als {{ show.predecessor.name }}

+ {% endif %} + {% for note in show.predecessor.notes.all reversed %} +
  • + {{ note.start|date:"d. M Y" }}: +
    {{ note.title }}
    +
  • + {% endfor %} + {% endif %} {% endif %} -
    -- cgit v0.10.2 From 9dee37ef6176affc4fae32d3e0e90de7060f8246 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sun, 1 May 2016 18:14:58 +0200 Subject: Link to predecessor show. diff --git a/program/templates/show_detail.html b/program/templates/show_detail.html index 04ad976..e3b2bdb 100644 --- a/program/templates/show_detail.html +++ b/program/templates/show_detail.html @@ -75,7 +75,7 @@ {% endfor %} {% if show.predecessor and show.predecessor.notes.all %} {% if show.name != show.predecessor.name %} -

    Davor als {{ show.predecessor.name }}

    +

    Davor als {{ show.predecessor.name }}

    {% endif %} {% for note in show.predecessor.notes.all reversed %}
  • diff --git a/program/views.py b/program/views.py index eaba951..5dc82dd 100644 --- a/program/views.py +++ b/program/views.py @@ -50,7 +50,7 @@ class ShowListView(ListView): class ShowDetailView(DetailView): - queryset = Show.objects.filter(is_active=True).exclude(id=1).distinct() + queryset = Show.objects.all().exclude(id=1) template_name = 'show_detail.html' -- cgit v0.10.2 From a1487772e667436e2274dece86cb40d2e58632a7 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 21 May 2016 10:21:14 +0200 Subject: nop: added entries to musicprog list diff --git a/nop/views.py b/nop/views.py index 12e2ada..9fd87ee 100644 --- a/nop/views.py +++ b/nop/views.py @@ -20,7 +20,10 @@ MUSIKPROG_IDS = ( 204, # Radyo Mezopotamya 206, # Abunda Lingva 290, # styrian underground - 523 # Songbirds + 523, # Songbirds + 562, # Singing Birds + 563, # canzoni italiane + 564 # on connait la chanson ) SPECIAL_PROGRAM_IDS = ( -- cgit v0.10.2