diff options
-rw-r--r-- | nop/urls.py | 2 | ||||
-rw-r--r-- | program/admin.py | 2 | ||||
-rw-r--r-- | program/management/commands/addnote.py | 11 | ||||
-rw-r--r-- | program/management/commands/cleanup_defaultshow.py | 5 | ||||
-rw-r--r-- | program/management/commands/createuser.py | 1 | ||||
-rw-r--r-- | program/management/commands/deleteuser.py | 3 | ||||
-rw-r--r-- | program/management/commands/importhosts.py | 1 | ||||
-rw-r--r-- | program/management/commands/importnotes.py | 9 | ||||
-rw-r--r-- | program/management/commands/importprogramslots.py | 8 | ||||
-rw-r--r-- | program/management/commands/importshows.py | 10 | ||||
-rw-r--r-- | program/migrations/0006_note_remove_cba_entry_id.py | 2 | ||||
-rw-r--r-- | program/migrations/0007_show_remove_cba_series_id.py | 2 | ||||
-rw-r--r-- | program/templatetags/content_boxes.py | 5 | ||||
-rw-r--r-- | program/templatetags/timeslots.py | 4 | ||||
-rw-r--r-- | program/urls.py | 6 | ||||
-rw-r--r-- | program/views.py | 12 | ||||
-rw-r--r-- | pv/urls.py | 11 |
17 files changed, 56 insertions, 38 deletions
diff --git a/nop/urls.py b/nop/urls.py index 3cc97a4..392d633 100644 --- a/nop/urls.py +++ b/nop/urls.py @@ -10,4 +10,4 @@ urlpatterns = patterns('', url(r'^/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/(?P<hour>\d{1,2})/(?P<minute>\d{1,2})/?$', get), url(r'^/?$', nop_form), url(r'^/static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': NOP_SITE_MEDIA}), -) + ) diff --git a/program/admin.py b/program/admin.py index 406d73f..1323697 100644 --- a/program/admin.py +++ b/program/admin.py @@ -60,6 +60,7 @@ class TimeSlotInline(admin.TabularInline): model = TimeSlot ordering = ('-end',) + class ProgramSlotAdmin(admin.ModelAdmin): actions = ('renew',) inlines = (TimeSlotInline,) @@ -86,6 +87,7 @@ class ProgramSlotInline(admin.TabularInline): model = ProgramSlot ordering = ('-until',) + class ShowAdmin(admin.ModelAdmin): filter_horizontal = ('hosts', 'owners', 'musicfocus', 'showinformation', 'showtopic') inlines = (ProgramSlotInline,) diff --git a/program/management/commands/addnote.py b/program/management/commands/addnote.py index 01d891e..5c0147e 100644 --- a/program/management/commands/addnote.py +++ b/program/management/commands/addnote.py @@ -1,4 +1,3 @@ -from django.contrib.auth.models import User from django.core.management.base import BaseCommand, CommandError from django.core.exceptions import ValidationError @@ -7,6 +6,7 @@ import sys from program.models import Show, TimeSlot, Note + class Command(BaseCommand): help = 'adds a note to a timeslot' args = '<show_id> <start_date> <status> [index]' @@ -40,11 +40,13 @@ class Command(BaseCommand): timeslot = TimeSlot.objects.get(show=show, start__year=year, start__month=month, start__day=day) except TimeSlot.DoesNotExist as dne: raise CommandError(dne) - except TimeSlot.MultipleObjectsReturned as mor: + except TimeSlot.MultipleObjectsReturned: if not index: - raise CommandError('you must provide the show_id, start_date, status index') + raise CommandError('you must provide the show_id, start_date, status index') try: - timeslot = TimeSlot.objects.filter(show=show, start__year=year, start__month=month, start__day=day).order_by('start')[int(index)] + timeslot = \ + TimeSlot.objects.filter(show=show, start__year=year, start__month=month, start__day=day).order_by( + 'start')[int(index)] except IndexError as ie: raise CommandError(ie) @@ -63,4 +65,3 @@ class Command(BaseCommand): else: note.save() print 'added note "%s" to "%s"' % (title, timeslot) - diff --git a/program/management/commands/cleanup_defaultshow.py b/program/management/commands/cleanup_defaultshow.py index 2f6ccca..98d3f98 100644 --- a/program/management/commands/cleanup_defaultshow.py +++ b/program/management/commands/cleanup_defaultshow.py @@ -3,10 +3,12 @@ from django.db import transaction from program.models import Show, TimeSlot, ProgramSlot + class Command(NoArgsCommand): + help = 'removes default shows without note' + @transaction.commit_manually def handle_noargs(self, **options): - help = 'removes default shows without note' default_show = Show.objects.get(pk=1) try: @@ -18,4 +20,3 @@ class Command(NoArgsCommand): transaction.rollback() else: transaction.commit() - diff --git a/program/management/commands/createuser.py b/program/management/commands/createuser.py index a356bb3..a78c101 100644 --- a/program/management/commands/createuser.py +++ b/program/management/commands/createuser.py @@ -3,6 +3,7 @@ from django.core.management.base import BaseCommand, CommandError from optparse import make_option + class Command(BaseCommand): help = 'creates an user' option_list = BaseCommand.option_list + ( diff --git a/program/management/commands/deleteuser.py b/program/management/commands/deleteuser.py index 27ce61e..db2cb60 100644 --- a/program/management/commands/deleteuser.py +++ b/program/management/commands/deleteuser.py @@ -3,6 +3,7 @@ from django.core.management.base import BaseCommand, CommandError from optparse import make_option + class Command(BaseCommand): help = 'deletes an user' option_list = BaseCommand.option_list + ( @@ -19,4 +20,4 @@ class Command(BaseCommand): except User.DoesNotExist: raise 'user does not exist.' else: - print 'user deleted succesfuly.'
\ No newline at end of file + print 'user deleted succesfuly.' diff --git a/program/management/commands/importhosts.py b/program/management/commands/importhosts.py index 1ecabef..31f4a3f 100644 --- a/program/management/commands/importhosts.py +++ b/program/management/commands/importhosts.py @@ -8,6 +8,7 @@ USER = 'helsinki' PASSWD = 'helsinki' DB = 'helsinki' + class Command(NoArgsCommand): help = 'Import hosts from current program' diff --git a/program/management/commands/importnotes.py b/program/management/commands/importnotes.py index 287dcef..0a1ab0f 100644 --- a/program/management/commands/importnotes.py +++ b/program/management/commands/importnotes.py @@ -1,7 +1,6 @@ -from django.contrib.auth.models import User from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned, ValidationError from django.core.management.base import NoArgsCommand -from django.utils.html import clean_html, strip_tags +from django.utils.html import strip_tags import MySQLdb @@ -11,6 +10,7 @@ USER = 'helsinki' PASSWD = 'helsinki' DB = 'helsinki' + class Command(NoArgsCommand): help = 'Import notes from current program' @@ -26,7 +26,7 @@ WHERE n.sendung_id in (SELECT id FROM sendungen WHERE letzter_termin > current_d for ntitel, datum, stitel, notiz in cursor.fetchall(): ntitel = strip_tags(ntitel) if ntitel else strip_tags(stitel) stitel = strip_tags(stitel) - notiz = clean_html(notiz) + notiz = strip_tags(notiz) if stitel.endswith('(Wiederholung)'): stitel = stitel[:-15] @@ -39,7 +39,8 @@ WHERE n.sendung_id in (SELECT id FROM sendungen WHERE letzter_termin > current_d print 'show with name "%s" not found' % stitel else: try: - timeslot = TimeSlot.objects.get(programslot__show=show, start__year=year, start__month=month, start__day=day) + timeslot = TimeSlot.objects.get(programslot__show=show, start__year=year, start__month=month, + start__day=day) except ObjectDoesNotExist: print 'no timeslot found for sendung "%s" and datum "%s"' % (stitel, datum) except MultipleObjectsReturned: diff --git a/program/management/commands/importprogramslots.py b/program/management/commands/importprogramslots.py index ce4f60e..b527f53 100644 --- a/program/management/commands/importprogramslots.py +++ b/program/management/commands/importprogramslots.py @@ -18,6 +18,7 @@ RRULES = { 28: RRule.objects.get(pk=5) } + class Command(NoArgsCommand): help = 'Import programslots from the current program' @@ -49,8 +50,8 @@ WHERE letzter_termin > current_date AND titel NOT LIKE 'Musikprogramm' AND titel except ObjectDoesNotExist: print 'show with name "%s" not found' % titel else: - programslot = ProgramSlot(rrule=rrule, byweekday=termin, show=show, dstart=erster_termin, tstart=tstart, - tend=tend, until=letzter_termin) + programslot = ProgramSlot(rrule=rrule, byweekday=termin, show=show, dstart=erster_termin, + tstart=tstart, tend=tend, until=letzter_termin) try: programslot.save() counter += 1 @@ -81,7 +82,8 @@ WHERE letzter_termin > current_date AND titel LIKE '%%(Wiederholung)'""") except ObjectDoesNotExist: print 'show with name "%s" not found' % titel else: - programslot = ProgramSlot(rrule=rrule, byweekday=termin, show=show, dstart=erster_termin, tstart=tstart, tend=tend, until=letzter_termin, is_repetition=True) + programslot = ProgramSlot(rrule=rrule, byweekday=termin, show=show, dstart=erster_termin, + tstart=tstart, tend=tend, until=letzter_termin, is_repetition=True) try: programslot.save() counter += 1 diff --git a/program/management/commands/importshows.py b/program/management/commands/importshows.py index d5fdee7..f1353b8 100644 --- a/program/management/commands/importshows.py +++ b/program/management/commands/importshows.py @@ -1,7 +1,7 @@ from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned from django.core.management.base import NoArgsCommand from django.template.defaultfilters import slugify -from django.utils.html import clean_html, strip_tags +from django.utils.html import strip_tags import MySQLdb @@ -13,9 +13,10 @@ DB = 'helsinki' TALK = BroadcastFormat.objects.get(pk=1) + class Command(NoArgsCommand): help = 'Import shows from the current program' - + def handle_noargs(self, **options): connection = MySQLdb.connect(user=USER, passwd=PASSWD, db=DB) cursor = connection.cursor() @@ -29,7 +30,7 @@ ORDER BY titel, beginn, ende""") for titel, beschreibung, web, macher in cursor.fetchall(): titel = strip_tags(titel) - beschreibung = clean_html(beschreibung) + beschreibung = strip_tags(beschreibung) slug = slugify(titel) @@ -50,7 +51,8 @@ ORDER BY titel, beginn, ende""") show = Show.objects.get(name=titel) print 'sendung "%s" already imported as show "%s"' % (titel, show) except ObjectDoesNotExist: - show = Show(broadcastformat=TALK, name=titel, slug=slug, short_description='FIXME', description=beschreibung) + show = Show(broadcastformat=TALK, name=titel, slug=slug, short_description='FIXME', + description=beschreibung) try: show.save() counter += 1 diff --git a/program/migrations/0006_note_remove_cba_entry_id.py b/program/migrations/0006_note_remove_cba_entry_id.py index e16da83..d04be57 100644 --- a/program/migrations/0006_note_remove_cba_entry_id.py +++ b/program/migrations/0006_note_remove_cba_entry_id.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models +from django.db import migrations class Migration(migrations.Migration): diff --git a/program/migrations/0007_show_remove_cba_series_id.py b/program/migrations/0007_show_remove_cba_series_id.py index 5c9f161..1173b51 100644 --- a/program/migrations/0007_show_remove_cba_series_id.py +++ b/program/migrations/0007_show_remove_cba_series_id.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models +from django.db import migrations class Migration(migrations.Migration): diff --git a/program/templatetags/content_boxes.py b/program/templatetags/content_boxes.py index 7f176c6..2d1745e 100644 --- a/program/templatetags/content_boxes.py +++ b/program/templatetags/content_boxes.py @@ -1,10 +1,9 @@ -# http://docs.djangoproject.com/en/1.2/howto/custom-template-tags/ - from django import template -register = template.Library() from program.models import BroadcastFormat, MusicFocus, ShowInformation, ShowTopic +register = template.Library() + @register.inclusion_tag('boxes/broadcastformat.html') def broadcastformat(): diff --git a/program/templatetags/timeslots.py b/program/templatetags/timeslots.py index c2c44b5..08e45b1 100644 --- a/program/templatetags/timeslots.py +++ b/program/templatetags/timeslots.py @@ -1,9 +1,9 @@ from django import template -register = template.Library() - from datetime import datetime, time, timedelta +register = template.Library() + @register.simple_tag def duration(start, end): diff --git a/program/urls.py b/program/urls.py index 18625a4..a3badf3 100644 --- a/program/urls.py +++ b/program/urls.py @@ -8,7 +8,6 @@ import os PROGRAM_SITE_MEDIA = os.path.join(os.path.dirname(__file__), '../site_media') - urlpatterns = patterns('', url(r'^today/?$', views.DayScheduleView.as_view()), url(r'^week/?$', views.WeekScheduleView.as_view()), @@ -25,5 +24,6 @@ urlpatterns = patterns('', url(r'^styles.css$', views.StylesView.as_view()) ) if settings.DEBUG: - urlpatterns += patterns('', - url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': PROGRAM_SITE_MEDIA})) + urlpatterns += \ + patterns('', + url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': PROGRAM_SITE_MEDIA})) diff --git a/program/views.py b/program/views.py index 5218ce7..bd04115 100644 --- a/program/views.py +++ b/program/views.py @@ -198,12 +198,18 @@ 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('%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") @@ -2,19 +2,20 @@ from django.conf import settings from django.conf.urls import patterns, url, include from django.contrib import admin -admin.autodiscover() - from program.views import json_day_schedule +admin.autodiscover() + urlpatterns = patterns('', 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<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$', json_day_schedule) -) + ) if settings.DEBUG: urlpatterns += patterns('', - (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}) -) + (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', + {'document_root': settings.MEDIA_ROOT}) + ) |