summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
Diffstat (limited to 'program')
-rw-r--r--program/admin.py3
-rw-r--r--program/management/commands/addnote.py11
-rw-r--r--program/management/commands/cleanup_defaultshow.py5
-rw-r--r--program/management/commands/createuser.py1
-rw-r--r--program/management/commands/deleteuser.py3
-rw-r--r--program/management/commands/importhosts.py1
-rw-r--r--program/management/commands/importnotes.py9
-rw-r--r--program/management/commands/importprogramslots.py8
-rw-r--r--program/management/commands/importshows.py10
-rw-r--r--program/migrations/0006_note_remove_cba_entry_id.py18
-rw-r--r--program/migrations/0007_show_remove_cba_series_id.py18
-rw-r--r--program/models.py4
-rw-r--r--program/templatetags/content_boxes.py5
-rw-r--r--program/templatetags/timeslots.py4
-rw-r--r--program/urls.py6
-rw-r--r--program/views.py2
16 files changed, 77 insertions, 31 deletions
diff --git a/program/admin.py b/program/admin.py
index e6c331a..1323697 100644
--- a/program/admin.py
+++ b/program/admin.py
@@ -58,11 +58,13 @@ class NoteAdmin(admin.ModelAdmin):
class TimeSlotInline(admin.TabularInline):
model = TimeSlot
+ ordering = ('-end',)
class ProgramSlotAdmin(admin.ModelAdmin):
actions = ('renew',)
inlines = (TimeSlotInline,)
+ fields = (('rrule', 'byweekday'), ('dstart', 'tstart', 'tend'), 'until', 'is_repetition', 'automation_id')
list_display = ('show', 'byweekday', 'rrule', 'tstart', 'tend', 'until')
list_filter = ('byweekday', 'rrule', 'is_repetition', 'is_active')
ordering = ('byweekday', 'dstart')
@@ -83,6 +85,7 @@ class ProgramSlotAdmin(admin.ModelAdmin):
class ProgramSlotInline(admin.TabularInline):
model = ProgramSlot
+ ordering = ('-until',)
class ShowAdmin(admin.ModelAdmin):
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
new file mode 100644
index 0000000..d04be57
--- /dev/null
+++ b/program/migrations/0006_note_remove_cba_entry_id.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('program', '0005_programslot_is_active'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='note',
+ name='cba_entry_id',
+ ),
+ ]
diff --git a/program/migrations/0007_show_remove_cba_series_id.py b/program/migrations/0007_show_remove_cba_series_id.py
new file mode 100644
index 0000000..1173b51
--- /dev/null
+++ b/program/migrations/0007_show_remove_cba_series_id.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('program', '0006_note_remove_cba_entry_id'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='show',
+ name='cba_series_id',
+ ),
+ ]
diff --git a/program/models.py b/program/models.py
index c3bc468..97324b1 100644
--- a/program/models.py
+++ b/program/models.py
@@ -244,7 +244,6 @@ class Show(models.Model):
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)
last_updated = models.DateTimeField(auto_now=True, editable=False)
@@ -255,7 +254,7 @@ class Show(models.Model):
verbose_name_plural = _("Shows")
def __unicode__(self):
- return u'%s' % self.name
+ return u'%04d | %s' % (self.id, self.name)
def get_absolute_url(self):
return reverse('show-detail', args=[self.slug])
@@ -489,7 +488,6 @@ class Note(models.Model):
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)
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/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 5dc82dd..6a53e82 100644
--- a/program/views.py
+++ b/program/views.py
@@ -195,7 +195,7 @@ def json_day_schedule(request, year=None, month=None, day=None):
else:
today = datetime.strptime('%s__%s__%s__00__00' % (year, month, day), '%Y__%m__%d__%H__%M')
- timeslots = TimeSlot.objects.get_24h_timeslots(today)
+ timeslots = TimeSlot.objects.get_24h_timeslots(today).select_related('programslot')
schedule = []
for ts in timeslots:
entry = {