From 103a909a999ecb8e2bce2cf84e4ec39968223a53 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 13 Apr 2011 20:53:29 +0200 Subject: getting real. diff --git a/.gitignore b/.gitignore index 3011f78..eb29dcd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.pyc -*.sqlite \ No newline at end of file +dev_data.sqlite +local_settings.py diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5596645 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2011, Ernesto Rico-Schmidt +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +Neither the name of the author nor the names of its contributors may be +used to endorse or promote products derived from this software without specific +prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.rst b/README.rst index 0667df6..8480e0b 100644 --- a/README.rst +++ b/README.rst @@ -1,19 +1,39 @@ +================================= Radio Helsinki Program Management ================================= -Requirements ------------- +Installation +============ + +To get setup you must have the following installed: + + * Python 2.6 + * virtualenv 1.5 + +Setting up the environment +-------------------------- + +Create a virtual environment where the dependencies will live:: + + $ virtualenv --no-site-packages helsinki + $ source helsinki/bin/activate + (helsinki)$ + +Install the project dependencies:: + + (helsinki)$ pip install -r requirements.txt + +Setting up the database +----------------------- + +By default the project is set up to run on a SQLite database. You can run:: + + (helsinki)$ python manage.py syncdb + (helsinki)$ python manage.py loaddata program/fixtures/*.yaml -- Django 1.2.5: http://pypi.python.org/pypi/Django/1.2.5 -- PIL: http://pypi.python.org/pypi/PIL/1.1.6 -- python-dateutil: http://pypi.python.org/pypi/python-dateutil/1.5 -- PyYAML: http://pypi.python.org/pypi/PyYAML/3.09 -- MySQL-python: http://pypi.python.org/pypi/MySQL-python/1.2.3 -- django-haystack: http://pypi.python.org/pypi/django-haystack/1.1.0 -- pysolr: http://pypi.python.org/pypi/pysolr/2.0.13 +Running a web server +-------------------- -Author ------- +In development you should run:: -Ernesto Rico-Schmidt -Contributions: Johannes Raggam + (helsinki)$ python manage.py runserver diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/docs/CHANGES.rst b/docs/CHANGES.rst deleted file mode 100644 index e69de29..0000000 diff --git a/docs/LICENSE.rst b/docs/LICENSE.rst deleted file mode 100644 index 5596645..0000000 --- a/docs/LICENSE.rst +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2011, Ernesto Rico-Schmidt -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of the author nor the names of its contributors may be -used to endorse or promote products derived from this software without specific -prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/helsinki/__init__.py b/helsinki/__init__.py deleted file mode 100644 index f48ad10..0000000 --- a/helsinki/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages -try: - __import__('pkg_resources').declare_namespace(__name__) -except ImportError: - from pkgutil import extend_path - __path__ = extend_path(__path__, __name__) diff --git a/helsinki/program/__init__.py b/helsinki/program/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/helsinki/program/admin.py b/helsinki/program/admin.py deleted file mode 100644 index 6c64dd3..0000000 --- a/helsinki/program/admin.py +++ /dev/null @@ -1,82 +0,0 @@ -from django.contrib import admin - -from datetime import datetime - -from models import BroadcastFormat, MusicFocus, ShowInformation, ShowTopic, Host, Note, ProgramSlot, Show, TimeSlot - -class BroadcastFormatAdmin(admin.ModelAdmin): - list_display = ('format',) - prepopulated_fields = {'slug': ('format',)} - -class MusicFocusAdmin(admin.ModelAdmin): - list_display = ('focus', 'abbrev') - prepopulated_fields = {'slug': ('focus',)} - -class ShowInformationAdmin(admin.ModelAdmin): - list_display = ('information', 'abbrev') - prepopulated_fields = {'slug': ('information',)} - -class ShowTopicAdmin(admin.ModelAdmin): - list_display = ('topic', 'abbrev') - prepopulated_fields = {'slug': ('topic',)} - -class NoteAdmin(admin.ModelAdmin): - date_hierarchy = 'start' - list_display = ('title', 'show', 'start', 'status') - list_filter = ('status',) - ordering = ('timeslot',) - - def queryset(self, request): - qs = super(NoteAdmin, self).queryset(request) - - if request.user.is_superuser: - return qs - else: - return qs.filter(owner=request.user) - - def formfield_for_foreignkey(self, db_field, request, **kwargs): - if db_field.name == 'timeslot': - if request.user.is_superuser: - kwargs['queryset'] = TimeSlot.objects.filter(start__gt=datetime.now) - else: - shows = request.user.shows.all() - kwargs['queryset'] = TimeSlot.objects.filter(show__in=shows, start__gt=datetime.now) - - return super(NoteAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) - - def save_model(self, request, obj, form, change): - obj.owner = request.user - obj.save() - -class TimeSlotInline(admin.TabularInline): - model = TimeSlot - -class ProgramSlotAdmin(admin.ModelAdmin): - date_hierarchy = 'dstart' - inlines = (TimeSlotInline,) - list_display = ('show', 'byweekday', 'rrule', 'tstart', 'tend', 'dstart', 'until', 'timeslot_count') - list_filter = ('byweekday', 'rrule', 'is_repetition') - ordering = ('byweekday', 'dstart') - search_fields = ('show__name',) - -class ProgramSlotInline(admin.TabularInline): - model = ProgramSlot - -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',) - ordering = ('slug',) - prepopulated_fields = {'slug': ('name',)} - search_fields = ('name', 'short_description', 'description') - -admin.site.register(BroadcastFormat, BroadcastFormatAdmin) -admin.site.register(MusicFocus, MusicFocusAdmin) -admin.site.register(ShowInformation, ShowInformationAdmin) -admin.site.register(ShowTopic, ShowTopicAdmin) -admin.site.register(Note, NoteAdmin) -admin.site.register(ProgramSlot, ProgramSlotAdmin) -admin.site.register(Show, ShowAdmin) - -admin.site.register(Host) \ No newline at end of file diff --git a/helsinki/program/fixtures/broadcastformats.yaml b/helsinki/program/fixtures/broadcastformats.yaml deleted file mode 100644 index 84fa335..0000000 --- a/helsinki/program/fixtures/broadcastformats.yaml +++ /dev/null @@ -1,35 +0,0 @@ -- model: program.broadcastformat - pk: 1 - fields: - format: Talk - slug: talk -- model: program.broadcastformat - pk: 2 - fields: - format: Musiksendung - slug: musiksendung -- model: program.broadcastformat - pk: 3 - fields: - format: Unmoderiertes Musikprogramm - slug: unmoderiertes-musikprogramm -- model: program.broadcastformat - pk: 4 - fields: - format: Feature/Magazin - slug: feature-magazin -- model: program.broadcastformat - pk: 5 - fields: - format: Experimentell - slug: experimentell -- model: program.broadcastformat - pk: 6 - fields: - format: Hörspiel/Literatur - slug: horspiel-literatur -- model: program.broadcastformat - pk: 7 - fields: - format: Vortrag/Diskussion - slug: vortrag-diskussion \ No newline at end of file diff --git a/helsinki/program/fixtures/hosts.yaml b/helsinki/program/fixtures/hosts.yaml deleted file mode 100644 index 4cccf3a..0000000 --- a/helsinki/program/fixtures/hosts.yaml +++ /dev/null @@ -1,4 +0,0 @@ -- model: program.host - pk: 1 - fields: - name: Musikredaktion diff --git a/helsinki/program/fixtures/musicfocus.yaml b/helsinki/program/fixtures/musicfocus.yaml deleted file mode 100644 index 90de149..0000000 --- a/helsinki/program/fixtures/musicfocus.yaml +++ /dev/null @@ -1,60 +0,0 @@ -- model: program.musicfocus - pk: 1 - fields: - focus: Jazz - abbrev: J - slug: jazz -- model: program.musicfocus - pk: 2 - fields: - focus: Volksmusik/Folk - abbrev: V - slug: volksmusik-folk -- model: program.musicfocus - pk: 3 - fields: - focus: Experimentelle Musik - abbrev: Ex - slug: expermentelle-musik -- model: program.musicfocus - pk: 4 - fields: - focus: Rock/Indie - abbrev: R - slug: rock-indie -- model: program.musicfocus - pk: 5 - fields: - focus: Metal/Hardrock - abbrev: M - slug: metal-hardrock -- model: program.musicfocus - pk: 6 - fields: - focus: Electronic - abbrev: E - slug: electronic -- model: program.musicfocus - pk: 7 - fields: - focus: Klassik - abbrev: K - slug: klassik -- model: program.musicfocus - pk: 8 - fields: - focus: Oldies - abbrev: O - slug: oldies -- model: program.musicfocus - pk: 9 - fields: - focus: Reggae/Ska - abbrev: Re - slug: reggae-ska -- model: program.musicfocus - pk: 10 - fields: - focus: Hiphop - abbrev: H - slug: hiphop \ No newline at end of file diff --git a/helsinki/program/fixtures/rrules.yaml b/helsinki/program/fixtures/rrules.yaml deleted file mode 100644 index 4095e07..0000000 --- a/helsinki/program/fixtures/rrules.yaml +++ /dev/null @@ -1,29 +0,0 @@ -- model: program.rrule - pk: 1 - fields: - name: einmalig - freq: 0 - count: 1 -- model: program.rrule - pk: 2 - fields: - name: täglich - freq: 3 -- model: program.rrule - pk: 3 - fields: - name: wöchentlich - freq: 2 - interval: 1 -- model: program.rrule - pk: 4 - fields: - name: zweiwöchentlich - freq: 2 - interval: 2 -- model: program.rrule - pk: 5 - fields: - name: vierwöchentlich - freq: 2 - interval: 4 \ No newline at end of file diff --git a/helsinki/program/fixtures/showinformation.yaml b/helsinki/program/fixtures/showinformation.yaml deleted file mode 100644 index cbde529..0000000 --- a/helsinki/program/fixtures/showinformation.yaml +++ /dev/null @@ -1,48 +0,0 @@ -- model: program.showinformation - pk: 1 - fields: - information: Interkulturell - abbrev: I - slug: interkulturell -- model: program.showinformation - pk: 2 - fields: - information: Lokalbezug - abbrev: L - slug: lokalbezug -- model: program.showinformation - pk: 3 - fields: - information: Minderheiten - abbrev: Mi - slug: minderheiten -- model: program.showinformation - pk: 4 - fields: - information: Wiederholung - abbrev: W - slug: wiederholung -- model: program.showinformation - pk: 5 - fields: - information: Mehr-/Fremdsprachig - abbrev: M - slug: mehr-fremdsprachig -- model: program.showinformation - pk: 6 - fields: - information: Frauenschwerpunkt - abbrev: F - slug: frauenschwerpunkt -- model: program.showinformation - pk: 7 - fields: - information: Österreichische Musik - abbrev: Ö - slug: osterreichische-musik -- model: program.showinformation - pk: 8 - fields: - information: Sendungsübernahme - abbrev: U - slug: sendungsubernahme \ No newline at end of file diff --git a/helsinki/program/fixtures/shows.yaml b/helsinki/program/fixtures/shows.yaml deleted file mode 100644 index f520b26..0000000 --- a/helsinki/program/fixtures/shows.yaml +++ /dev/null @@ -1,10 +0,0 @@ -- model: program.show - pk: 1 - fields: - hosts: [1] - broadcastformat: 3 - name: Musikprogramm - slug: musikprogramm - description: Unmoderiertes Musikprogramm - short_description: Unmoderiertes Musikprogramm - email: musikredaktion@helsinki.at diff --git a/helsinki/program/fixtures/showtopics.yaml b/helsinki/program/fixtures/showtopics.yaml deleted file mode 100644 index 8f12508..0000000 --- a/helsinki/program/fixtures/showtopics.yaml +++ /dev/null @@ -1,30 +0,0 @@ -- model: program.showtopic - pk: 1 - fields: - topic: Politik/Gesellschaft - abbrev: P - slug: politik-gesellschaft -- model: program.showtopic - pk: 2 - fields: - topic: Natur/Klima/Tiere - abbrev: N - slug: natur-klima-tiere -- model: program.showtopic - pk: 3 - fields: - topic: Kultur/Kunst - abbrev: K - slug: kultur-kunst -- model: program.showtopic - pk: 4 - fields: - topic: Soziales - abbrev: S - slug: soziales -- model: program.showtopic - pk: 5 - fields: - topic: Wissenschaft/Philosophie - abbrev: W - slug: wissenschaft-philosophie \ No newline at end of file diff --git a/helsinki/program/manage.py b/helsinki/program/manage.py deleted file mode 100755 index 5e78ea9..0000000 --- a/helsinki/program/manage.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env python -from django.core.management import execute_manager -try: - import settings # Assumed to be in the same directory. -except ImportError: - import sys - sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) - sys.exit(1) - -if __name__ == "__main__": - execute_manager(settings) diff --git a/helsinki/program/management/__init__.py b/helsinki/program/management/__init__.py deleted file mode 100644 index 3aa4ca5..0000000 --- a/helsinki/program/management/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -__author__ = 'ers' - \ No newline at end of file diff --git a/helsinki/program/management/commands/__init__.py b/helsinki/program/management/commands/__init__.py deleted file mode 100644 index 3aa4ca5..0000000 --- a/helsinki/program/management/commands/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -__author__ = 'ers' - \ No newline at end of file diff --git a/helsinki/program/management/commands/importhosts.py b/helsinki/program/management/commands/importhosts.py deleted file mode 100644 index 39a8afd..0000000 --- a/helsinki/program/management/commands/importhosts.py +++ /dev/null @@ -1,34 +0,0 @@ -from django.core.management.base import NoArgsCommand - -import MySQLdb - -from helsinki.program.models import Host - -USER = 'helsinki' -PASSWD = 'helsinki' -DB = 'helsinki' - -class Command(NoArgsCommand): - help = 'Import hosts from current program' - - def handle_noargs(self, **options): - connection = MySQLdb.connect(user=USER, passwd=PASSWD, db=DB) - cursor = connection.cursor() - - cursor.execute("""SELECT DISTINCT macher -FROM sendungen -WHERE letzter_termin > current_date AND macher != '' AND titel NOT LIKE 'Musikprogramm'""") - - counter = 0 - - for row in cursor.fetchall(): - for macher in row[0].split(','): - host = Host(name=macher.strip()) - host.save() - - counter += 1 - - cursor.close() - connection.close() - - print '%i hosts imported' % counter diff --git a/helsinki/program/management/commands/importnotes.py b/helsinki/program/management/commands/importnotes.py deleted file mode 100644 index 19ddfed..0000000 --- a/helsinki/program/management/commands/importnotes.py +++ /dev/null @@ -1,62 +0,0 @@ -from django.contrib.auth.models import User -from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned -from django.core.management.base import NoArgsCommand -from django.utils.html import clean_html, strip_tags - -import MySQLdb - -from helsinki.program.models import Note, Show, TimeSlot - -USER = 'helsinki' -PASSWD = 'helsinki' -DB = 'helsinki' - -OWNER = User.objects.get(pk=1) - -class Command(NoArgsCommand): - help = 'Import notes from current program' - - def handle_noargs(self, **options): - connection = MySQLdb.connect(user=USER, passwd=PASSWD, db=DB) - cursor = connection.cursor() - - cursor.execute("""SELECT n.titel, n.datum, s.titel, n.notiz -FROM notizen AS n JOIN sendungen AS s ON n.sendung_id=s.id -WHERE n.sendung_id in (SELECT id FROM sendungen WHERE letzter_termin > current_date) AND n.titel != ''""") - - counter = 0 - for ntitel, datum, stitel, notiz in cursor.fetchall(): - ntitel = strip_tags(ntitel) - stitel = strip_tags(stitel) - notiz = clean_html(notiz) - - if stitel.endswith('(Wiederholung)'): - stitel = stitel[:-15] - - if datum: - year, month, day = datum.year, datum.month, datum.day - try: - show = Show.objects.get(name=stitel) - - try: - 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: - print 'multiple timeslots found for sendung "%s" and datum "%s"' % (stitel, datum) - else: - note = Note(timeslot=timeslot, owner=OWNER, title=ntitel, content=notiz) - - try: - note.save() - except: - print 'could not save note "%s" for show "%s" and datum "%s"' % (ntitel, stitel, datum) - else: - counter += 1 - except ObjectDoesNotExist: - print 'show with name "%s" not found' % stitel - - cursor.close() - connection.close() - - print '%i notes imported' % counter diff --git a/helsinki/program/management/commands/importprogramslots.py b/helsinki/program/management/commands/importprogramslots.py deleted file mode 100644 index 52aa73a..0000000 --- a/helsinki/program/management/commands/importprogramslots.py +++ /dev/null @@ -1,96 +0,0 @@ -from django.core.exceptions import ObjectDoesNotExist -from django.core.management.base import NoArgsCommand -from django.utils.html import strip_tags - -from datetime import time -import MySQLdb - -from helsinki.program.models import Show, ProgramSlot, RRule - -USER = 'helsinki' -PASSWD = 'helsinki' -DB = 'helsinki' - -RRULES = { - 0: RRule.objects.get(pk=1), - 7: RRule.objects.get(pk=3), - 14: RRule.objects.get(pk=4), - 28: RRule.objects.get(pk=5) -} - -class Command(NoArgsCommand): - help = 'Import programslots from the current program' - - def handle_noargs(self, **options): - connection = MySQLdb.connect(user=USER, passwd=PASSWD, db=DB) - cursor = connection.cursor() - - cursor.execute("""SELECT titel, beginn, ende, erster_termin, letzter_termin, rhytmus, termin -FROM sendungen -WHERE letzter_termin > current_date AND titel NOT LIKE 'Musikprogramm' AND titel NOT LIKE '%%(Wiederholung)'""") - - counter = 0 - - for titel, beginn, ende, erster_termin, letzter_termin, rhytmus, termin in cursor.fetchall(): - titel = strip_tags(titel) - - hours, seconds = divmod(beginn.seconds, 3600) - minutes, seconds = divmod(seconds, 60) - tstart = time(hour=hours, minute=minutes, second=seconds) - - hours, seconds = divmod(ende.seconds, 3600) - minutes, seconds = divmod(seconds, 60) - tend = time(hour=hours, minute=minutes, second=seconds) - - try: - rrule = RRULES[rhytmus] - try: - show = Show.objects.get(name=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) - try: - programslot.save() - counter += 1 - except: - pass - except KeyError: - print 'rhythmus "%i" is not supported for sendung "%s"' % (rhytmus, titel) - - cursor.execute("""SELECT titel, beginn, ende, erster_termin, letzter_termin, rhytmus, termin -FROM sendungen -WHERE letzter_termin > current_date AND titel LIKE '%%(Wiederholung)'""") - - for titel, beginn, ende, erster_termin, letzter_termin, rhytmus, termin in cursor.fetchall(): - titel = strip_tags(titel[:-15]) - - hours, seconds = divmod(beginn.seconds, 3600) - minutes, seconds = divmod(seconds, 60) - tstart = time(hour=hours, minute=minutes, second=seconds) - - hours, seconds = divmod(ende.seconds, 3600) - minutes, seconds = divmod(seconds, 60) - tend = time(hour=hours, minute=minutes, second=seconds) - - try: - rrule = RRULES[rhytmus] - try: - show = Show.objects.get(name=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, is_repetition=True) - try: - programslot.save() - counter += 1 - except: - pass - except KeyError: - print 'rhythmus "%i" is not supported for sendung "%s"' % (rhytmus, titel) - - cursor.close() - connection.close() - - print '%i programslots imported' % counter diff --git a/helsinki/program/management/commands/importshows.py b/helsinki/program/management/commands/importshows.py deleted file mode 100644 index b013dab..0000000 --- a/helsinki/program/management/commands/importshows.py +++ /dev/null @@ -1,67 +0,0 @@ -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 - -import MySQLdb - -from helsinki.program.models import BroadcastFormat, Host, Show - -USER = 'helsinki' -PASSWD = 'helsinki' -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() - - cursor.execute("""SELECT titel, beschreibung, web, macher -FROM sendungen -WHERE letzter_termin > current_date AND titel NOT LIKE 'Musikprogramm' AND titel NOT LIKE '%%(Wiederholung)' -ORDER BY titel, beginn, ende""") - - counter = 0 - - for titel, beschreibung, web, macher in cursor.fetchall(): - titel = strip_tags(titel) - beschreibung = clean_html(beschreibung) - - slug = slugify(titel) - - hosts = [] - - for macher in macher.split(','): - macher = macher.strip() - try: - host = Host.objects.get(name=macher) - except MultipleObjectsReturned: - print 'multiple hosts with name "%s" found' % macher - except ObjectDoesNotExist: - print 'host with name "%s" not found' % macher - else: - hosts.append(host) - - try: - 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) - try: - show.save() - counter += 1 - except: - print 'sendung "%s" could not be imported' % titel - else: - for h in hosts: - show.hosts.add(h) - show.save() - - cursor.close() - connection.close() - - print '%i shows imported' % counter diff --git a/helsinki/program/models.py b/helsinki/program/models.py deleted file mode 100644 index 5f0f835..0000000 --- a/helsinki/program/models.py +++ /dev/null @@ -1,297 +0,0 @@ -from django.contrib.auth.models import User -from django.core.exceptions import ObjectDoesNotExist -from django.db import models -from django.utils.translation import ugettext_lazy as _ - -from datetime import date, datetime -from dateutil.relativedelta import relativedelta -from dateutil.rrule import rrule - -class BroadcastFormat(models.Model): - format = models.CharField(_("Format"), max_length=32) - slug = models.SlugField(_("Slug"), max_length=32, unique=True) - - class Meta: - ordering = ('format',) - verbose_name = _("Broadcast format") - verbose_name_plural = _("Broadcast formats") - - 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) - - class Meta: - ordering = ('information',) - verbose_name = _("Show information") - verbose_name_plural = _("Show information") - - 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) - - class Meta: - ordering = ('topic',) - verbose_name = _("Show topic") - verbose_name_plural = _("Show topics") - - 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) - - class Meta: - ordering = ('focus',) - verbose_name = _("Music focus") - verbose_name_plural = _("Music focus") - - 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") - - def __unicode__(self): - return u'%s' % self.name - - @models.permalink - 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")) - name = models.CharField(_("Name"), max_length=256) - slug = models.CharField(_("Slug"), max_length=255, unique=True) - image = models.ImageField(_("Image"), blank=True, null=True, upload_to='show_images') - short_description = models.CharField(_("Short description"), max_length=64) - description = models.TextField(_("Description")) - 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) - created = models.DateTimeField(auto_now_add=True, editable=False) - last_updated = models.DateTimeField(auto_now=True, editable=False) - - class Meta: - ordering = ('slug',) - verbose_name = _("Show") - verbose_name_plural = _("Shows") - - def __unicode__(self): - return u'%s' % self.name - - @models.permalink - def get_absolute_url(self): - return ('show-detail', [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 = ( - (1, _("Monthly")), - (2, _("Weekly")), - (3, _("Daily")), - ) - BYSETPOS_CHOICES = ( - (1, _("First")), - (2, _("Second")), - (3, _("Third")), - (4, _("Fourth")), - (5, _("Fifth")), - (-1, _("Last")), - ) - 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) - count = models.IntegerField(_("Count"), blank=True, null=True) - - class Meta: - ordering = ('-freq', 'interval', 'bysetpos') - verbose_name = _("Recurrence rule") - verbose_name_plural = _("Recurrence rules") - - def __unicode__(self): - return u'%s' % self.name - -class ProgramSlot(models.Model): - BYWEEKDAY_CHOICES = ( - (0, _("Monday")), - (1, _("Tuesday")), - (2, _("Wednesday")), - (3, _("Thursday")), - (4, _("Friday")), - (5, _("Saturday")), - (6, _("Sunday")), - ) - 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")) - 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) - created = models.DateTimeField(auto_now_add=True, editable=False) - last_updated = models.DateTimeField(auto_now=True, editable=False) - - class Meta: - ordering = ('dstart', 'tstart') - unique_together = ('rrule', 'byweekday', 'dstart', 'tstart') - verbose_name = _("Program slot") - verbose_name_plural = _("Program slots") - - def __unicode__(self): - weekday = self.BYWEEKDAY_CHOICES[self.byweekday][1] - tend = self.tend.strftime('%H:%M') - dstart = self.dstart.strftime('%d. %b %Y') - tstart = self.tstart.strftime('%H:%M') - - if self.rrule.freq == 0: - return u'%s, %s - %s' % (dstart, tstart, tend) - if self.rrule.freq == 3: - return u'%s, %s - %s' % (self.rrule, tstart, tend) - else: - return u'%s, %s, %s - %s' % (weekday, self.rrule, tstart, tend) - - def save(self, *args, **kwargs): - if not self.pk: - super(ProgramSlot, self).save(*args, **kwargs) - - if self.rrule.freq == 0: - byweekday_start = None - byweekday_end = None - elif self.rrule.freq == 3: - byweekday_start = (0, 1, 2, 3, 4, 5, 6) - byweekday_end = (0, 1, 2, 3, 4, 5, 6) - else: - byweekday_start = self.byweekday - - if self.tend < self.tstart: - byweekday_end = self.byweekday + 1 if self.byweekday < 6 else 0 - else: - byweekday_end = self.byweekday - - 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)) - ends = list(rrule(freq=self.rrule.freq, - dtstart=datetime.combine(self.dstart, self.tend), - interval=self.rrule.interval, - until=self.until+relativedelta(days=+1), - bysetpos=self.rrule.bysetpos, - byweekday=byweekday_end)) - - for k in range(len(starts)): - timeslot = TimeSlot(programslot=self, start=starts[k], end=ends[k]) - timeslot.save() - - def timeslot_count(self): - return self.timeslots.count() - timeslot_count.description = _("Time slot count") - -class TimeSlotManager(models.Manager): - def get_or_create_current(self): - try: - return TimeSlot.objects.get(start__lte=datetime.now(), end__gt=datetime.now()) - except ObjectDoesNotExist: - once = RRule.objects.get(pk=1) - 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] - - 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.save() - - return new_programslot.timeslots.all()[0] - -class TimeSlot(models.Model): - 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) - - objects = TimeSlotManager() - - class Meta: - ordering = ('start', 'end') - verbose_name = _("Time slot") - verbose_name_plural = _("Time slots") - - def __unicode__(self): - start = self.start.strftime('%d. %b %Y %H:%M') - end = self.end.strftime('%H:%M') - - return u'%s: %s - %s' % (self.show, start, end) - - def save(self, *args, **kwargs): - self.show = self.programslot.show - super(TimeSlot, self).save(*args, **kwargs) - - @models.permalink - def get_absolute_url(self): - return ('timeslot-detail', [self.id]) - -class Note(models.Model): - STATUS_CHOICES = ( - (0, _("Cancellation")), - (1, _("Recommendation")), - (2, _("Repetition")), - ) - timeslot = models.OneToOneField(TimeSlot, verbose_name=_("Time slot")) - owner = models.ForeignKey(User, related_name='notes', verbose_name=_("Owner")) - title = models.CharField(_("Title"), max_length=128) - content = models.TextField(_("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) - created = models.DateTimeField(auto_now_add=True, editable=False) - last_updated = models.DateTimeField(auto_now=True, editable=False) - - class Meta: - ordering = ('timeslot',) - verbose_name = _("Note") - verbose_name_plural = _("Notes") - - def __unicode__(self): - return u'%s - %s' % (self.title, self.timeslot) - - def save(self, *args, **kwargs): - self.start = self.timeslot.start - self.show = self.timeslot.programslot.show - - super(Note, self).save(*args, **kwargs) diff --git a/helsinki/program/search_indexes.py b/helsinki/program/search_indexes.py deleted file mode 100644 index 745f379..0000000 --- a/helsinki/program/search_indexes.py +++ /dev/null @@ -1,15 +0,0 @@ -from haystack.indexes import CharField, DateTimeField, SearchIndex -from haystack import site - -from datetime import datetime - -from program.models import Note, Show - -class NoteIndex(SearchIndex): - SearchableText = CharField(document=True, use_template=True) - -class ShowIndex(SearchIndex): - SearchableText = CharField(document=True, use_template=True) - -site.register(Note, NoteIndex) -site.register(Show, ShowIndex) diff --git a/helsinki/program/search_sites.py b/helsinki/program/search_sites.py deleted file mode 100644 index fe5127a..0000000 --- a/helsinki/program/search_sites.py +++ /dev/null @@ -1,2 +0,0 @@ -import haystack -haystack.autodiscover() \ No newline at end of file diff --git a/helsinki/program/settings.py b/helsinki/program/settings.py deleted file mode 100644 index 036fe3e..0000000 --- a/helsinki/program/settings.py +++ /dev/null @@ -1,76 +0,0 @@ -import os - -# Django settings for helsinki project. - -DEBUG = True -TEMPLATE_DEBUG = DEBUG - -ADMINS = ( - # ('Your Name', 'your_email@example.com'), -) - -MANAGERS = ADMINS - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'helsinki2', - 'USER': 'helsinki', - 'PASSWORD': 'helsinki' - } -} - -TIME_ZONE = 'Europe/Vienna' - -LANGUAGE_CODE = 'de' - -SITE_ID = 1 - -USE_I18N = True - -USE_L10N = True - -MEDIA_ROOT = '' - -MEDIA_URL = '' - -ADMIN_MEDIA_PREFIX = '/media/' - -SECRET_KEY = 'oepk-$!=)c)7+y%cdz-x46_h5bp!o-*9%dv!(sf=3r4zfqk_(t' - -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', -# 'django.template.loaders.eggs.Loader', -) - -MIDDLEWARE_CLASSES = ( - 'django.middleware.common.CommonMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', -) - -ROOT_URLCONF = 'helsinki.program.urls' - -TEMPLATE_DIRS = ( - os.path.join(os.path.dirname(__file__), "templates"), -) - -INSTALLED_APPS = ( - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.sites', - 'django.contrib.messages', - 'django.contrib.admin', - 'helsinki.program', - 'haystack', -) - -HAYSTACK_SITECONF = 'helsinki.program.search_sites' -HAYSTACK_SEARCH_ENGINE = 'solr' -HAYSTACK_SOLR_URL = 'http://localhost:8988/solr' -# plone integration -HAYSTACK_ID_FIELD = 'docid' diff --git a/helsinki/program/site_media/styles/base.css b/helsinki/program/site_media/styles/base.css deleted file mode 100644 index 51194b1..0000000 --- a/helsinki/program/site_media/styles/base.css +++ /dev/null @@ -1,152 +0,0 @@ -#recommendations-box, -#day-schedule, -#broadcastformats, -#filter, -#shows { - display: inline; - float: left; -} - -#filter { width: 213px; } -#recommendations-box { width: 213px; } -#day-schedule { width: 700px; } -#shows {width: 700px;} -#broadcastformats { width: 170px; } -#current-timeslot, -#next-timeslot, -#after-next-timeslot { - clear: both; -} - -#current-timeslot .start, -#next-timeslot .start, -#after-next-timeslot .start { - display: inline; - float: left; -} - -#current-timeslot .show, -#next-timeslot .show, -#after-next-timeslot .show { - display: inline; - float: left; -} - -/* FIXME: fill the actual colors */ -#current-timeslot .experimentell, -#next-timeslot .experimentell, -#after-next-timeslot .experimentell, -#recommendations-box .experimentell { - border-left: red solid 3px; -} -#current-timeslot .feature-magazin, -#next-timeslot .feature-magazin, -#after-next-timeslot .feature-magazin, -#recommendations-box .feature-magazin { - border-left: red solid 3px; -} -#current-timeslot .horspiel-literatur, -#next-timeslot .horspiel-literatur, -#after-next-timeslot .horspiel-literatur, -#recommendations-box .horspiel-literatur { - border-left: red solid 3px; -} -#current-timeslot .musiksendung, -#next-timeslot .musiksendung, -#after-next-timeslot .musiksendung, -#recommendations-box .musiksendung { - border-left: red solid 3px; -} -#current-timeslot .talk, -#next-timeslot .talk, -#after-next-timeslot .talk, -#recommendations-box .talk { - border-left: red solid 3px; -} -#current-timeslot .unmoderiertes-musikprogramm, -#next-timeslot .unmoderiertes-musikprogramm, -#after-next-timeslot .unmoderiertes-musikprogramm, -#recommendations-box .unmoderiertes-musikprogramm { - border-left: red solid 3px; -} -#current-timeslot .vortrag-diskussion, -#next-timeslot .vortrag-diskussion, -#after-next-timeslot .vortrag-diskussion, -#recommendations-box .vortrag-diskussion { - border-left: red solid 3px; -} - -#recommendations-box .recommendation { - clear: both; -} - -/* FIXME: fill the actual colors */ -#day-schedule .experimentell { - background-color: red; -} -#day-schedule .feature-magazin { - background-color: red; -} -#day-schedule .horspiel-literatur { - background-color: red; -} -#day-schedule .musiksendung { - background-color: red; -} -#day-schedule .talk { - background-color: red; -} -#day-schedule .unmoderiertes-musikprogramm { - background-color: red; -} -#day-schedule .vortrag-diskussion { - background-color: red; -} - -#day-schedule .timeslot { - clear: both; -} - -.timeslot .start, -.timeslot .show-abbrevs, -.timeslot .show { - display: inline; - float: left; -} - -.timeslot .show-abbrevs { width: 50px; } - -#shows .show { clear: both; } - -.show .abbrevs { - width: 50px; - display: inline; - float: left; -} -.show .details { - display: inline; - float: left; -} - -.details .name, -.details .programslots, -.details .short-description { - display: inline; - float: left; -} - -#week-schedule { width: 960px; } -#week-schedule .weekday { font-size: small; height: 2em; } - -#monday, -#tuesday, -#wednesday, -#thursday, -#friday, -#saturday, -#sunday { - display: inline; - float: left; - font-size: small; - width: 123px; -} diff --git a/helsinki/program/templates/404.html b/helsinki/program/templates/404.html deleted file mode 100644 index 6281ba0..0000000 --- a/helsinki/program/templates/404.html +++ /dev/null @@ -1,7 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Seite nicht gefunden{% endblock %} - -{% block content %} -

Es tut uns leid, aber die angeforderte Seite konnte nicht gefunden werden.

-{% endblock %} \ No newline at end of file diff --git a/helsinki/program/templates/500.html b/helsinki/program/templates/500.html deleted file mode 100644 index 98074ab..0000000 --- a/helsinki/program/templates/500.html +++ /dev/null @@ -1,11 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Serverfehler{% endblock %} - -{% block content %} -

- Ein Fehler ist aufgetreten. - Dieser Fehler wurde an die Serververwalter per E-Mail gemeldet und sollte in Kürze behoben sein. - Vielen Dank für Ihr Verständnis. -

-{% endblock %} \ No newline at end of file diff --git a/helsinki/program/templates/base.html b/helsinki/program/templates/base.html deleted file mode 100644 index 2ed539e..0000000 --- a/helsinki/program/templates/base.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - {% block title %}{% endblock %} - - - -{% block content %}{% endblock %} - - - \ No newline at end of file diff --git a/helsinki/program/templates/program/box_broadcastformat.html b/helsinki/program/templates/program/box_broadcastformat.html deleted file mode 100644 index 20e914f..0000000 --- a/helsinki/program/templates/program/box_broadcastformat.html +++ /dev/null @@ -1,10 +0,0 @@ -{% if broadcastformats %} -
-
Legende
- {% for broadcastformat in broadcastformats %} -
- {{ broadcastformat.format }} -
- {% endfor %} -
-{% endif %} diff --git a/helsinki/program/templates/program/box_musicfocus.html b/helsinki/program/templates/program/box_musicfocus.html deleted file mode 100644 index da2c90f..0000000 --- a/helsinki/program/templates/program/box_musicfocus.html +++ /dev/null @@ -1,14 +0,0 @@ -{% if musicfoci %} -
-
Musiktendenz
-
-
    - {% for item in musicfoci %} -
  • - {{ item }} -
  • - {% endfor %} -
-
-
-{% endif %} diff --git a/helsinki/program/templates/program/box_showinformation.html b/helsinki/program/templates/program/box_showinformation.html deleted file mode 100644 index a3171d0..0000000 --- a/helsinki/program/templates/program/box_showinformation.html +++ /dev/null @@ -1,14 +0,0 @@ -{% if showinformations %} -
-
Sendungsinfo
-
-
    - {% for item in showinformations %} -
  • - {{ item }} -
  • - {% endfor %} -
-
-
-{% endif %} diff --git a/helsinki/program/templates/program/box_showtopic.html b/helsinki/program/templates/program/box_showtopic.html deleted file mode 100644 index 79e9519..0000000 --- a/helsinki/program/templates/program/box_showtopic.html +++ /dev/null @@ -1,14 +0,0 @@ -{% if showtopics %} -
-
Thema / Schwerpunkt
-
-
    - {% for item in showtopics %} -
  • - {{ item }} -
  • - {% endfor %} -
-
-
-{% endif %} diff --git a/helsinki/program/templates/program/current_box.html b/helsinki/program/templates/program/current_box.html deleted file mode 100644 index a2341d3..0000000 --- a/helsinki/program/templates/program/current_box.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - Current program box - - - - - {% if current or next or after_next %} -
-
Programm derzeit
-
-
{{ current.start|date:"H:i" }}
-
- - {% if current.note %} -
{{ current.note.title }}
- {% else %} - {% if current.show.short_description != 'FIXME' %} -
{{ current.show.short_description }}
- {% endif %} - {% endif %} -
-
-
-
{{ next.start|date:"H:i" }}
- -
-
-
{{ after_next.start|date:"H:i" }}
- -
-
- {% endif %} - - - diff --git a/helsinki/program/templates/program/day_schedule.html b/helsinki/program/templates/program/day_schedule.html deleted file mode 100644 index a0e1ac4..0000000 --- a/helsinki/program/templates/program/day_schedule.html +++ /dev/null @@ -1,60 +0,0 @@ - - - Day schedule: {{ day|date:"l, d.m.Y" }} - - - - - -
- -{% load content_boxes %} -
-{% broadcastformat %} -
-
-
-
Filter
-
-{% musicfocus %} -{% showinformation %} -{% showtopic %} -
- -
-

Tagesansicht

-

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

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

{{ timeslot.show.name }}

- {% if timeslot.note %} -

Heute: {{ timeslot.note.title }}

- {% else %} - {% if timeslot.show.short_description != 'FIXME' %} -

{{ timeslot.show.short_description }}

- {% endif %} - {% endif %} -
-
- {% endfor %} -
-
- - - - diff --git a/helsinki/program/templates/program/host_detail.html b/helsinki/program/templates/program/host_detail.html deleted file mode 100644 index d28f582..0000000 --- a/helsinki/program/templates/program/host_detail.html +++ /dev/null @@ -1,29 +0,0 @@ - - - Host detail: {{ host.name }} - - - - -
-
{{ host.name }}
- -
-
Sendungen
- - {% for show in host.shows.all %} - - {% endfor %} -
- - {% if host.email %} -
E-Mail Adresse: {{ host.email }}
- {% endif %} - - {% if host.website %} - - {% endif %} -
- - - diff --git a/helsinki/program/templates/program/host_list.html b/helsinki/program/templates/program/host_list.html deleted file mode 100644 index 9b83b29..0000000 --- a/helsinki/program/templates/program/host_list.html +++ /dev/null @@ -1,17 +0,0 @@ - - - Host list - - - - -
-{% for host in host_list %} - -{% endfor %} -
- - - diff --git a/helsinki/program/templates/program/recommendations.html b/helsinki/program/templates/program/recommendations.html deleted file mode 100644 index 85ec16e..0000000 --- a/helsinki/program/templates/program/recommendations.html +++ /dev/null @@ -1,24 +0,0 @@ - - - Recomendations - - - - -
-
Programmhinweise
-{% for recommendation in recommendation_list %} -
-
{{ recommendation.timeslot.start|date:"d.m. H:i" }}-{{ recommendation.timeslot.end|date:"H:i" }}
- - {% if recommendation.show.short_description != 'FIXME' %} -
{{ recommendation.show.short_description }}
- {% endif %} - -
{{ recommendation.content|safe}}
-
-{% endfor %} -
- - - diff --git a/helsinki/program/templates/program/recommendations_box.html b/helsinki/program/templates/program/recommendations_box.html deleted file mode 100644 index abcbe03..0000000 --- a/helsinki/program/templates/program/recommendations_box.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - Recomendations box - - - - {% if recommendation_list %} -
-
Programmhinweise
- {% for recommendation in recommendation_list %} -
-

{{ recommendation.show.name }}

-

{{ recommendation.timeslot.start|date:"d.m. H:i" }}-{{ recommendation.timeslot.end|date:"H:i" }}

-

{{ recommendation.title }}

-
- {% endfor %} -
- {% endif %} - - diff --git a/helsinki/program/templates/program/show_detail.html b/helsinki/program/templates/program/show_detail.html deleted file mode 100644 index 0238ad3..0000000 --- a/helsinki/program/templates/program/show_detail.html +++ /dev/null @@ -1,64 +0,0 @@ - - - Show detail: {{ show.name }} - - - -
- -
- -

{{ show.name }}

- - {% if show.short_description != 'FIXME' %} -
{{ show.short_description }}
- {% endif %} - -
- {% for topic in show.showtopic.all %} - {{ topic.abbrev }} - {% endfor %} - - {% for information in show.showinformation.all %} - {{ information.abbrev }} - {% endfor %} - - {% for focus in show.musicfocus.all %} - {{ focus.abbrev }} - {% endfor %} - - {{ show.broadcastformat.abbrev }} -
- -
- {% for slot in show.programslots.all %} -
{{ slot }}
- {% endfor %} -
- -
{{ show.broadcastformat.format }}
- -
- {% for host in show.hosts.all %} -
{{ host }}
- {% endfor %} -
- - -
{{ show.description|safe }}
- - {% if show.email %} - - {% endif %} - - {% if show.website %} - - {% endif %} - - {% if show.cba_series_id %} - - {% endif %} -
- - - diff --git a/helsinki/program/templates/program/show_list.html b/helsinki/program/templates/program/show_list.html deleted file mode 100644 index 6fe6525..0000000 --- a/helsinki/program/templates/program/show_list.html +++ /dev/null @@ -1,58 +0,0 @@ - - - Show list - - - - -{% load content_boxes %} -
-{% broadcastformat %} -
-
-
-
Filter
-
-{% musicfocus %} -{% showinformation %} -{% showtopic %} -
- -
-{% for show in show_list %} -
-
  - {% for topic in show.showtopic.all %} - {{ topic.abbrev }} - {% endfor %} - - {% for information in show.showinformation.all %} - {{ information.abbrev }} - {% endfor %} - - {% for focus in show.musicfocus.all %} - {{ focus.abbrev }} - {% endfor %} - - {{ show.broadcastformat.abbrev }} -
- -
- - -
- {% for slot in show.programslots.all %} -
{{ slot }}
- {% endfor %} -
- - {% if show.short_description != 'FIXME' %} -
{{ show.short_description }}
- {% endif %} -
-
-{% endfor %} -
- - - diff --git a/helsinki/program/templates/program/timeslot_detail.html b/helsinki/program/templates/program/timeslot_detail.html deleted file mode 100644 index 04d56c2..0000000 --- a/helsinki/program/templates/program/timeslot_detail.html +++ /dev/null @@ -1,58 +0,0 @@ - - - Timeslot detail: {{ timeslot }} - - - - -
-

{{ timeslot.show.name }}

- - {% if timeslot.show.short_description != 'FIXME' %} -
{{ timeslot.show.short_description }}
- {% endif %} - -
- {% for topic in timeslot.show.showtopic.all %} - {{ topic.abbrev }} - {% endfor %} - - {% for information in timeslot.show.showinformation.all %} - {{ information.abbrev }} - {% endfor %} - - {% for focus in timeslot.show.musicfocus.all %} - {{ focus.abbrev }} - {% endfor %} - - {{ timeslot.show.broadcastformat.abbrev }} -
- -
- {% for slot in timeslot.show.programslots.all %} -
{{ slot }}
- {% endfor %} -
- -
{{ timeslot.show.broadcastformat.format }}
- -
- {% for host in timeslot.show.hosts.all %} - - {% endfor %} -
- -
{{ timeslot.show.description|safe }}
- -
- {% if timeslot.note %} -
-
{{ timeslot.note.title }}
-
{{ timeslot.note.content|safe }}
-
- {% endif %} -
-
- - - diff --git a/helsinki/program/templates/program/week_schedule.html b/helsinki/program/templates/program/week_schedule.html deleted file mode 100644 index 76aed5a..0000000 --- a/helsinki/program/templates/program/week_schedule.html +++ /dev/null @@ -1,61 +0,0 @@ - - - Week schedule - - - - - -
-
-
{{ monday|date:"l d.m.Y" }}
- {% for timeslot in monday_timeslots %} - - {% endfor %} -
- -
-
{{ tuesday|date:"l d.m.Y" }}
- {% for timeslot in tuesday_timeslots %} - - {% endfor %} -
- -
-
{{ wednesday|date:"l d.m.Y" }}
- {% for timeslot in wednesday_timeslots %} - - {% endfor %} -
- -
-
{{ thursday|date:"l d.m.Y" }}
- {% for timeslot in thursday_timeslots %} - - {% endfor %} -
- -
-
{{ friday|date:"l d.m.Y" }}
- {% for timeslot in friday_timeslots %} - - {% endfor %} -
- -
-
{{ saturday|date:"l d.m.Y" }}
- {% for timeslot in saturday_timeslots %} - - {% endfor %} -
- -
-
{{ sunday|date:"l d.m.Y" }}
- {% for timeslot in sunday_timeslots %} - - {% endfor %} -
-
- - - diff --git a/helsinki/program/templates/search/indexes/program/note_SearchableText.txt b/helsinki/program/templates/search/indexes/program/note_SearchableText.txt deleted file mode 100644 index 2421b4f..0000000 --- a/helsinki/program/templates/search/indexes/program/note_SearchableText.txt +++ /dev/null @@ -1,2 +0,0 @@ -{{ object.title }} -{{ object.content }} \ No newline at end of file diff --git a/helsinki/program/templates/search/indexes/program/note_text.txt b/helsinki/program/templates/search/indexes/program/note_text.txt deleted file mode 100644 index 2421b4f..0000000 --- a/helsinki/program/templates/search/indexes/program/note_text.txt +++ /dev/null @@ -1,2 +0,0 @@ -{{ object.title }} -{{ object.content }} \ No newline at end of file diff --git a/helsinki/program/templates/search/indexes/program/show_SearchableText.txt b/helsinki/program/templates/search/indexes/program/show_SearchableText.txt deleted file mode 100644 index f08b515..0000000 --- a/helsinki/program/templates/search/indexes/program/show_SearchableText.txt +++ /dev/null @@ -1,3 +0,0 @@ -{{ object.name }} -{{ object.description }} -{{ object.short_description }} \ No newline at end of file diff --git a/helsinki/program/templates/search/indexes/program/show_text.txt b/helsinki/program/templates/search/indexes/program/show_text.txt deleted file mode 100644 index f08b515..0000000 --- a/helsinki/program/templates/search/indexes/program/show_text.txt +++ /dev/null @@ -1,3 +0,0 @@ -{{ object.name }} -{{ object.description }} -{{ object.short_description }} \ No newline at end of file diff --git a/helsinki/program/templatetags/__init__.py b/helsinki/program/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/helsinki/program/templatetags/content_boxes.py b/helsinki/program/templatetags/content_boxes.py deleted file mode 100644 index 56c0afb..0000000 --- a/helsinki/program/templatetags/content_boxes.py +++ /dev/null @@ -1,30 +0,0 @@ -# http://docs.djangoproject.com/en/dev/howto/custom-template-tags/ - -from django import template -register = template.Library() - -from helsinki.program.models import ( - BroadcastFormat, - MusicFocus, - ShowInformation, - ShowTopic) - -@register.inclusion_tag('program/box_broadcastformat.html') -def broadcastformat(): - broadcastformats = BroadcastFormat.objects.all() - return {'broadcastformats': broadcastformats} - -@register.inclusion_tag('program/box_musicfocus.html') -def musicfocus(): - musicfoci = MusicFocus.objects.all() - return {'musicfoci': musicfoci} - -@register.inclusion_tag('program/box_showinformation.html') -def showinformation(): - showinformations = ShowInformation.objects.all() - return {'showinformations': showinformations} - -@register.inclusion_tag('program/box_showtopic.html') -def showtopic(): - showtopics = ShowTopic.objects.all() - return {'showtopics': showtopics} diff --git a/helsinki/program/urls.py b/helsinki/program/urls.py deleted file mode 100644 index f90a332..0000000 --- a/helsinki/program/urls.py +++ /dev/null @@ -1,19 +0,0 @@ -from django.conf import settings -from django.conf.urls.defaults import * -from django.contrib import admin - -import os - -admin.autodiscover() - -urlpatterns = patterns('', - (r'^admin/', include(admin.site.urls)), - (r'^program/', include('helsinki.program.urls_program')), -) -if settings.DEBUG: - urlpatterns += patterns('', - (r'^site_media/(?P.*)$', - 'django.views.static.serve', - {'document_root': os.path.join(os.path.dirname(__file__), 'site_media')} - ), - ) diff --git a/helsinki/program/urls_program.py b/helsinki/program/urls_program.py deleted file mode 100644 index a93db83..0000000 --- a/helsinki/program/urls_program.py +++ /dev/null @@ -1,35 +0,0 @@ -from django.conf.urls.defaults import * - -from django.views.generic.list_detail import object_detail, object_list - -from models import BroadcastFormat, Host, Show, TimeSlot -from views import current_show, day_schedule, recommendations, show_list, week_schedule - -host_dict = { - 'queryset': Host.objects.all(), - 'template_object_name': 'host' -} -show_dict = { - 'queryset': Show.objects.all(), - 'template_object_name': 'show' -} -timeslot_dict = { - 'queryset': TimeSlot.objects.all(), - 'template_object_name': 'timeslot' -} -recommendation_dict = {'template_name': 'program/recommendations_box.html'} - -urlpatterns = patterns('', - (r'^today/?$', day_schedule), - (r'^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/?$', day_schedule), - (r'^(?P\d{4})/(?P\d{1,2})/?$', week_schedule), - (r'^current_box/?$', current_show), - (r'^hosts/?$', object_list, host_dict), - url(r'^hosts/(?P\d+)/?$', object_detail, host_dict, name='host-detail'), - (r'^tips/?$', recommendations), - (r'^tips_box/?$', recommendations, recommendation_dict), - (r'^shows/?$', show_list), - url(r'^shows/(?P[\w-]+)/?$', object_detail, show_dict, name='show-detail'), - url(r'^(?P\d+)/?$', object_detail, timeslot_dict, name='timeslot-detail'), - (r'^week/?$', week_schedule) -) diff --git a/helsinki/program/views.py b/helsinki/program/views.py deleted file mode 100644 index a9c7b67..0000000 --- a/helsinki/program/views.py +++ /dev/null @@ -1,101 +0,0 @@ -from django.views.generic import list_detail -from django.views.generic import simple -from django.shortcuts import get_object_or_404 - -from helsinki.program.models import ( - BroadcastFormat, - MusicFocus, - Note, - Show, - ShowInformation, - ShowTopic, - TimeSlot) - -from datetime import date, datetime, time, timedelta - -def show_list(request): - - if 'broadcastformat' in request.GET: - broadcastformat = get_object_or_404(BroadcastFormat, slug=request.GET['broadcastformat']) - - queryset = Show.objects.filter(broadcastformat=broadcastformat) - elif 'musicfocus' in request.GET: - musicfocus = get_object_or_404(MusicFocus, slug=request.GET['musicfocus']) - - queryset = Show.objects.filter(musicfocus=musicfocus) - elif 'showinformation' in request.GET: - showinformation = get_object_or_404(ShowInformation, slug=request.GET['showinformation']) - - queryset = Show.objects.filter(showinformation=showinformation) - elif 'showtopic' in request.GET: - showtopic = get_object_or_404(ShowTopic, slug=request.GET['showtopic']) - - queryset = Show.objects.filter(showtopic=showtopic) - else: - queryset = Show.objects.all() - - return list_detail.object_list(request, queryset=queryset, template_object_name='show') - -def recommendations(request, template_name='program/recommendations.html'): - now = datetime.now() - in_one_week = now + timedelta(weeks=1) - - queryset = Note.objects.filter(status=1, timeslot__start__range=(now, in_one_week))[:10] - - 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') - - tomorrow = today+timedelta(days=1) - - recommendations = Note.objects.filter(status=1, timeslot__start__range=(today, tomorrow)) - - extra_context = dict(day=today, recommendations=recommendations) - - if 'broadcastformat' in request.GET: - broadcastformat = get_object_or_404(BroadcastFormat, slug=request.GET['broadcastformat']) - - extra_context['timeslots'] = TimeSlot.objects.filter(start__range=(today, tomorrow), show__broadcastformat=broadcastformat) - else: - extra_context['timeslots'] = TimeSlot.objects.filter(start__range=(today, tomorrow)) - - return simple.direct_to_template(request, extra_context=extra_context, template='program/day_schedule.html') - -def current_show(request): - current = TimeSlot.objects.get_or_create_current() - next = current.get_next_by_start() - after_next = next.get_next_by_start() - - extra_context = dict(current=current, next=next, after_next=after_next) - - return simple.direct_to_template(request, template='program/current_box.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.today(), '%Y__%W').split('__') - - monday = datetime.strptime('%s__%s__1__06__00' % (year, week), '%Y__%W__%w__%H__%M') - - 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) - next_monday = monday+timedelta(days=7) - - extra_context = dict(monday=monday, tuesday=tuesday, wednesday=wednesday, thursday=thursday, friday=friday, saturday=saturday, sunday=sunday) - - extra_context['monday_timeslots'] = TimeSlot.objects.filter(start__range=(monday, tuesday)) - extra_context['tuesday_timeslots'] = TimeSlot.objects.filter(start__range=(tuesday, wednesday)) - extra_context['wednesday_timeslots'] = TimeSlot.objects.filter(start__range=(wednesday, thursday)) - extra_context['thursday_timeslots'] = TimeSlot.objects.filter(start__range=(thursday, friday)) - extra_context['friday_timeslots'] = TimeSlot.objects.filter(start__range=(friday, saturday)) - extra_context['saturday_timeslots'] = TimeSlot.objects.filter(start__range=(saturday, sunday)) - extra_context['sunday_timeslots'] = TimeSlot.objects.filter(start__range=(sunday, next_monday)) - - return simple.direct_to_template(request, template='program/week_schedule.html', extra_context=extra_context) diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..5e78ea9 --- /dev/null +++ b/manage.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python +from django.core.management import execute_manager +try: + import settings # Assumed to be in the same directory. +except ImportError: + import sys + sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) + sys.exit(1) + +if __name__ == "__main__": + execute_manager(settings) diff --git a/program/__init__.py b/program/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/program/admin.py b/program/admin.py new file mode 100644 index 0000000..6c64dd3 --- /dev/null +++ b/program/admin.py @@ -0,0 +1,82 @@ +from django.contrib import admin + +from datetime import datetime + +from models import BroadcastFormat, MusicFocus, ShowInformation, ShowTopic, Host, Note, ProgramSlot, Show, TimeSlot + +class BroadcastFormatAdmin(admin.ModelAdmin): + list_display = ('format',) + prepopulated_fields = {'slug': ('format',)} + +class MusicFocusAdmin(admin.ModelAdmin): + list_display = ('focus', 'abbrev') + prepopulated_fields = {'slug': ('focus',)} + +class ShowInformationAdmin(admin.ModelAdmin): + list_display = ('information', 'abbrev') + prepopulated_fields = {'slug': ('information',)} + +class ShowTopicAdmin(admin.ModelAdmin): + list_display = ('topic', 'abbrev') + prepopulated_fields = {'slug': ('topic',)} + +class NoteAdmin(admin.ModelAdmin): + date_hierarchy = 'start' + list_display = ('title', 'show', 'start', 'status') + list_filter = ('status',) + ordering = ('timeslot',) + + def queryset(self, request): + qs = super(NoteAdmin, self).queryset(request) + + if request.user.is_superuser: + return qs + else: + return qs.filter(owner=request.user) + + def formfield_for_foreignkey(self, db_field, request, **kwargs): + if db_field.name == 'timeslot': + if request.user.is_superuser: + kwargs['queryset'] = TimeSlot.objects.filter(start__gt=datetime.now) + else: + shows = request.user.shows.all() + kwargs['queryset'] = TimeSlot.objects.filter(show__in=shows, start__gt=datetime.now) + + return super(NoteAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) + + def save_model(self, request, obj, form, change): + obj.owner = request.user + obj.save() + +class TimeSlotInline(admin.TabularInline): + model = TimeSlot + +class ProgramSlotAdmin(admin.ModelAdmin): + date_hierarchy = 'dstart' + inlines = (TimeSlotInline,) + list_display = ('show', 'byweekday', 'rrule', 'tstart', 'tend', 'dstart', 'until', 'timeslot_count') + list_filter = ('byweekday', 'rrule', 'is_repetition') + ordering = ('byweekday', 'dstart') + search_fields = ('show__name',) + +class ProgramSlotInline(admin.TabularInline): + model = ProgramSlot + +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',) + ordering = ('slug',) + prepopulated_fields = {'slug': ('name',)} + search_fields = ('name', 'short_description', 'description') + +admin.site.register(BroadcastFormat, BroadcastFormatAdmin) +admin.site.register(MusicFocus, MusicFocusAdmin) +admin.site.register(ShowInformation, ShowInformationAdmin) +admin.site.register(ShowTopic, ShowTopicAdmin) +admin.site.register(Note, NoteAdmin) +admin.site.register(ProgramSlot, ProgramSlotAdmin) +admin.site.register(Show, ShowAdmin) + +admin.site.register(Host) \ No newline at end of file diff --git a/program/fixtures/broadcastformats.yaml b/program/fixtures/broadcastformats.yaml new file mode 100644 index 0000000..84fa335 --- /dev/null +++ b/program/fixtures/broadcastformats.yaml @@ -0,0 +1,35 @@ +- model: program.broadcastformat + pk: 1 + fields: + format: Talk + slug: talk +- model: program.broadcastformat + pk: 2 + fields: + format: Musiksendung + slug: musiksendung +- model: program.broadcastformat + pk: 3 + fields: + format: Unmoderiertes Musikprogramm + slug: unmoderiertes-musikprogramm +- model: program.broadcastformat + pk: 4 + fields: + format: Feature/Magazin + slug: feature-magazin +- model: program.broadcastformat + pk: 5 + fields: + format: Experimentell + slug: experimentell +- model: program.broadcastformat + pk: 6 + fields: + format: Hörspiel/Literatur + slug: horspiel-literatur +- model: program.broadcastformat + pk: 7 + fields: + format: Vortrag/Diskussion + slug: vortrag-diskussion \ No newline at end of file diff --git a/program/fixtures/hosts.yaml b/program/fixtures/hosts.yaml new file mode 100644 index 0000000..4cccf3a --- /dev/null +++ b/program/fixtures/hosts.yaml @@ -0,0 +1,4 @@ +- model: program.host + pk: 1 + fields: + name: Musikredaktion diff --git a/program/fixtures/musicfocus.yaml b/program/fixtures/musicfocus.yaml new file mode 100644 index 0000000..90de149 --- /dev/null +++ b/program/fixtures/musicfocus.yaml @@ -0,0 +1,60 @@ +- model: program.musicfocus + pk: 1 + fields: + focus: Jazz + abbrev: J + slug: jazz +- model: program.musicfocus + pk: 2 + fields: + focus: Volksmusik/Folk + abbrev: V + slug: volksmusik-folk +- model: program.musicfocus + pk: 3 + fields: + focus: Experimentelle Musik + abbrev: Ex + slug: expermentelle-musik +- model: program.musicfocus + pk: 4 + fields: + focus: Rock/Indie + abbrev: R + slug: rock-indie +- model: program.musicfocus + pk: 5 + fields: + focus: Metal/Hardrock + abbrev: M + slug: metal-hardrock +- model: program.musicfocus + pk: 6 + fields: + focus: Electronic + abbrev: E + slug: electronic +- model: program.musicfocus + pk: 7 + fields: + focus: Klassik + abbrev: K + slug: klassik +- model: program.musicfocus + pk: 8 + fields: + focus: Oldies + abbrev: O + slug: oldies +- model: program.musicfocus + pk: 9 + fields: + focus: Reggae/Ska + abbrev: Re + slug: reggae-ska +- model: program.musicfocus + pk: 10 + fields: + focus: Hiphop + abbrev: H + slug: hiphop \ No newline at end of file diff --git a/program/fixtures/rrules.yaml b/program/fixtures/rrules.yaml new file mode 100644 index 0000000..4095e07 --- /dev/null +++ b/program/fixtures/rrules.yaml @@ -0,0 +1,29 @@ +- model: program.rrule + pk: 1 + fields: + name: einmalig + freq: 0 + count: 1 +- model: program.rrule + pk: 2 + fields: + name: täglich + freq: 3 +- model: program.rrule + pk: 3 + fields: + name: wöchentlich + freq: 2 + interval: 1 +- model: program.rrule + pk: 4 + fields: + name: zweiwöchentlich + freq: 2 + interval: 2 +- model: program.rrule + pk: 5 + fields: + name: vierwöchentlich + freq: 2 + interval: 4 \ No newline at end of file diff --git a/program/fixtures/showinformation.yaml b/program/fixtures/showinformation.yaml new file mode 100644 index 0000000..cbde529 --- /dev/null +++ b/program/fixtures/showinformation.yaml @@ -0,0 +1,48 @@ +- model: program.showinformation + pk: 1 + fields: + information: Interkulturell + abbrev: I + slug: interkulturell +- model: program.showinformation + pk: 2 + fields: + information: Lokalbezug + abbrev: L + slug: lokalbezug +- model: program.showinformation + pk: 3 + fields: + information: Minderheiten + abbrev: Mi + slug: minderheiten +- model: program.showinformation + pk: 4 + fields: + information: Wiederholung + abbrev: W + slug: wiederholung +- model: program.showinformation + pk: 5 + fields: + information: Mehr-/Fremdsprachig + abbrev: M + slug: mehr-fremdsprachig +- model: program.showinformation + pk: 6 + fields: + information: Frauenschwerpunkt + abbrev: F + slug: frauenschwerpunkt +- model: program.showinformation + pk: 7 + fields: + information: Österreichische Musik + abbrev: Ö + slug: osterreichische-musik +- model: program.showinformation + pk: 8 + fields: + information: Sendungsübernahme + abbrev: U + slug: sendungsubernahme \ No newline at end of file diff --git a/program/fixtures/shows.yaml b/program/fixtures/shows.yaml new file mode 100644 index 0000000..f520b26 --- /dev/null +++ b/program/fixtures/shows.yaml @@ -0,0 +1,10 @@ +- model: program.show + pk: 1 + fields: + hosts: [1] + broadcastformat: 3 + name: Musikprogramm + slug: musikprogramm + description: Unmoderiertes Musikprogramm + short_description: Unmoderiertes Musikprogramm + email: musikredaktion@helsinki.at diff --git a/program/fixtures/showtopics.yaml b/program/fixtures/showtopics.yaml new file mode 100644 index 0000000..8f12508 --- /dev/null +++ b/program/fixtures/showtopics.yaml @@ -0,0 +1,30 @@ +- model: program.showtopic + pk: 1 + fields: + topic: Politik/Gesellschaft + abbrev: P + slug: politik-gesellschaft +- model: program.showtopic + pk: 2 + fields: + topic: Natur/Klima/Tiere + abbrev: N + slug: natur-klima-tiere +- model: program.showtopic + pk: 3 + fields: + topic: Kultur/Kunst + abbrev: K + slug: kultur-kunst +- model: program.showtopic + pk: 4 + fields: + topic: Soziales + abbrev: S + slug: soziales +- model: program.showtopic + pk: 5 + fields: + topic: Wissenschaft/Philosophie + abbrev: W + slug: wissenschaft-philosophie \ No newline at end of file diff --git a/program/management/__init__.py b/program/management/__init__.py new file mode 100644 index 0000000..3aa4ca5 --- /dev/null +++ b/program/management/__init__.py @@ -0,0 +1,2 @@ +__author__ = 'ers' + \ No newline at end of file diff --git a/program/management/commands/__init__.py b/program/management/commands/__init__.py new file mode 100644 index 0000000..3aa4ca5 --- /dev/null +++ b/program/management/commands/__init__.py @@ -0,0 +1,2 @@ +__author__ = 'ers' + \ No newline at end of file diff --git a/program/management/commands/importhosts.py b/program/management/commands/importhosts.py new file mode 100644 index 0000000..a2abbd3 --- /dev/null +++ b/program/management/commands/importhosts.py @@ -0,0 +1,34 @@ +from django.core.management.base import NoArgsCommand + +import MySQLdb + +from models import Host + +USER = 'helsinki' +PASSWD = 'helsinki' +DB = 'helsinki' + +class Command(NoArgsCommand): + help = 'Import hosts from current program' + + def handle_noargs(self, **options): + connection = MySQLdb.connect(user=USER, passwd=PASSWD, db=DB) + cursor = connection.cursor() + + cursor.execute("""SELECT DISTINCT macher +FROM sendungen +WHERE letzter_termin > current_date AND macher != '' AND titel NOT LIKE 'Musikprogramm'""") + + counter = 0 + + for row in cursor.fetchall(): + for macher in row[0].split(','): + host = Host(name=macher.strip()) + host.save() + + counter += 1 + + cursor.close() + connection.close() + + print '%i hosts imported' % counter diff --git a/program/management/commands/importnotes.py b/program/management/commands/importnotes.py new file mode 100644 index 0000000..48e047c --- /dev/null +++ b/program/management/commands/importnotes.py @@ -0,0 +1,62 @@ +from django.contrib.auth.models import User +from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned +from django.core.management.base import NoArgsCommand +from django.utils.html import clean_html, strip_tags + +import MySQLdb + +from models import Note, Show, TimeSlot + +USER = 'helsinki' +PASSWD = 'helsinki' +DB = 'helsinki' + +OWNER = User.objects.get(pk=1) + +class Command(NoArgsCommand): + help = 'Import notes from current program' + + def handle_noargs(self, **options): + connection = MySQLdb.connect(user=USER, passwd=PASSWD, db=DB) + cursor = connection.cursor() + + cursor.execute("""SELECT n.titel, n.datum, s.titel, n.notiz +FROM notizen AS n JOIN sendungen AS s ON n.sendung_id=s.id +WHERE n.sendung_id in (SELECT id FROM sendungen WHERE letzter_termin > current_date) AND n.titel != ''""") + + counter = 0 + for ntitel, datum, stitel, notiz in cursor.fetchall(): + ntitel = strip_tags(ntitel) + stitel = strip_tags(stitel) + notiz = clean_html(notiz) + + if stitel.endswith('(Wiederholung)'): + stitel = stitel[:-15] + + if datum: + year, month, day = datum.year, datum.month, datum.day + try: + show = Show.objects.get(name=stitel) + + try: + 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: + print 'multiple timeslots found for sendung "%s" and datum "%s"' % (stitel, datum) + else: + note = Note(timeslot=timeslot, owner=OWNER, title=ntitel, content=notiz) + + try: + note.save() + except: + print 'could not save note "%s" for show "%s" and datum "%s"' % (ntitel, stitel, datum) + else: + counter += 1 + except ObjectDoesNotExist: + print 'show with name "%s" not found' % stitel + + cursor.close() + connection.close() + + print '%i notes imported' % counter diff --git a/program/management/commands/importprogramslots.py b/program/management/commands/importprogramslots.py new file mode 100644 index 0000000..86e3038 --- /dev/null +++ b/program/management/commands/importprogramslots.py @@ -0,0 +1,96 @@ +from django.core.exceptions import ObjectDoesNotExist +from django.core.management.base import NoArgsCommand +from django.utils.html import strip_tags + +from datetime import time +import MySQLdb + +from models import Show, ProgramSlot, RRule + +USER = 'helsinki' +PASSWD = 'helsinki' +DB = 'helsinki' + +RRULES = { + 0: RRule.objects.get(pk=1), + 7: RRule.objects.get(pk=3), + 14: RRule.objects.get(pk=4), + 28: RRule.objects.get(pk=5) +} + +class Command(NoArgsCommand): + help = 'Import programslots from the current program' + + def handle_noargs(self, **options): + connection = MySQLdb.connect(user=USER, passwd=PASSWD, db=DB) + cursor = connection.cursor() + + cursor.execute("""SELECT titel, beginn, ende, erster_termin, letzter_termin, rhytmus, termin +FROM sendungen +WHERE letzter_termin > current_date AND titel NOT LIKE 'Musikprogramm' AND titel NOT LIKE '%%(Wiederholung)'""") + + counter = 0 + + for titel, beginn, ende, erster_termin, letzter_termin, rhytmus, termin in cursor.fetchall(): + titel = strip_tags(titel) + + hours, seconds = divmod(beginn.seconds, 3600) + minutes, seconds = divmod(seconds, 60) + tstart = time(hour=hours, minute=minutes, second=seconds) + + hours, seconds = divmod(ende.seconds, 3600) + minutes, seconds = divmod(seconds, 60) + tend = time(hour=hours, minute=minutes, second=seconds) + + try: + rrule = RRULES[rhytmus] + try: + show = Show.objects.get(name=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) + try: + programslot.save() + counter += 1 + except: + pass + except KeyError: + print 'rhythmus "%i" is not supported for sendung "%s"' % (rhytmus, titel) + + cursor.execute("""SELECT titel, beginn, ende, erster_termin, letzter_termin, rhytmus, termin +FROM sendungen +WHERE letzter_termin > current_date AND titel LIKE '%%(Wiederholung)'""") + + for titel, beginn, ende, erster_termin, letzter_termin, rhytmus, termin in cursor.fetchall(): + titel = strip_tags(titel[:-15]) + + hours, seconds = divmod(beginn.seconds, 3600) + minutes, seconds = divmod(seconds, 60) + tstart = time(hour=hours, minute=minutes, second=seconds) + + hours, seconds = divmod(ende.seconds, 3600) + minutes, seconds = divmod(seconds, 60) + tend = time(hour=hours, minute=minutes, second=seconds) + + try: + rrule = RRULES[rhytmus] + try: + show = Show.objects.get(name=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, is_repetition=True) + try: + programslot.save() + counter += 1 + except: + pass + except KeyError: + print 'rhythmus "%i" is not supported for sendung "%s"' % (rhytmus, titel) + + cursor.close() + connection.close() + + print '%i programslots imported' % counter diff --git a/program/management/commands/importshows.py b/program/management/commands/importshows.py new file mode 100644 index 0000000..0f619b5 --- /dev/null +++ b/program/management/commands/importshows.py @@ -0,0 +1,67 @@ +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 + +import MySQLdb + +from models import BroadcastFormat, Host, Show + +USER = 'helsinki' +PASSWD = 'helsinki' +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() + + cursor.execute("""SELECT titel, beschreibung, web, macher +FROM sendungen +WHERE letzter_termin > current_date AND titel NOT LIKE 'Musikprogramm' AND titel NOT LIKE '%%(Wiederholung)' +ORDER BY titel, beginn, ende""") + + counter = 0 + + for titel, beschreibung, web, macher in cursor.fetchall(): + titel = strip_tags(titel) + beschreibung = clean_html(beschreibung) + + slug = slugify(titel) + + hosts = [] + + for macher in macher.split(','): + macher = macher.strip() + try: + host = Host.objects.get(name=macher) + except MultipleObjectsReturned: + print 'multiple hosts with name "%s" found' % macher + except ObjectDoesNotExist: + print 'host with name "%s" not found' % macher + else: + hosts.append(host) + + try: + 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) + try: + show.save() + counter += 1 + except: + print 'sendung "%s" could not be imported' % titel + else: + for h in hosts: + show.hosts.add(h) + show.save() + + cursor.close() + connection.close() + + print '%i shows imported' % counter diff --git a/program/models.py b/program/models.py new file mode 100644 index 0000000..5f0f835 --- /dev/null +++ b/program/models.py @@ -0,0 +1,297 @@ +from django.contrib.auth.models import User +from django.core.exceptions import ObjectDoesNotExist +from django.db import models +from django.utils.translation import ugettext_lazy as _ + +from datetime import date, datetime +from dateutil.relativedelta import relativedelta +from dateutil.rrule import rrule + +class BroadcastFormat(models.Model): + format = models.CharField(_("Format"), max_length=32) + slug = models.SlugField(_("Slug"), max_length=32, unique=True) + + class Meta: + ordering = ('format',) + verbose_name = _("Broadcast format") + verbose_name_plural = _("Broadcast formats") + + 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) + + class Meta: + ordering = ('information',) + verbose_name = _("Show information") + verbose_name_plural = _("Show information") + + 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) + + class Meta: + ordering = ('topic',) + verbose_name = _("Show topic") + verbose_name_plural = _("Show topics") + + 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) + + class Meta: + ordering = ('focus',) + verbose_name = _("Music focus") + verbose_name_plural = _("Music focus") + + 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") + + def __unicode__(self): + return u'%s' % self.name + + @models.permalink + 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")) + name = models.CharField(_("Name"), max_length=256) + slug = models.CharField(_("Slug"), max_length=255, unique=True) + image = models.ImageField(_("Image"), blank=True, null=True, upload_to='show_images') + short_description = models.CharField(_("Short description"), max_length=64) + description = models.TextField(_("Description")) + 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) + created = models.DateTimeField(auto_now_add=True, editable=False) + last_updated = models.DateTimeField(auto_now=True, editable=False) + + class Meta: + ordering = ('slug',) + verbose_name = _("Show") + verbose_name_plural = _("Shows") + + def __unicode__(self): + return u'%s' % self.name + + @models.permalink + def get_absolute_url(self): + return ('show-detail', [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 = ( + (1, _("Monthly")), + (2, _("Weekly")), + (3, _("Daily")), + ) + BYSETPOS_CHOICES = ( + (1, _("First")), + (2, _("Second")), + (3, _("Third")), + (4, _("Fourth")), + (5, _("Fifth")), + (-1, _("Last")), + ) + 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) + count = models.IntegerField(_("Count"), blank=True, null=True) + + class Meta: + ordering = ('-freq', 'interval', 'bysetpos') + verbose_name = _("Recurrence rule") + verbose_name_plural = _("Recurrence rules") + + def __unicode__(self): + return u'%s' % self.name + +class ProgramSlot(models.Model): + BYWEEKDAY_CHOICES = ( + (0, _("Monday")), + (1, _("Tuesday")), + (2, _("Wednesday")), + (3, _("Thursday")), + (4, _("Friday")), + (5, _("Saturday")), + (6, _("Sunday")), + ) + 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")) + 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) + created = models.DateTimeField(auto_now_add=True, editable=False) + last_updated = models.DateTimeField(auto_now=True, editable=False) + + class Meta: + ordering = ('dstart', 'tstart') + unique_together = ('rrule', 'byweekday', 'dstart', 'tstart') + verbose_name = _("Program slot") + verbose_name_plural = _("Program slots") + + def __unicode__(self): + weekday = self.BYWEEKDAY_CHOICES[self.byweekday][1] + tend = self.tend.strftime('%H:%M') + dstart = self.dstart.strftime('%d. %b %Y') + tstart = self.tstart.strftime('%H:%M') + + if self.rrule.freq == 0: + return u'%s, %s - %s' % (dstart, tstart, tend) + if self.rrule.freq == 3: + return u'%s, %s - %s' % (self.rrule, tstart, tend) + else: + return u'%s, %s, %s - %s' % (weekday, self.rrule, tstart, tend) + + def save(self, *args, **kwargs): + if not self.pk: + super(ProgramSlot, self).save(*args, **kwargs) + + if self.rrule.freq == 0: + byweekday_start = None + byweekday_end = None + elif self.rrule.freq == 3: + byweekday_start = (0, 1, 2, 3, 4, 5, 6) + byweekday_end = (0, 1, 2, 3, 4, 5, 6) + else: + byweekday_start = self.byweekday + + if self.tend < self.tstart: + byweekday_end = self.byweekday + 1 if self.byweekday < 6 else 0 + else: + byweekday_end = self.byweekday + + 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)) + ends = list(rrule(freq=self.rrule.freq, + dtstart=datetime.combine(self.dstart, self.tend), + interval=self.rrule.interval, + until=self.until+relativedelta(days=+1), + bysetpos=self.rrule.bysetpos, + byweekday=byweekday_end)) + + for k in range(len(starts)): + timeslot = TimeSlot(programslot=self, start=starts[k], end=ends[k]) + timeslot.save() + + def timeslot_count(self): + return self.timeslots.count() + timeslot_count.description = _("Time slot count") + +class TimeSlotManager(models.Manager): + def get_or_create_current(self): + try: + return TimeSlot.objects.get(start__lte=datetime.now(), end__gt=datetime.now()) + except ObjectDoesNotExist: + once = RRule.objects.get(pk=1) + 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] + + 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.save() + + return new_programslot.timeslots.all()[0] + +class TimeSlot(models.Model): + 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) + + objects = TimeSlotManager() + + class Meta: + ordering = ('start', 'end') + verbose_name = _("Time slot") + verbose_name_plural = _("Time slots") + + def __unicode__(self): + start = self.start.strftime('%d. %b %Y %H:%M') + end = self.end.strftime('%H:%M') + + return u'%s: %s - %s' % (self.show, start, end) + + def save(self, *args, **kwargs): + self.show = self.programslot.show + super(TimeSlot, self).save(*args, **kwargs) + + @models.permalink + def get_absolute_url(self): + return ('timeslot-detail', [self.id]) + +class Note(models.Model): + STATUS_CHOICES = ( + (0, _("Cancellation")), + (1, _("Recommendation")), + (2, _("Repetition")), + ) + timeslot = models.OneToOneField(TimeSlot, verbose_name=_("Time slot")) + owner = models.ForeignKey(User, related_name='notes', verbose_name=_("Owner")) + title = models.CharField(_("Title"), max_length=128) + content = models.TextField(_("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) + created = models.DateTimeField(auto_now_add=True, editable=False) + last_updated = models.DateTimeField(auto_now=True, editable=False) + + class Meta: + ordering = ('timeslot',) + verbose_name = _("Note") + verbose_name_plural = _("Notes") + + def __unicode__(self): + return u'%s - %s' % (self.title, self.timeslot) + + def save(self, *args, **kwargs): + self.start = self.timeslot.start + self.show = self.timeslot.programslot.show + + super(Note, self).save(*args, **kwargs) diff --git a/program/search_indexes.py b/program/search_indexes.py new file mode 100644 index 0000000..4b0cf74 --- /dev/null +++ b/program/search_indexes.py @@ -0,0 +1,13 @@ +from haystack.indexes import CharField, SearchIndex +from haystack import site + +from models import Note, Show + +class NoteIndex(SearchIndex): + SearchableText = CharField(document=True, use_template=True) + +class ShowIndex(SearchIndex): + SearchableText = CharField(document=True, use_template=True) + +site.register(Note, NoteIndex) +site.register(Show, ShowIndex) diff --git a/program/templatetags/__init__.py b/program/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/program/templatetags/content_boxes.py b/program/templatetags/content_boxes.py new file mode 100644 index 0000000..7108c5a --- /dev/null +++ b/program/templatetags/content_boxes.py @@ -0,0 +1,26 @@ +# 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.inclusion_tag('program/boxes/broadcastformat.html') +def broadcastformat(): + broadcastformats = BroadcastFormat.objects.all() + return {'broadcastformats': broadcastformats} + +@register.inclusion_tag('program/boxes/musicfocus.html') +def musicfocus(): + musicfoci = MusicFocus.objects.all() + return {'musicfoci': musicfoci} + +@register.inclusion_tag('program/boxes/showinformation.html') +def showinformation(): + showinformations = ShowInformation.objects.all() + return {'showinformations': showinformations} + +@register.inclusion_tag('program/boxes/showtopic.html') +def showtopic(): + showtopics = ShowTopic.objects.all() + return {'showtopics': showtopics} diff --git a/program/urls.py b/program/urls.py new file mode 100644 index 0000000..b9df496 --- /dev/null +++ b/program/urls.py @@ -0,0 +1,35 @@ +from django.conf.urls.defaults import patterns, url + +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 + +hosts_dict = { + 'queryset': Host.objects.all(), + 'template_object_name': 'host' +} +shows_dict = { + 'queryset': Show.objects.all(), + 'template_object_name': 'show' +} +timeslots_dict = { + 'queryset': TimeSlot.objects.all(), + 'template_object_name': 'timeslot' +} +recommendations_dict = {'template_name': 'program/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/?$', current_show), + url(r'^hosts/?$', object_list, hosts_dict), + url(r'^hosts/(?P\d+)/?$', object_detail, hosts_dict, 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, shows_dict, name='show-detail'), + url(r'^(?P\d+)/?$', object_detail, timeslots_dict, name='timeslot-detail'), + url(r'^week/?$', week_schedule) +) diff --git a/program/views.py b/program/views.py new file mode 100644 index 0000000..59e8fdf --- /dev/null +++ b/program/views.py @@ -0,0 +1,92 @@ +from django.views.generic import list_detail, simple +from django.shortcuts import get_object_or_404 + +from models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, ShowTopic, TimeSlot + +from datetime import date, datetime, time, timedelta + +def show_list(request): + if 'broadcastformat' in request.GET: + broadcastformat = get_object_or_404(BroadcastFormat, slug=request.GET['broadcastformat']) + + queryset = Show.objects.filter(broadcastformat=broadcastformat) + elif 'musicfocus' in request.GET: + musicfocus = get_object_or_404(MusicFocus, slug=request.GET['musicfocus']) + + queryset = Show.objects.filter(musicfocus=musicfocus) + elif 'showinformation' in request.GET: + showinformation = get_object_or_404(ShowInformation, slug=request.GET['showinformation']) + + queryset = Show.objects.filter(showinformation=showinformation) + elif 'showtopic' in request.GET: + showtopic = get_object_or_404(ShowTopic, slug=request.GET['showtopic']) + + queryset = Show.objects.filter(showtopic=showtopic) + else: + queryset = Show.objects.all() + + return list_detail.object_list(request, queryset=queryset, template_object_name='show') + +def recommendations(request, template_name='program/recommendations.html'): + now = datetime.now() + in_one_week = now + timedelta(weeks=1) + + queryset = Note.objects.filter(status=1, timeslot__start__range=(now, in_one_week))[:10] + + 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') + + tomorrow = today+timedelta(days=1) + + recommendations = Note.objects.filter(status=1, timeslot__start__range=(today, tomorrow)) + + extra_context = dict(day=today, recommendations=recommendations) + + if 'broadcastformat' in request.GET: + broadcastformat = get_object_or_404(BroadcastFormat, slug=request.GET['broadcastformat']) + + extra_context['timeslots'] = TimeSlot.objects.filter(start__range=(today, tomorrow), show__broadcastformat=broadcastformat) + else: + extra_context['timeslots'] = TimeSlot.objects.filter(start__range=(today, tomorrow)) + + return simple.direct_to_template(request, extra_context=extra_context, template='program/day_schedule.html') + +def current_show(request): + current = TimeSlot.objects.get_or_create_current() + next = current.get_next_by_start() + after_next = next.get_next_by_start() + + extra_context = dict(current=current, next=next, after_next=after_next) + + return simple.direct_to_template(request, template='program/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.today(), '%Y__%W').split('__') + + monday = datetime.strptime('%s__%s__1__06__00' % (year, week), '%Y__%W__%w__%H__%M') + + 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) + next_monday = monday+timedelta(days=7) + + extra_context = dict(monday=monday, tuesday=tuesday, wednesday=wednesday, thursday=thursday, friday=friday, saturday=saturday, sunday=sunday) + + extra_context['monday_timeslots'] = TimeSlot.objects.filter(start__range=(monday, tuesday)) + extra_context['tuesday_timeslots'] = TimeSlot.objects.filter(start__range=(tuesday, wednesday)) + extra_context['wednesday_timeslots'] = TimeSlot.objects.filter(start__range=(wednesday, thursday)) + extra_context['thursday_timeslots'] = TimeSlot.objects.filter(start__range=(thursday, friday)) + extra_context['friday_timeslots'] = TimeSlot.objects.filter(start__range=(friday, saturday)) + extra_context['saturday_timeslots'] = TimeSlot.objects.filter(start__range=(saturday, sunday)) + extra_context['sunday_timeslots'] = TimeSlot.objects.filter(start__range=(sunday, next_monday)) + + return simple.direct_to_template(request, template='program/week_schedule.html', extra_context=extra_context) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..32201d5 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,7 @@ +Django==1.2.5 +MySQL-python==1.2.3 +PIL==1.1.7 +PyYAML==3.09 +django-haystack==1.1.0 +pysolr==2.0.13 +python-dateutil==1.5 diff --git a/search_sites.py b/search_sites.py new file mode 100644 index 0000000..e8d4e13 --- /dev/null +++ b/search_sites.py @@ -0,0 +1,2 @@ +import haystack +haystack.autodiscover() diff --git a/settings.py b/settings.py new file mode 100644 index 0000000..a48b53e --- /dev/null +++ b/settings.py @@ -0,0 +1,75 @@ +# Django settings for helsinki project. + +import os.path +PROJECT_DIR = os.path.dirname(__file__) + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +ADMINS = ( ) + +MANAGERS = ADMINS + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(PROJECT_DIR, 'dev_data.sqlite'), + } +} + +TIME_ZONE = 'Europe/Vienna' + +LANGUAGE_CODE = 'de' + +SITE_ID = 1 + +USE_I18N = True +USE_L10N = True + +MEDIA_ROOT = '' +MEDIA_URL = '' + +ADMIN_MEDIA_PREFIX = '/media/' + +SECRET_KEY = '' + +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', +# 'django.template.loaders.eggs.Loader', +) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', +) + +ROOT_URLCONF = 'helsinki.urls' + +TEMPLATE_DIRS = ( + os.path.join(PROJECT_DIR, "templates"), +) + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.messages', + 'django.contrib.admin', + 'program', + 'haystack', +) + +HAYSTACK_SITECONF = 'helsinki.search_sites' +HAYSTACK_SEARCH_ENGINE = 'solr' +HAYSTACK_SOLR_URL = 'http://localhost:8988/solr' +HAYSTACK_ID_FIELD = 'docid' + +try: + from local_settings import * +except ImportError: + pass diff --git a/setup.py b/setup.py deleted file mode 100644 index 767fcc2..0000000 --- a/setup.py +++ /dev/null @@ -1,35 +0,0 @@ -from setuptools import setup, find_packages -import os - -version = '0.1' - -setup(name='helsinki.program', - version=version, - description="Program Management for Radio Helsinki, Graz", - long_description=open("README.rst").read() + "\n" + - open(os.path.join("docs", "CHANGES.rst")).read(), - # Get more strings from http://www.python.org/pypi?:action=list_classifiers - classifiers=[ - "Programming Language :: Python", - "Topic :: Software Development :: Libraries :: Python Modules", - ], - keywords='django radio', - author='Ernesto Rico-Schmidt', - author_email='', - url='https://github.com/nnrcschmdt/helsinki/', - license='GPL', - packages=find_packages(exclude=['ez_setup']), - namespace_packages=['helsinki',], - include_package_data=True, - zip_safe=False, - install_requires=[ - 'setuptools', - # -*- Extra requirements: -*- - 'Django', - 'python-dateutil', - 'PyYAML', - 'MySQL-python', - 'django-haystack', - 'pysolr' - ], -) diff --git a/site_media/styles/base.css b/site_media/styles/base.css new file mode 100644 index 0000000..51194b1 --- /dev/null +++ b/site_media/styles/base.css @@ -0,0 +1,152 @@ +#recommendations-box, +#day-schedule, +#broadcastformats, +#filter, +#shows { + display: inline; + float: left; +} + +#filter { width: 213px; } +#recommendations-box { width: 213px; } +#day-schedule { width: 700px; } +#shows {width: 700px;} +#broadcastformats { width: 170px; } +#current-timeslot, +#next-timeslot, +#after-next-timeslot { + clear: both; +} + +#current-timeslot .start, +#next-timeslot .start, +#after-next-timeslot .start { + display: inline; + float: left; +} + +#current-timeslot .show, +#next-timeslot .show, +#after-next-timeslot .show { + display: inline; + float: left; +} + +/* FIXME: fill the actual colors */ +#current-timeslot .experimentell, +#next-timeslot .experimentell, +#after-next-timeslot .experimentell, +#recommendations-box .experimentell { + border-left: red solid 3px; +} +#current-timeslot .feature-magazin, +#next-timeslot .feature-magazin, +#after-next-timeslot .feature-magazin, +#recommendations-box .feature-magazin { + border-left: red solid 3px; +} +#current-timeslot .horspiel-literatur, +#next-timeslot .horspiel-literatur, +#after-next-timeslot .horspiel-literatur, +#recommendations-box .horspiel-literatur { + border-left: red solid 3px; +} +#current-timeslot .musiksendung, +#next-timeslot .musiksendung, +#after-next-timeslot .musiksendung, +#recommendations-box .musiksendung { + border-left: red solid 3px; +} +#current-timeslot .talk, +#next-timeslot .talk, +#after-next-timeslot .talk, +#recommendations-box .talk { + border-left: red solid 3px; +} +#current-timeslot .unmoderiertes-musikprogramm, +#next-timeslot .unmoderiertes-musikprogramm, +#after-next-timeslot .unmoderiertes-musikprogramm, +#recommendations-box .unmoderiertes-musikprogramm { + border-left: red solid 3px; +} +#current-timeslot .vortrag-diskussion, +#next-timeslot .vortrag-diskussion, +#after-next-timeslot .vortrag-diskussion, +#recommendations-box .vortrag-diskussion { + border-left: red solid 3px; +} + +#recommendations-box .recommendation { + clear: both; +} + +/* FIXME: fill the actual colors */ +#day-schedule .experimentell { + background-color: red; +} +#day-schedule .feature-magazin { + background-color: red; +} +#day-schedule .horspiel-literatur { + background-color: red; +} +#day-schedule .musiksendung { + background-color: red; +} +#day-schedule .talk { + background-color: red; +} +#day-schedule .unmoderiertes-musikprogramm { + background-color: red; +} +#day-schedule .vortrag-diskussion { + background-color: red; +} + +#day-schedule .timeslot { + clear: both; +} + +.timeslot .start, +.timeslot .show-abbrevs, +.timeslot .show { + display: inline; + float: left; +} + +.timeslot .show-abbrevs { width: 50px; } + +#shows .show { clear: both; } + +.show .abbrevs { + width: 50px; + display: inline; + float: left; +} +.show .details { + display: inline; + float: left; +} + +.details .name, +.details .programslots, +.details .short-description { + display: inline; + float: left; +} + +#week-schedule { width: 960px; } +#week-schedule .weekday { font-size: small; height: 2em; } + +#monday, +#tuesday, +#wednesday, +#thursday, +#friday, +#saturday, +#sunday { + display: inline; + float: left; + font-size: small; + width: 123px; +} diff --git a/templates/404.html b/templates/404.html new file mode 100644 index 0000000..6281ba0 --- /dev/null +++ b/templates/404.html @@ -0,0 +1,7 @@ +{% extends "base.html" %} + +{% block title %}Seite nicht gefunden{% endblock %} + +{% block content %} +

Es tut uns leid, aber die angeforderte Seite konnte nicht gefunden werden.

+{% endblock %} \ No newline at end of file diff --git a/templates/500.html b/templates/500.html new file mode 100644 index 0000000..98074ab --- /dev/null +++ b/templates/500.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} + +{% block title %}Serverfehler{% endblock %} + +{% block content %} +

+ Ein Fehler ist aufgetreten. + Dieser Fehler wurde an die Serververwalter per E-Mail gemeldet und sollte in Kürze behoben sein. + Vielen Dank für Ihr Verständnis. +

+{% endblock %} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..2ed539e --- /dev/null +++ b/templates/base.html @@ -0,0 +1,11 @@ + + + + {% block title %}{% endblock %} + + + +{% block content %}{% endblock %} + + + \ No newline at end of file diff --git a/templates/program/boxes/broadcastformat.html b/templates/program/boxes/broadcastformat.html new file mode 100644 index 0000000..3ae00e1 --- /dev/null +++ b/templates/program/boxes/broadcastformat.html @@ -0,0 +1,10 @@ +{% if broadcastformats %} +
+
Legende
+ {% for broadcastformat in broadcastformats %} +
+ {{ broadcastformat.format }} +
+ {% endfor %} +
+{% endif %} diff --git a/templates/program/boxes/current.html b/templates/program/boxes/current.html new file mode 100644 index 0000000..a2341d3 --- /dev/null +++ b/templates/program/boxes/current.html @@ -0,0 +1,42 @@ + + + + + Current program box + + + + + {% if current or next or after_next %} +
+
Programm derzeit
+
+
{{ current.start|date:"H:i" }}
+
+ + {% if current.note %} +
{{ current.note.title }}
+ {% else %} + {% if current.show.short_description != 'FIXME' %} +
{{ current.show.short_description }}
+ {% endif %} + {% endif %} +
+
+
+
{{ next.start|date:"H:i" }}
+ +
+
+
{{ after_next.start|date:"H:i" }}
+ +
+
+ {% endif %} + + + diff --git a/templates/program/boxes/musicfocus.html b/templates/program/boxes/musicfocus.html new file mode 100644 index 0000000..7b78f81 --- /dev/null +++ b/templates/program/boxes/musicfocus.html @@ -0,0 +1,14 @@ +{% if musicfoci %} +
+
Musiktendenz
+
+
    + {% for item in musicfoci %} +
  • + {{ item }} +
  • + {% endfor %} +
+
+
+{% endif %} diff --git a/templates/program/boxes/recommendations.html b/templates/program/boxes/recommendations.html new file mode 100644 index 0000000..abcbe03 --- /dev/null +++ b/templates/program/boxes/recommendations.html @@ -0,0 +1,22 @@ + + + + + Recomendations box + + + + {% if recommendation_list %} +
+
Programmhinweise
+ {% for recommendation in recommendation_list %} +
+

{{ recommendation.show.name }}

+

{{ recommendation.timeslot.start|date:"d.m. H:i" }}-{{ recommendation.timeslot.end|date:"H:i" }}

+

{{ recommendation.title }}

+
+ {% endfor %} +
+ {% endif %} + + diff --git a/templates/program/boxes/showinformation.html b/templates/program/boxes/showinformation.html new file mode 100644 index 0000000..bff9486 --- /dev/null +++ b/templates/program/boxes/showinformation.html @@ -0,0 +1,14 @@ +{% if showinformations %} +
+
Sendungsinfo
+
+
    + {% for item in showinformations %} +
  • + {{ item }} +
  • + {% endfor %} +
+
+
+{% endif %} diff --git a/templates/program/boxes/showtopic.html b/templates/program/boxes/showtopic.html new file mode 100644 index 0000000..b545476 --- /dev/null +++ b/templates/program/boxes/showtopic.html @@ -0,0 +1,14 @@ +{% if showtopics %} +
+
Thema / Schwerpunkt
+
+
    + {% for item in showtopics %} +
  • + {{ item }} +
  • + {% endfor %} +
+
+
+{% endif %} diff --git a/templates/program/day_schedule.html b/templates/program/day_schedule.html new file mode 100644 index 0000000..a0e1ac4 --- /dev/null +++ b/templates/program/day_schedule.html @@ -0,0 +1,60 @@ + + + Day schedule: {{ day|date:"l, d.m.Y" }} + + + + + +
+ +{% load content_boxes %} +
+{% broadcastformat %} +
+
+
+
Filter
+
+{% musicfocus %} +{% showinformation %} +{% showtopic %} +
+ +
+

Tagesansicht

+

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

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

{{ timeslot.show.name }}

+ {% if timeslot.note %} +

Heute: {{ timeslot.note.title }}

+ {% else %} + {% if timeslot.show.short_description != 'FIXME' %} +

{{ timeslot.show.short_description }}

+ {% endif %} + {% endif %} +
+
+ {% endfor %} +
+
+ + + + diff --git a/templates/program/host_detail.html b/templates/program/host_detail.html new file mode 100644 index 0000000..d28f582 --- /dev/null +++ b/templates/program/host_detail.html @@ -0,0 +1,29 @@ + + + Host detail: {{ host.name }} + + + + +
+
{{ host.name }}
+ +
+
Sendungen
+ + {% for show in host.shows.all %} + + {% endfor %} +
+ + {% if host.email %} +
E-Mail Adresse: {{ host.email }}
+ {% endif %} + + {% if host.website %} + + {% endif %} +
+ + + diff --git a/templates/program/host_list.html b/templates/program/host_list.html new file mode 100644 index 0000000..9b83b29 --- /dev/null +++ b/templates/program/host_list.html @@ -0,0 +1,17 @@ + + + Host list + + + + +
+{% for host in host_list %} + +{% endfor %} +
+ + + diff --git a/templates/program/recommendations.html b/templates/program/recommendations.html new file mode 100644 index 0000000..85ec16e --- /dev/null +++ b/templates/program/recommendations.html @@ -0,0 +1,24 @@ + + + Recomendations + + + + +
+
Programmhinweise
+{% for recommendation in recommendation_list %} +
+
{{ recommendation.timeslot.start|date:"d.m. H:i" }}-{{ recommendation.timeslot.end|date:"H:i" }}
+ + {% if recommendation.show.short_description != 'FIXME' %} +
{{ recommendation.show.short_description }}
+ {% endif %} + +
{{ recommendation.content|safe}}
+
+{% endfor %} +
+ + + diff --git a/templates/program/show_detail.html b/templates/program/show_detail.html new file mode 100644 index 0000000..7614496 --- /dev/null +++ b/templates/program/show_detail.html @@ -0,0 +1,63 @@ + + + Show detail: {{ show.name }} + + + +
+ +
+ +

{{ show.name }}

+ + {% if show.short_description != 'FIXME' %} +
{{ show.short_description }}
+ {% endif %} + +
+ {% for topic in show.showtopic.all %} + {{ topic.abbrev }} + {% endfor %} + + {% for information in show.showinformation.all %} + {{ information.abbrev }} + {% endfor %} + + {% for focus in show.musicfocus.all %} + {{ focus.abbrev }} + {% endfor %} + + {{ show.broadcastformat.abbrev }} +
+ +
+ {% for slot in show.programslots.all %} +
{{ slot }}
+ {% endfor %} +
+ +
{{ show.broadcastformat.format }}
+ +
+ {% for host in show.hosts.all %} + + {% endfor %} +
+ +
{{ show.description|safe }}
+ + {% if show.email %} + + {% endif %} + + {% if show.website %} + + {% endif %} + + {% if show.cba_series_id %} + + {% endif %} +
+ + + diff --git a/templates/program/show_list.html b/templates/program/show_list.html new file mode 100644 index 0000000..6fe6525 --- /dev/null +++ b/templates/program/show_list.html @@ -0,0 +1,58 @@ + + + Show list + + + + +{% load content_boxes %} +
+{% broadcastformat %} +
+
+
+
Filter
+
+{% musicfocus %} +{% showinformation %} +{% showtopic %} +
+ +
+{% for show in show_list %} +
+
  + {% for topic in show.showtopic.all %} + {{ topic.abbrev }} + {% endfor %} + + {% for information in show.showinformation.all %} + {{ information.abbrev }} + {% endfor %} + + {% for focus in show.musicfocus.all %} + {{ focus.abbrev }} + {% endfor %} + + {{ show.broadcastformat.abbrev }} +
+ +
+ + +
+ {% for slot in show.programslots.all %} +
{{ slot }}
+ {% endfor %} +
+ + {% if show.short_description != 'FIXME' %} +
{{ show.short_description }}
+ {% endif %} +
+
+{% endfor %} +
+ + + diff --git a/templates/program/timeslot_detail.html b/templates/program/timeslot_detail.html new file mode 100644 index 0000000..04d56c2 --- /dev/null +++ b/templates/program/timeslot_detail.html @@ -0,0 +1,58 @@ + + + Timeslot detail: {{ timeslot }} + + + + +
+

{{ timeslot.show.name }}

+ + {% if timeslot.show.short_description != 'FIXME' %} +
{{ timeslot.show.short_description }}
+ {% endif %} + +
+ {% for topic in timeslot.show.showtopic.all %} + {{ topic.abbrev }} + {% endfor %} + + {% for information in timeslot.show.showinformation.all %} + {{ information.abbrev }} + {% endfor %} + + {% for focus in timeslot.show.musicfocus.all %} + {{ focus.abbrev }} + {% endfor %} + + {{ timeslot.show.broadcastformat.abbrev }} +
+ +
+ {% for slot in timeslot.show.programslots.all %} +
{{ slot }}
+ {% endfor %} +
+ +
{{ timeslot.show.broadcastformat.format }}
+ +
+ {% for host in timeslot.show.hosts.all %} + + {% endfor %} +
+ +
{{ timeslot.show.description|safe }}
+ +
+ {% if timeslot.note %} +
+
{{ timeslot.note.title }}
+
{{ timeslot.note.content|safe }}
+
+ {% endif %} +
+
+ + + diff --git a/templates/program/week_schedule.html b/templates/program/week_schedule.html new file mode 100644 index 0000000..76aed5a --- /dev/null +++ b/templates/program/week_schedule.html @@ -0,0 +1,61 @@ + + + Week schedule + + + + + +
+
+
{{ monday|date:"l d.m.Y" }}
+ {% for timeslot in monday_timeslots %} + + {% endfor %} +
+ +
+
{{ tuesday|date:"l d.m.Y" }}
+ {% for timeslot in tuesday_timeslots %} + + {% endfor %} +
+ +
+
{{ wednesday|date:"l d.m.Y" }}
+ {% for timeslot in wednesday_timeslots %} + + {% endfor %} +
+ +
+
{{ thursday|date:"l d.m.Y" }}
+ {% for timeslot in thursday_timeslots %} + + {% endfor %} +
+ +
+
{{ friday|date:"l d.m.Y" }}
+ {% for timeslot in friday_timeslots %} + + {% endfor %} +
+ +
+
{{ saturday|date:"l d.m.Y" }}
+ {% for timeslot in saturday_timeslots %} + + {% endfor %} +
+ +
+
{{ sunday|date:"l d.m.Y" }}
+ {% for timeslot in sunday_timeslots %} + + {% endfor %} +
+
+ + + diff --git a/templates/search/indexes/program/note_SearchableText.txt b/templates/search/indexes/program/note_SearchableText.txt new file mode 100644 index 0000000..2421b4f --- /dev/null +++ b/templates/search/indexes/program/note_SearchableText.txt @@ -0,0 +1,2 @@ +{{ object.title }} +{{ object.content }} \ No newline at end of file diff --git a/templates/search/indexes/program/show_SearchableText.txt b/templates/search/indexes/program/show_SearchableText.txt new file mode 100644 index 0000000..f08b515 --- /dev/null +++ b/templates/search/indexes/program/show_SearchableText.txt @@ -0,0 +1,3 @@ +{{ object.name }} +{{ object.description }} +{{ object.short_description }} \ No newline at end of file diff --git a/urls.py b/urls.py new file mode 100644 index 0000000..27fbf2e --- /dev/null +++ b/urls.py @@ -0,0 +1,19 @@ +from django.conf import settings +from django.conf.urls.defaults import * +from django.contrib import admin + +import os.path + +admin.autodiscover() + +urlpatterns = patterns('', + (r'^admin/', include(admin.site.urls)), + (r'^program/', include('program.urls')), +) +if settings.DEBUG: + urlpatterns += patterns('', + (r'^site_media/(?P.*)$', + 'django.views.static.serve', + {'document_root': os.path.join(settings.PROJECT_DIR, 'site_media')} + ), + ) -- cgit v0.10.2