From 158b1d5c12fd2332960671bce6d71953871da3cf Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sat, 2 Apr 2011 14:32:19 +0200 Subject: added static_media. diff --git a/urls.py b/urls.py index db535ce..5aaf499 100644 --- a/urls.py +++ b/urls.py @@ -1,9 +1,19 @@ +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')), ) +if settings.DEBUG: + urlpatterns += patterns('', + (r'^site_media/(?P.*)$', + 'django.views.static.serve', + {'document_root': os.path.join(os.path.dirname(__file__), 'site_media')} + ), + ) -- cgit v0.10.2 From 8c8b20d8b5a882f816605192a675b2c838252c2c Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sat, 2 Apr 2011 14:34:23 +0200 Subject: updated list. diff --git a/TODO b/TODO index ed96ac1..ac65d10 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,5 @@ * create style sheet and update templates +* back-port to Django 1.2 * integrate django-haystack * integrate calendar into day schedule view * integrate tinyMCE into admin site -- cgit v0.10.2 From c2ec66c87e1cc650b0ae5f776173d1795cf1a558 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sat, 2 Apr 2011 16:25:18 +0200 Subject: cleaned-up templates. diff --git a/templates/program/current_box.html b/templates/program/current_box.html index d778518..fd9cb69 100644 --- a/templates/program/current_box.html +++ b/templates/program/current_box.html @@ -15,7 +15,9 @@ {% if current.note %}
{{ current.note.title }}
{% else %} -
{{ current.show.short_description }}
+ {% if current.show.short_description != 'FIMXE' %} +
{{ current.show.short_description }}
+ {% endif %} {% endif %} diff --git a/templates/program/day_schedule.html b/templates/program/day_schedule.html index 6230314..3e7d4bc 100644 --- a/templates/program/day_schedule.html +++ b/templates/program/day_schedule.html @@ -42,7 +42,9 @@ {% if timeslot.note %}
Heute: {{ timeslot.note.title }}
{% else %} + {% if timeslot.show.short_description != 'FIXME' %}
{{ timeslot.show.short_description }}
+ {% endif %} {% endif %} diff --git a/templates/program/host_detail.html b/templates/program/host_detail.html index b780838..eff52d6 100644 --- a/templates/program/host_detail.html +++ b/templates/program/host_detail.html @@ -1,18 +1,27 @@ Host detail: {{ host.name }} +
{{ host.name }}
+
+
Sendungen
+ + {% for show in host.shows.all %} + + {% endfor %} +
+ {% if host.email %} -
{{ host.email }}
+
E-Mail Adresse: {{ host.email }}
{% endif %} {% if host.website %} -
{{ host.website }}
+ {% endif %}
diff --git a/templates/program/host_list.html b/templates/program/host_list.html index 365154a..6497d35 100644 --- a/templates/program/host_list.html +++ b/templates/program/host_list.html @@ -1,6 +1,7 @@ Host list + diff --git a/templates/program/recommendations.html b/templates/program/recommendations.html index aa5866a..a8f5fde 100644 --- a/templates/program/recommendations.html +++ b/templates/program/recommendations.html @@ -1,18 +1,20 @@ Recomendations +
-{% for note in recommendations %} -
-
{{ note.show.broadcastformat }}
-
{{ note.timeslot.start }}
- -
{{ note.show.short_description }}
-
{{ note.title }}
-
{{ note.content }}
+{% for recommendation in recommendations %} +
+
{{ recommendation.timeslot.start|date:"d.m.Y 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/recommendations_box.html b/templates/program/recommendations_box.html index 94a55dd..b40bf0e 100644 --- a/templates/program/recommendations_box.html +++ b/templates/program/recommendations_box.html @@ -5,7 +5,7 @@ -
+
Programmhinweise
{% for recommendation in recommendations %}
diff --git a/templates/program/show_detail.html b/templates/program/show_detail.html index 05e678c..9cd2d8e 100644 --- a/templates/program/show_detail.html +++ b/templates/program/show_detail.html @@ -39,9 +39,11 @@ {% endfor %}
+ {% if show.short_description != 'FIXME' %}
{{ show.short_description }}
+ {% endif %} -
{{ show.description }}
+
{{ show.description|safe }}
{% if show.email %} diff --git a/templates/program/show_list.html b/templates/program/show_list.html index 7643087..1f061d0 100644 --- a/templates/program/show_list.html +++ b/templates/program/show_list.html @@ -1,72 +1,87 @@ Show list + -
-{% for topic in showtopics %} -
- {{ topic.abbrev }} - {{ topic }} +
+
Filter
+ +
+
Thema/Schwerpunkt
+ {% for topic in showtopics %} +
+ {{ topic.abbrev }} + {{ topic }} +
+ {% endfor %}
-{% endfor %} -
-
-{% for information in showinformations %} -
- {{ information.abbrev }} - {{ information }} +
+
+ {% for information in showinformations %} +
+ {{ information.abbrev }} + {{ information }} +
+ {% endfor %}
-{% endfor %} -
-
-{% for focus in musicfoci %} -
- {{ focus.abbrev }} - {{ focus }} +
+
Musiktendenz
+ {% for focus in musicfoci %} +
+ {{ focus.abbrev }} + {{ focus }} +
+ {% endfor %}
-{% endfor %}
-
+
{% for show in shows %}
-
- {% for topic in show.showtopic.all %} +
  + {% for topic in show.showtopic.all %} {{ topic.abbrev }} - {% endfor %} + {% endfor %} - {% for information in show.showinformation.all %} + {% for information in show.showinformation.all %} {{ information.abbrev }} - {% endfor %} + {% endfor %} - {% for focus in show.musicfocus.all %} + {% for focus in show.musicfocus.all %} {{ focus.abbrev }} - {% endfor %} + {% endfor %} {{ show.broadcastformat.abbrev }}
- +
+ -
- {% for slot in show.programslots.all %} -
{{ slot }}
- {% endfor %} -
+
+ {% for slot in show.programslots.all %} +
{{ slot }}
+ {% endfor %} +
-
{{ show.short_description }}
+ {% if show.short_description != 'FIXME' %} +
{{ show.short_description }}
+ {% endif %} +
{% endfor %}
-
-{% for format in broadcastformats %} -
{{ format }}
-{% endfor %} +
+
Legende
+ {% for broadcastformat in broadcastformats %} + + {% endfor %}
diff --git a/templates/program/timeslot_detail.html b/templates/program/timeslot_detail.html index f445f5d..f8dee29 100644 --- a/templates/program/timeslot_detail.html +++ b/templates/program/timeslot_detail.html @@ -1,13 +1,12 @@ Timeslot detail: {{ timeslot }} + -
-
-
{{ timeslot.show.name }}
+
{{ timeslot.show.name }}
{% for topic in timeslot.show.showtopic.all %} @@ -35,19 +34,21 @@
{% for host in timeslot.show.hosts.all %} -
{{ host }}
+ {% endfor %}
+ {% if timeslot.show.short_description != 'FIXME' %}
{{ timeslot.show.short_description }}
+ {% endif %} -
{{ timeslot.show.description }}
+
{{ timeslot.show.description|safe }}
{% if timeslot.note %}
{{ timeslot.note.title }}
-
{{ timeslot.note.content }}
+
{{ timeslot.note.content|safe }}
{% endif %}
diff --git a/templates/program/week_schedule.html b/templates/program/week_schedule.html index 2969d28..f6e8f57 100644 --- a/templates/program/week_schedule.html +++ b/templates/program/week_schedule.html @@ -1,38 +1,12 @@ Week schedule +
-
-
06:00
-
07:00
-
08:00
-
09:00
-
10:00
-
11:00
-
12:00
-
13:00
-
14:00
-
15:00
-
16:00
-
17:00
-
18:00
-
19:00
-
20:00
-
21:00
-
22:00
-
23:00
-
00:00
-
01:00
-
02:00
-
03:00
-
04:00
-
05:00
-
-
{{ monday|date:"l d.m.Y" }}
{% for timeslot in monday_timeslots %} -- cgit v0.10.2 From 37d54b9c36bf9079b8c95a9e7fc84d09361704e2 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sat, 2 Apr 2011 16:25:56 +0200 Subject: added base style sheet. 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; +} -- cgit v0.10.2 From 5d74968fd081864a2e0cfbeeccfeacbf3bdc078d Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sat, 2 Apr 2011 16:30:32 +0200 Subject: updated requirements and todo list. diff --git a/README.rst b/README.rst index 65cd260..7187e15 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ Requirements ============ -- Django 1.3: http://pypi.python.org/pypi/Django/1.3 +- 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 diff --git a/TODO b/TODO index ac65d10..7e9e8c6 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ -* create style sheet and update templates * back-port to Django 1.2 * integrate django-haystack * integrate calendar into day schedule view -- cgit v0.10.2 From 06f95893a4ccb46bec2450eacac29e1e266e40c6 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sat, 2 Apr 2011 20:01:02 +0200 Subject: fixed typo. diff --git a/templates/program/current_box.html b/templates/program/current_box.html index fd9cb69..226264e 100644 --- a/templates/program/current_box.html +++ b/templates/program/current_box.html @@ -15,7 +15,7 @@ {% if current.note %}
{{ current.note.title }}
{% else %} - {% if current.show.short_description != 'FIMXE' %} + {% if current.show.short_description != 'FIXME' %}
{{ current.show.short_description }}
{% endif %} {% endif %} -- cgit v0.10.2 From a7142c5ef44aa672a3bc5f3b3c97bd5529fa8bd7 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sat, 2 Apr 2011 20:02:53 +0200 Subject: removed settings not compatible with Django 1.2. diff --git a/settings.py b/settings.py index ac4ad72..0894d5f 100644 --- a/settings.py +++ b/settings.py @@ -34,20 +34,8 @@ MEDIA_ROOT = '' MEDIA_URL = '' -STATIC_ROOT = '' - -STATIC_URL = '/static/' - ADMIN_MEDIA_PREFIX = '/static/admin/' -STATICFILES_DIRS = () - -STATICFILES_FINDERS = ( - 'django.contrib.staticfiles.finders.FileSystemFinder', - 'django.contrib.staticfiles.finders.AppDirectoriesFinder', -# 'django.contrib.staticfiles.finders.DefaultStorageFinder', -) - SECRET_KEY = 'oepk-$!=)c)7+y%cdz-x46_h5bp!o-*9%dv!(sf=3r4zfqk_(t' TEMPLATE_LOADERS = ( @@ -76,7 +64,6 @@ INSTALLED_APPS = ( 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', - 'django.contrib.staticfiles', 'django.contrib.admin', 'helsinki.program', ) -- cgit v0.10.2 From 9b09c2ce17bbdd65a210b41f983ff8b6702d2545 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sat, 2 Apr 2011 20:05:07 +0200 Subject: changed to function based generic views. diff --git a/program/urls.py b/program/urls.py index 637ad97..bf798ec 100644 --- a/program/urls.py +++ b/program/urls.py @@ -1,20 +1,20 @@ from django.conf.urls.defaults import * -from django.views.generic.detail import DetailView -from django.views.generic.list import ListView + +from django.views.generic.list_detail import object_detail, object_list from models import Host, Show, TimeSlot -from views import CurrentShowView, DayScheduleView, RecommendationsView, ShowListView, TodayScheduleView, WeekScheduleView +from views import current_show, day_schedule, recommendations, show_list, today_schedule, week_schedule urlpatterns = patterns('', - ('^$', TodayScheduleView.as_view()), - ('^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/$', DayScheduleView.as_view()), - ('^(?P\d{4})/(?P\d{1,2})/$', WeekScheduleView.as_view()), - ('^current_box/$', CurrentShowView.as_view()), - ('^hosts/$', ListView.as_view(model=Host, context_object_name='hosts')), - url('^host/(?P\d+)/$', DetailView.as_view(model=Host), name='host-detail'), - ('^recommendations/$', RecommendationsView.as_view()), - ('^recommendations_box/$', RecommendationsView.as_view(template_name='program/recommendations_box.html')), - ('^shows/$', ShowListView.as_view()), - url('^show/(?P[\w-]+)/$', DetailView.as_view(model=Show), name='show-detail'), - url('^(?P\d+)/$', DetailView.as_view(model=TimeSlot), name='timeslot-detail'), -) \ No newline at end of file + ('^$', today_schedule), + ('^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/$', day_schedule), + ('^(?P\d{4})/(?P\d{1,2})/$', week_schedule), + ('^current_box/$', current_show), + ('^hosts/$', object_list, dict(template_object_name='host', queryset=Host.objects.all())), + url('^host/(?P\d+)/$', object_detail, dict(template_object_name='host', queryset=Host.objects.all()), name='host-detail'), + ('^recommendations/$', recommendations), + ('^recommendations_box/$', recommendations, dict(template_name='program/recommendations_box.html')), + ('^shows/$', show_list), + url('^show/(?P[\w-]+)/$', object_detail, dict(template_object_name='show', queryset=Show.objects.all()), name='show-detail'), + url('^(?P\d+)/$', object_detail, dict(template_object_name='timeslot', queryset=TimeSlot.objects.all()), name='timeslot-detail'), +) diff --git a/program/views.py b/program/views.py index 23c1483..b5f02b6 100644 --- a/program/views.py +++ b/program/views.py @@ -1,150 +1,113 @@ -from django.views.generic.list import ListView -from django.views.generic.base import TemplateView +from django.views.generic import list_detail +from django.views.generic import 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 -class ShowListView(ListView): - context_object_name = 'shows' +def show_list(request): + broadcastformats = BroadcastFormat.objects.all() + musicfoci = MusicFocus.objects.all() + showinformation = ShowInformation.objects.all() + showtopics = ShowTopic.objects.all() - def get_context_data(self, **kwargs): - context = super(ShowListView, self).get_context_data(**kwargs) + extra_context = dict(broadcastformats=broadcastformats, musicfoci=musicfoci, showinformation=showinformation, showtopics=showtopics) + + if 'broadcastformat' in request.GET: + broadcastformat = get_object_or_404(BroadcastFormat, slug=request.GET['broadcastformat']) - context['broadcastformats'] = BroadcastFormat.objects.all() - context['musicfoci'] = MusicFocus.objects.all() - context['showinformations'] = ShowInformation.objects.all() - context['showtopics'] = ShowTopic.objects.all() + queryset = Show.objects.filter(broadcastformat=broadcastformat) + elif 'musicfocus' in request.GET: + musicfocus = get_object_or_404(MusicFocus, slug=request.GET['musicfocus']) - return context + queryset = Show.objects.filter(musicfocus=musicfocus) + elif 'showinformation' in request.GET: + showinformation = get_object_or_404(ShowInformation, slug=request.GET['showinformation']) - def get_queryset(self): - if 'broadcastformat' in self.request.GET: - broadcastformat = get_object_or_404(BroadcastFormat, slug=self.request.GET['broadcastformat']) + queryset = Show.objects.filter(showinformation=showinformation) + elif 'showtopic' in request.GET: + showtopic = get_object_or_404(ShowTopic, slug=request.GET['showtopic']) - return Show.objects.filter(broadcastformat=broadcastformat) - elif 'musicfocus' in self.request.GET: - musicfocus = get_object_or_404(MusicFocus, slug=self.request.GET['musicfocus']) + queryset = Show.objects.filter(showtopic=showtopic) + else: + queryset = Show.objects.all() - return Show.objects.filter(musicfocus=musicfocus) - elif 'showinformation' in self.request.GET: - showinformation = get_object_or_404(ShowInformation, slug=self.request.GET['showinformation']) - return Show.objects.filter(showinformation=showinformation) - elif 'showtopic' in self.request.GET: - showtopic = get_object_or_404(ShowTopic, slug=self.request.GET['showtopic']) + return list_detail.object_list(request, queryset=queryset, extra_context=extra_context, template_object_name='show') - return Show.objects.filter(showtopic=showtopic) - else: - return Show.objects.all() +def recommendations(request, template_name='program/recommendations.html'): + now = datetime.now() + in_one_week = now + timedelta(weeks=1) -class RecommendationsView(ListView): - context_object_name = 'recommendations' - template_name = 'program/recommendations.html' + queryset = Note.objects.filter(status=1, timeslot__start__range=(now, in_one_week))[:10] - def get_queryset(self): - now = datetime.now() - in_one_week = now + timedelta(weeks=1) + return list_detail.object_list(request, queryset=queryset, template_name=template_name, template_object_name='recommendation') - return Note.objects.filter(status=1, timeslot__start__range=(now, in_one_week))[:10] +def today_schedule(request): + now = datetime.now() + today = datetime.combine(date.today(), time(6, 0)) + tomorrow = today + timedelta(days=1) -class TodayScheduleView(TemplateView): - template_name = 'program/day_schedule.html' + broadcastformats = BroadcastFormat.objects.all() + recommendations = Note.objects.filter(status=1, timeslot__start__range=(now, tomorrow)) - def get_context_data(self, **kwargs): - context = super(TodayScheduleView, self).get_context_data(**kwargs) + extra_context = dict(day=today, broadcastformats=broadcastformats, recommendations=recommendations) - now = datetime.now() - today = datetime.combine(date.today(), time(6, 0)) - tomorrow = datetime.combine(date.today()+timedelta(days=1), time(6, 0)) + if 'broadcastformat' in request.GET: + broadcastformat = get_object_or_404(BroadcastFormat, slug=request.GET['broadcastformat']) - context['day'] = today - context['broadcastformats'] = BroadcastFormat.objects.all() - context['recommendations'] = Note.objects.filter(status=1, timeslot__start__range=(now, tomorrow)) + extra_context['timeslots'] = TimeSlot.objects.filter(start__range=(today, tomorrow), show__broadcastformat=broadcastformat) + else: + extra_context['timeslots'] = TimeSlot.objects.filter(start__range=(today, tomorrow)) - if 'broadcastformat' in self.request.GET: - broadcastformat = get_object_or_404(BroadcastFormat, slug=self.request.GET['broadcastformat']) + return simple.direct_to_template(request, extra_context=extra_context, template='program/day_schedule.html') - context['timeslots'] = TimeSlot.objects.filter(start__range=(today, tomorrow), show__broadcastformat=broadcastformat) - else: - context['timeslots'] = TimeSlot.objects.filter(start__range=(today, tomorrow)) +def day_schedule(request, year, month, day): + this_day = datetime.strptime('%s__%s__%s__06__00' % (year, month, day), '%Y__%m__%d__%H__%M') + that_day = this_day+timedelta(days=1) - return context + broadcastformats = BroadcastFormat.objects.all() + recommendations = Note.objects.filter(status=1, timeslot__start__range=(this_day, that_day)) -class DayScheduleView(TemplateView): - template_name = 'program/day_schedule.html' + extra_context = dict(day=this_day, broadcastformats=broadcastformats, recommendations=recommendations) - def get_context_data(self, **kwargs): - context = super(DayScheduleView, self).get_context_data(**kwargs) + if 'broadcastformat' in request.GET: + broadcastformat = get_object_or_404(BroadcastFormat, slug=request.GET['broadcastformat']) - year = context['params']['year'] - month = context['params']['month'] - day = context['params']['day'] + extra_context['timeslots'] = TimeSlot.objects.filter(start__range=(this_day, that_day), show__broadcastformat=broadcastformat) + else: + extra_context['timeslots'] = TimeSlot.objects.filter(start__range=(this_day, that_day)) - # start the day at 6 - this_day = datetime.strptime('%s__%s__%s__06__00' % (year, month, day), '%Y__%m__%d__%H__%M') - that_day = this_day+timedelta(days=1) + return simple.direct_to_template(request, extra_context=extra_context, template='program/day_schedule.html') - context['day'] = this_day - context['broadcastformats'] = BroadcastFormat.objects.all() - context['recommendations'] = Note.objects.filter(status=1, timeslot__start__range=(this_day, that_day)) +def current_show(request): + current = TimeSlot.objects.get_or_create_current() + next = current.get_next_by_start() + after_next = next.get_next_by_start() - if 'broadcastformat' in self.request.GET: - broadcastformat = get_object_or_404(BroadcastFormat, slug=self.request.GET['broadcastformat']) + extra_context = dict(current=current, next=next, after_next=after_next) - context['timeslots'] = TimeSlot.objects.filter(start__range=(this_day, that_day), show__broadcastformat=broadcastformat) - else: - context['timeslots'] = TimeSlot.objects.filter(start__range=(this_day, that_day)) + return simple.direct_to_template(request, template='program/current_box.html', extra_context=extra_context) - return context - -class CurrentShowView(TemplateView): - template_name = 'program/current_box.html' - - def get_context_data(self, **kwargs): - context = super(CurrentShowView, self).get_context_data(**kwargs) - - context['current'] = TimeSlot.objects.get_or_create_current() - context['next'] = TimeSlot.objects.get_or_create_current().get_next_by_start() - context['after_next'] = TimeSlot.objects.get_or_create_current().get_next_by_start().get_next_by_start() - - return context - -class WeekScheduleView(TemplateView): - template_name = 'program/week_schedule.html' - - def get_context_data(self, **kwargs): - context = super(WeekScheduleView, self).get_context_data(**kwargs) - - year = context['params']['year'] - week = context['params']['week'] - - # start the day at 6 - 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) - - context['monday'] = monday - context['tuesday'] = tuesday - context['wednesday'] = wednesday - context['thursday'] = thursday - context['friday'] = friday - context['saturday'] = saturday - context['sunday'] = sunday - - context['monday_timeslots'] = TimeSlot.objects.filter(start__range=(monday, tuesday)) - context['tuesday_timeslots'] = TimeSlot.objects.filter(start__range=(tuesday, wednesday)) - context['wednesday_timeslots'] = TimeSlot.objects.filter(start__range=(wednesday, thursday)) - context['thursday_timeslots'] = TimeSlot.objects.filter(start__range=(thursday, friday)) - context['friday_timeslots'] = TimeSlot.objects.filter(start__range=(friday, saturday)) - context['saturday_timeslots'] = TimeSlot.objects.filter(start__range=(saturday, sunday)) - context['sunday_timeslots'] = TimeSlot.objects.filter(start__range=(sunday, next_monday)) - - return context +def week_schedule(request, year, week): + 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) -- cgit v0.10.2 From cd517b9452f7ecd995c8e85056bc4438185a4848 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sat, 2 Apr 2011 20:06:25 +0200 Subject: renamed variables to match context of generic views. diff --git a/templates/program/host_list.html b/templates/program/host_list.html index 6497d35..5ab5c3f 100644 --- a/templates/program/host_list.html +++ b/templates/program/host_list.html @@ -6,7 +6,7 @@
-{% for host in hosts %} +{% for host in host_list %} diff --git a/templates/program/recommendations.html b/templates/program/recommendations.html index a8f5fde..483962c 100644 --- a/templates/program/recommendations.html +++ b/templates/program/recommendations.html @@ -6,7 +6,7 @@
-{% for recommendation in recommendations %} +{% for recommendation in recommendation_list %}
{{ recommendation.timeslot.start|date:"d.m.Y H:i" }} - {{ recommendation.timeslot.end|date:"H:i" }}
diff --git a/templates/program/recommendations_box.html b/templates/program/recommendations_box.html index b40bf0e..26a7c97 100644 --- a/templates/program/recommendations_box.html +++ b/templates/program/recommendations_box.html @@ -7,7 +7,7 @@
Programmhinweise
- {% for recommendation in recommendations %} + {% for recommendation in recommendation_list %}
{{ recommendation.timeslot.start|date:"d.m. H:i" }}-{{ recommendation.timeslot.end|date:"H:i" }}
diff --git a/templates/program/show_list.html b/templates/program/show_list.html index 1f061d0..9539035 100644 --- a/templates/program/show_list.html +++ b/templates/program/show_list.html @@ -40,7 +40,7 @@
-{% for show in shows %} +{% for show in show_list %}
  {% for topic in show.showtopic.all %} -- cgit v0.10.2 From 81956e36f21f4c243a599a88512599d20c325fe8 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sat, 2 Apr 2011 20:07:22 +0200 Subject: back-ported to Django 1.2. diff --git a/TODO b/TODO index 7e9e8c6..a8ccd9f 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ -* back-port to Django 1.2 * integrate django-haystack * integrate calendar into day schedule view * integrate tinyMCE into admin site -- cgit v0.10.2 From b5b52f8f4fd25c9a9b778bbe2e76f0ad3aa43ea8 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sat, 2 Apr 2011 22:32:35 +0200 Subject: fixed admin media prefix, removed settings for logging. diff --git a/settings.py b/settings.py index 0894d5f..646fcac 100644 --- a/settings.py +++ b/settings.py @@ -34,7 +34,7 @@ MEDIA_ROOT = '' MEDIA_URL = '' -ADMIN_MEDIA_PREFIX = '/static/admin/' +ADMIN_MEDIA_PREFIX = '/media/' SECRET_KEY = 'oepk-$!=)c)7+y%cdz-x46_h5bp!o-*9%dv!(sf=3r4zfqk_(t' @@ -67,21 +67,3 @@ INSTALLED_APPS = ( 'django.contrib.admin', 'helsinki.program', ) - -LOGGING = { - 'version': 1, - 'disable_existing_loggers': False, - 'handlers': { - 'mail_admins': { - 'level': 'ERROR', - 'class': 'django.utils.log.AdminEmailHandler' - } - }, - 'loggers': { - 'django.request':{ - 'handlers': ['mail_admins'], - 'level': 'ERROR', - 'propagate': True, - }, - } -} -- cgit v0.10.2 From 3eabe337cbbf236ee9cb35e285ae2ad1ff72f491 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sun, 3 Apr 2011 00:22:53 +0200 Subject: updated requirements, added pysolr. diff --git a/README.rst b/README.rst index 7187e15..842c545 100644 --- a/README.rst +++ b/README.rst @@ -7,3 +7,4 @@ Requirements - 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 -- cgit v0.10.2 From 2de89101a2842a069f5c8ef8b577b3a98929517b Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sun, 3 Apr 2011 00:23:42 +0200 Subject: added haystack and Solr settings. diff --git a/settings.py b/settings.py index 646fcac..11de59f 100644 --- a/settings.py +++ b/settings.py @@ -66,4 +66,9 @@ INSTALLED_APPS = ( 'django.contrib.messages', 'django.contrib.admin', 'helsinki.program', + 'haystack', ) + +HAYSTACK_SITECONF = 'helsinki.search_sites' +HAYSTACK_SEARCH_ENGINE = 'solr' +HAYSTACK_SOLR_URL = 'http://localhost:8983/solr' -- cgit v0.10.2 From e88087eece7104820b60bb11573b579bbb36c01d Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sun, 3 Apr 2011 00:24:41 +0200 Subject: added search indexes and templates. diff --git a/program/search_indexes.py b/program/search_indexes.py new file mode 100644 index 0000000..8c21e14 --- /dev/null +++ b/program/search_indexes.py @@ -0,0 +1,23 @@ +from haystack.indexes import CharField, DateTimeField, SearchIndex +from haystack import site + +from datetime import datetime + +from program.models import Note, Show + +class NoteIndex(SearchIndex): + text = CharField(document=True, use_template=True) + last_updated = DateTimeField(model_attr='last_updated') + + def get_queryset(self): + return Note.objects.filter(last_updated__lte=datetime.now()) + +class ShowIndex(SearchIndex): + text = CharField(document=True, use_template=True) + last_updated = DateTimeField(model_attr='last_updated') + + def get_queryset(self): + return Show.objects.filter(last_updated__lte=datetime.now()) + +site.register(Note, NoteIndex) +site.register(Show, ShowIndex) \ No newline at end of file diff --git a/search_sites.py b/search_sites.py new file mode 100644 index 0000000..fe5127a --- /dev/null +++ b/search_sites.py @@ -0,0 +1,2 @@ +import haystack +haystack.autodiscover() \ No newline at end of file diff --git a/templates/search/indexes/program/note_text.txt b/templates/search/indexes/program/note_text.txt new file mode 100644 index 0000000..2421b4f --- /dev/null +++ b/templates/search/indexes/program/note_text.txt @@ -0,0 +1,2 @@ +{{ object.title }} +{{ object.content }} \ No newline at end of file diff --git a/templates/search/indexes/program/show_text.txt b/templates/search/indexes/program/show_text.txt new file mode 100644 index 0000000..f08b515 --- /dev/null +++ b/templates/search/indexes/program/show_text.txt @@ -0,0 +1,3 @@ +{{ object.name }} +{{ object.description }} +{{ object.short_description }} \ No newline at end of file -- cgit v0.10.2 From da5e6afcd45443790b73541f6721d73b6e29f059 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sun, 3 Apr 2011 00:26:20 +0200 Subject: integrated django-haystack. diff --git a/TODO b/TODO index a8ccd9f..8b33005 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ -* integrate django-haystack * integrate calendar into day schedule view * integrate tinyMCE into admin site * integrate open ID -- cgit v0.10.2 From 649ee0193efeb9af3250745d0c836c5a0e8c4d93 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Sun, 3 Apr 2011 16:37:23 +0200 Subject: fixed query in time slot manager. diff --git a/program/models.py b/program/models.py index f6839e2..70347b0 100644 --- a/program/models.py +++ b/program/models.py @@ -221,7 +221,7 @@ class ProgramSlot(models.Model): class TimeSlotManager(models.Manager): def get_or_create_current(self): try: - return TimeSlot.objects.get(start__lte=datetime.now(), end__gte=datetime.now()) + return TimeSlot.objects.get(start__lte=datetime.now(), end__gt=datetime.now()) except ObjectDoesNotExist: once = RRule.objects.get(pk=1) today = date.today().weekday() -- cgit v0.10.2 From 45ac409c7861a99526e314dfa5f358e49208c0ab Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Apr 2011 23:28:28 +0200 Subject: time slot choices are now limited in admin. diff --git a/program/models.py b/program/models.py index 70347b0..5f0f835 100644 --- a/program/models.py +++ b/program/models.py @@ -271,7 +271,7 @@ class Note(models.Model): (1, _("Recommendation")), (2, _("Repetition")), ) - timeslot = models.OneToOneField(TimeSlot, limit_choices_to={'start__gte': datetime.now}, verbose_name=_("Time slot")) + 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")) -- cgit v0.10.2 From 3c5bfc8fe50437e9a8f8b1a259639dc95c56f3d9 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Wed, 6 Apr 2011 23:28:59 +0200 Subject: tweaked Note administration. diff --git a/program/admin.py b/program/admin.py index 5a6ce7f..6c64dd3 100644 --- a/program/admin.py +++ b/program/admin.py @@ -1,5 +1,7 @@ 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): @@ -20,10 +22,32 @@ class ShowTopicAdmin(admin.ModelAdmin): class NoteAdmin(admin.ModelAdmin): date_hierarchy = 'start' - list_display = ('title', 'show', 'status') + 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 -- cgit v0.10.2