diff options
-rw-r--r-- | program/admin.py | 10 | ||||
-rw-r--r-- | program/models.py | 34 | ||||
-rw-r--r-- | program/urls.py | 5 | ||||
-rw-r--r-- | program/views.py | 23 | ||||
-rw-r--r-- | templates/program/host_detail.html | 13 | ||||
-rw-r--r-- | templates/program/host_list.html | 5 | ||||
-rw-r--r-- | templates/program/recommendations.html | 20 | ||||
-rw-r--r-- | templates/program/show_detail.html | 22 | ||||
-rw-r--r-- | templates/program/show_list.html | 79 | ||||
-rw-r--r-- | templates/program/timeslot_detail.html | 16 |
10 files changed, 139 insertions, 88 deletions
diff --git a/program/admin.py b/program/admin.py index 642beaf..25ed87e 100644 --- a/program/admin.py +++ b/program/admin.py @@ -20,7 +20,7 @@ class ShowTopicAdmin(admin.ModelAdmin): class NoteAdmin(admin.ModelAdmin): list_filter = ('status',) - ordering = ('time_slot',) + ordering = ('timeslot',) class TimeSlotInline(admin.TabularInline): model = TimeSlot @@ -28,7 +28,7 @@ class TimeSlotInline(admin.TabularInline): class ProgramSlotAdmin(admin.ModelAdmin): date_hierarchy = 'dstart' inlines = (TimeSlotInline,) - list_display = ('show', 'byweekday', 'rrule', 'tstart', 'tend', 'dstart', 'until') + list_display = ('show', 'byweekday', 'rrule', 'tstart', 'tend', 'dstart', 'until', 'timeslot_count') list_filter = ('byweekday', 'rrule', 'is_repetition') ordering = ('byweekday', 'dstart') search_fields = ('show__name',) @@ -37,10 +37,10 @@ class ProgramSlotInline(admin.TabularInline): model = ProgramSlot class ShowAdmin(admin.ModelAdmin): - filter_horizontal = ('hosts', 'owners', 'music_focus', 'show_information', 'show_topic') + filter_horizontal = ('hosts', 'owners', 'musicfocus', 'showinformation', 'showtopic') inlines = (ProgramSlotInline,) - list_display = ('name', 'short_description', 'broadcast_format') - list_filter = ('broadcast_format', 'show_information', 'show_topic', 'music_focus',) + list_display = ('name', 'short_description', 'broadcastformat') + list_filter = ('broadcastformat', 'showinformation', 'showtopic', 'musicfocus',) ordering = ('slug',) prepopulated_fields = {'slug': ('name',)} search_fields = ('name', 'short_description', 'description') diff --git a/program/models.py b/program/models.py index 74f660a..9c51541 100644 --- a/program/models.py +++ b/program/models.py @@ -78,10 +78,10 @@ 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")) - broadcast_format = models.ForeignKey(BroadcastFormat, related_name='shows', verbose_name=_("Broadcast format")) - show_information = models.ManyToManyField(ShowInformation, blank=True, null=True, related_name='shows', verbose_name=_("Show information")) - show_topic = models.ManyToManyField(ShowTopic, blank=True, null=True, related_name='shows', verbose_name=_("Show topic")) - music_focus = models.ManyToManyField(MusicFocus, blank=True, null=True, related_name='shows', verbose_name=_("Music focus")) + 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=256, unique=True) image = models.ImageField(_("Image"), blank=True, null=True, upload_to='show_images') @@ -143,9 +143,9 @@ class ProgramSlot(models.Model): (5, _("Saturday")), (6, _("Sunday")), ) - rrule = models.ForeignKey(RRule, related_name='program_slots', verbose_name=_("Recurrence rule")) + rrule = models.ForeignKey(RRule, related_name='programslots', verbose_name=_("Recurrence rule")) byweekday = models.IntegerField(_("Weekday"), choices=BYWEEKDAY_CHOICES) - show = models.ForeignKey(Show, related_name='program_slots', verbose_name=_("Show")) + 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")) @@ -209,11 +209,15 @@ class ProgramSlot(models.Model): byweekday=byweekday)) for k in range(len(starts)): - time_slot = TimeSlot(program_slot=self, start=starts[k], end=ends[k]) - time_slot.save() + 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 TimeSlot(models.Model): - program_slot = models.ForeignKey(ProgramSlot, related_name='time_slots', verbose_name=_("Program slot")) + programslot = models.ForeignKey(ProgramSlot, related_name='timeslots', verbose_name=_("Program slot")) start = models.DateTimeField(_("Start time")) end = models.DateTimeField(_("End time")) @@ -229,7 +233,7 @@ class TimeSlot(models.Model): return u'%s: %s - %s' % (self.show(), start, end) def show(self): - return self.program_slot.show + return self.programslot.show @models.permalink def get_absolute_url(self): @@ -241,7 +245,7 @@ class Note(models.Model): (1, _("Recommendation")), (2, _("Repetition")), ) - time_slot = models.OneToOneField(TimeSlot, 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")) @@ -251,10 +255,12 @@ class Note(models.Model): last_updated = models.DateTimeField(auto_now=True, editable=False) class Meta: - ordering = ('time_slot',) + ordering = ('timeslot',) verbose_name = _("Note") verbose_name_plural = _("Notes") def __unicode__(self): - return u'%s - %s' % (self.title, self.time_slot) -
\ No newline at end of file + return u'%s - %s' % (self.title, self.timeslot) + + def show(self): + return self.timeslot.programslot.show diff --git a/program/urls.py b/program/urls.py index 850fbdd..9dfc811 100644 --- a/program/urls.py +++ b/program/urls.py @@ -3,12 +3,13 @@ from django.views.generic.detail import DetailView from django.views.generic.list import ListView from models import Host, Show, TimeSlot -from views import ShowListView +from views import RecommendationsView, ShowListView urlpatterns = patterns('', url('^hosts/$', ListView.as_view(model=Host,context_object_name='host_list')), url('^host/(?P<pk>\d+)/$', DetailView.as_view(model=Host), name='host-detail'), - url('^shows/$', ShowListView.as_view(model=Show)), + url('^recommendations/$', RecommendationsView.as_view()), + url('^shows/$', ShowListView.as_view()), url('^show/(?P<slug>[\w-]+)/$', DetailView.as_view(model=Show), name='show-detail'), url('^timeslot/(?P<pk>\d+)/$', DetailView.as_view(model=TimeSlot, context_object_name='timeslot'), name='timeslot-detail'), )
\ No newline at end of file diff --git a/program/views.py b/program/views.py index c6974b9..73a1298 100644 --- a/program/views.py +++ b/program/views.py @@ -1,6 +1,8 @@ -from django.views.generic.list import ListView +from django.views.generic import ListView -from models import BroadcastFormat, MusicFocus, Show, ShowInformation, ShowTopic +from models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, ShowTopic + +from datetime import datetime, timedelta class ShowListView(ListView): context_object_name = 'show_list' @@ -9,9 +11,16 @@ class ShowListView(ListView): def get_context_data(self, **kwargs): context = super(ShowListView, self).get_context_data(**kwargs) - context['broadcast_format_list'] = BroadcastFormat.objects.all() - context['music_focus_list'] = MusicFocus.objects.all() - context['show_information_list'] = ShowInformation.objects.all() - context['show_topic_list'] = ShowTopic.objects.all() + context['broadcastformat_list'] = BroadcastFormat.objects.all() + context['musicfocus_list'] = MusicFocus.objects.all() + context['showinformation_list'] = ShowInformation.objects.all() + context['showtopic_list'] = ShowTopic.objects.all() + + return context - return context
\ No newline at end of file +class RecommendationsView(ListView): + now = datetime.now() + in_one_week = now + timedelta(weeks=1) + context_object_name = 'recommendation_list' + template_name = 'program/recommendations.html' + queryset = Note.objects.filter(status=1, timeslot__start__range=(now, in_one_week))[:10] diff --git a/templates/program/host_detail.html b/templates/program/host_detail.html index a632a20..b780838 100644 --- a/templates/program/host_detail.html +++ b/templates/program/host_detail.html @@ -5,9 +5,16 @@ <body> <div id="host-detail"> - {{ host.name }} - {{ host.email }} - {{ host.website }} + <div id="name">{{ host.name }}</div> + + {% if host.email %} + <div id="email">{{ host.email }}</div> + {% endif %} + + {% if host.website %} + <div id="website">{{ host.website }}</div> + {% endif %} </div> + </body> </html>
\ No newline at end of file diff --git a/templates/program/host_list.html b/templates/program/host_list.html index fb19e47..ee67192 100644 --- a/templates/program/host_list.html +++ b/templates/program/host_list.html @@ -5,11 +5,12 @@ <body> <div id="host-list"> - {% for host in host_list %} +{% for host in host_list %} <div class="host"> <a href="{% url host-detail host.id %}">{{ host.name }}</a> </div> - {% endfor %} +{% endfor %} </div> + </body> </html>
\ No newline at end of file diff --git a/templates/program/recommendations.html b/templates/program/recommendations.html new file mode 100644 index 0000000..499fe4e --- /dev/null +++ b/templates/program/recommendations.html @@ -0,0 +1,20 @@ +<html> +<head> + <title>Recomendations</title> +</head> +<body> + +<div id="recommendations"> +{% for note in recommendation_list %} + <div class="show"> + <div class="broadcast-format">{{ note.show.broadcastformat }}</div> + <div class="time-slot">{{ note.timeslot.start }}</div> + <div class="show-name"><a href="{% url show-detail note.show.slug %}">{{ note.show.name }}</a></div> + <div class="show-short-description">{{ note.show.short_description }}</div> + <div class="note-title"><a href="{% url timeslot-detail note.timeslot.id %}">{{ note.title }}</a></div> + </div> +{% endfor %} +</div> + +</body> +</html>
\ No newline at end of file diff --git a/templates/program/show_detail.html b/templates/program/show_detail.html index 4de24c5..e2216ff 100644 --- a/templates/program/show_detail.html +++ b/templates/program/show_detail.html @@ -10,25 +10,28 @@ <div id="name">{{ show.name }}</div> <div id="abbrevs"> - {% for topic in show.show_topic.all %} + {% for topic in show.showtopic.all %} <span class="topic-abbrev">{{ topic.abbrev }}</span> {% endfor %} - {% for information in show.show_information.all %} + + {% for information in show.showinformation.all %} <span class="information-abbrev">{{ information.abbrev }}</span> {% endfor %} - {% for focus in show.music_focus.all %} + + {% for focus in show.musicfocus.all %} <span class="focus-abbrev">{{ focus.abbrev }}</span> {% endfor %} - <span class="broadcast-format-abbrev">{{ show.broadcast_format.abbrev }}</span> + + <span class="broadcastformat-abbrev">{{ show.broadcastformat.abbrev }}</span> </div> <div id="program-slots"> - {% for slot in show.program_slots.all %} - <div class="program-slot">{{ slot }}</div> + {% for slot in show.programslots.all %} + <div class="programslot">{{ slot }}</div> {% endfor %} </div> - <div id="broadcast-format">{{ show.broadcast_format.format }}</div> + <div id="broadcastformat">{{ show.broadcastformat.format }}</div> <div id="hosts"> {% for host in show.hosts.all %} @@ -37,18 +40,21 @@ </div> <div id="short-description">{{ show.short_description }}</div> + <div id="description">{{ show.description }}</div> + {% if show.email %} <div id="email"><a href="mailto:{{ show.email }}">{{ show.email }}</a></div> {% endif %} + {% if show.website %} <div id="website"><a href="{{ show.website }}">{{ show.website }}</a></div> {% endif %} + {% if show.cba_series_id %} <div id="cba-series-id"><a href="http://cba.fro.at/series/{{ show.cba_series_id }}">CBA</a></div> {% endif %} </div> </body> - </html>
\ No newline at end of file diff --git a/templates/program/show_list.html b/templates/program/show_list.html index 09bfa04..844395d 100644 --- a/templates/program/show_list.html +++ b/templates/program/show_list.html @@ -4,72 +4,69 @@ </head> <body> -<div id="show-topic-list"> - {% for topic in show_topic_list %} - <div class="show-topic"> +<div id="showtopic-list"> +{% for topic in showtopic_list %} + <div class="showtopic"> <span class="abbrev">{{ topic.abbrev }}</span> <span class="topic">{{ topic }}</span> </div> - {% endfor %} +{% endfor %} </div> -<div id="show-information-list"> - {% for information in show_information_list %} - <div class="show-information"> +<div id="showinformation-list"> +{% for information in showinformation_list %} + <div class="showinformation"> <span class="abbrev">{{ information.abbrev }}</span> <span class="information">{{ information }}</span> </div> - {% endfor %} +{% endfor %} </div> -<div id="music-focus-list"> - {% for focus in music_focus_list %} - <div class="music-focus"> +<div id="musicfocus-list"> +{% for focus in musicfocus_list %} + <div class="musicfocus"> <span class="abbrev">{{ focus.abbrev }}</span> <span class="focus">{{ focus }}</span> </div> - {% endfor %} +{% endfor %} </div> <div id="show-list"> - {% for show in show_list %} +{% for show in show_list %} <div class="show"> <div class="abbrevs"> - {% for topic in show.show_topic.all %} - <span class="topic-abbrev">{{ topic.abbrev }}</span> - {% endfor %} + {% for topic in show.showtopic.all %} + <span class="topic-abbrev">{{ topic.abbrev }}</span> + {% endfor %} - {% for information in show.show_information.all %} - <span class="information-abbrev">{{ information.abbrev }}</span> - {% endfor %} + {% for information in show.showinformation.all %} + <span class="information-abbrev">{{ information.abbrev }}</span> + {% endfor %} - {% for focus in show.music_focus.all %} - <span class="focus-abbrev">{{ focus.abbrev }}</span> - {% endfor %} + {% for focus in show.musicfocus.all %} + <span class="focus-abbrev">{{ focus.abbrev }}</span> + {% endfor %} - <span class="broadcast-format-abbrev">{{ show.broadcast_format.abbrev }}</span> + <span class="broadcastformat-abbrev">{{ show.broadcastformat.abbrev }}</span> </div> - <div class="name"> - <a href="{% url show-detail show.slug %} ">{{ show.name }}</a> - </div> - <div class="program-slots"> - {% for slot in show.program_slots.all %} - <div class="program-slot">{{ slot }}</div> - {% endfor %} - </div> - <div class="short-description"> - {{ show.short_description }} + + <div class="name"><a href="{% url show-detail show.slug %} ">{{ show.name }}</a></div> + + <div class="programslots"> + {% for slot in show.programslots.all %} + <div class="programslot">{{ slot }}</div> + {% endfor %} </div> - </div> - {% endfor %} + + <div class="short-description">{{ show.short_description }}</div> + </div> +{% endfor %} </div> -<div id="broadcast-format-list"> - {% for format in broadcast_format_list %} - <div class="broadcast-format"> - {{ format }} - </div> - {% endfor %} +<div id="broadcastformat-list"> +{% for format in broadcastformat_list %} + <div class="broadcastformat">{{ format }}</div> +{% endfor %} </div> </body> diff --git a/templates/program/timeslot_detail.html b/templates/program/timeslot_detail.html index d589f0e..d8a677e 100644 --- a/templates/program/timeslot_detail.html +++ b/templates/program/timeslot_detail.html @@ -10,25 +10,28 @@ <div id="name">{{ timeslot.show.name }}</div> <div id="abbrevs"> - {% for topic in timeslot.show.show_topic.all %} + {% for topic in timeslot.show.showtopic.all %} <span class="topic-abbrev">{{ topic.abbrev }}</span> {% endfor %} - {% for information in timeslot.show.show_information.all %} + + {% for information in timeslot.show.showinformation.all %} <span class="information-abbrev">{{ information.abbrev }}</span> {% endfor %} - {% for focus in timeslot.show.music_focus.all %} + + {% for focus in timeslot.show.musicfocus.all %} <span class="focus-abbrev">{{ focus.abbrev }}</span> {% endfor %} - <span class="broadcast-format-abbrev">{{ timeslot.show.broadcast_format.abbrev }}</span> + + <span class="broadcastformat-abbrev">{{ timeslot.show.broadcastformat.abbrev }}</span> </div> <div id="program-slots"> - {% for slot in timeslot.show.program_slots.all %} + {% for slot in timeslot.show.programslots.all %} <div class="program-slot">{{ slot }}</div> {% endfor %} </div> - <div id="broadcast-format">{{ timeslot.show.broadcast_format.format }}</div> + <div id="broadcastformat">{{ timeslot.show.broadcastformat.format }}</div> <div id="hosts"> {% for host in timeslot.show.hosts.all %} @@ -37,6 +40,7 @@ </div> <div id="short-description">{{ timeslot.show.short_description }}</div> + <div id="description">{{ timeslot.show.description }}</div> <div id="note"> |