summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2021-02-17 17:50:37 (GMT)
committerChristian Pointner <equinox@helsinki.at>2021-02-17 17:50:37 (GMT)
commitaafc069b9d6945138c2c2de1228f1a52c22d3c40 (patch)
treed9e6d23fd7a10d66d41c59d8e055053d7b5df72c /program
parent8fa0d03d3509290ea6f523c2223966b1a2b73488 (diff)
fix model for new language field and add language filter to show list template
Diffstat (limited to 'program')
-rw-r--r--program/migrations/0012_add_language.py3
-rw-r--r--program/models.py7
-rw-r--r--program/templates/boxes/language.html15
-rw-r--r--program/templates/day_schedule.html1
-rw-r--r--program/templates/show_list.html1
-rw-r--r--program/templatetags/content_boxes.py7
-rw-r--r--program/views.py9
7 files changed, 37 insertions, 6 deletions
diff --git a/program/migrations/0012_add_language.py b/program/migrations/0012_add_language.py
index 59be77d..21d3c4f 100644
--- a/program/migrations/0012_add_language.py
+++ b/program/migrations/0012_add_language.py
@@ -15,7 +15,8 @@ class Migration(migrations.Migration):
name='Language',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
- ('name', models.CharField(max_length=32, verbose_name='Language')),
+ ('slug', models.SlugField(unique=True, max_length=32, verbose_name='Slug')),
+ ('name', models.CharField(max_length=32, verbose_name='Name')),
('native_name', models.CharField(max_length=32, verbose_name='Native Name')),
],
options={
diff --git a/program/models.py b/program/models.py
index dd6cac4..7951c35 100644
--- a/program/models.py
+++ b/program/models.py
@@ -209,11 +209,12 @@ class MusicFocus(models.Model):
class Language(models.Model):
- name = models.CharField(_("Language"), max_length=32)
+ slug = models.SlugField(_("Slug"), max_length=32, unique=True)
+ name = models.CharField(_("Name"), max_length=32)
native_name = models.CharField(_("Native Name"), max_length=32)
class Meta:
- ordering = ('language',)
+ ordering = ('name',)
verbose_name = _("Language")
verbose_name_plural = _("Languages")
@@ -246,7 +247,7 @@ class Show(models.Model):
predecessor = models.ForeignKey('self', blank=True, null=True, related_name='successors', verbose_name=_("Predecessor"))
hosts = models.ManyToManyField(Host, blank=True, related_name='shows', verbose_name=_("Hosts"))
owners = models.ManyToManyField(User, blank=True, related_name='shows', verbose_name=_("Owners"))
- language = models.ManyToManyField(Language, blank=True, related_name='language', verbose_name=_("Language"))
+ language = models.ManyToManyField(Language, blank=True, related_name='shows', verbose_name=_("Language"))
broadcastformat = models.ForeignKey(BroadcastFormat, related_name='shows', verbose_name=_("Broadcast format"))
showinformation = models.ManyToManyField(ShowInformation, blank=True, related_name='shows', verbose_name=_("Show information"))
showtopic = models.ManyToManyField(ShowTopic, blank=True, related_name='shows', verbose_name=_("Show topic"))
diff --git a/program/templates/boxes/language.html b/program/templates/boxes/language.html
new file mode 100644
index 0000000..050c342
--- /dev/null
+++ b/program/templates/boxes/language.html
@@ -0,0 +1,15 @@
+{% if language_list %}
+ <dl id="filterbox_language" class="portlet filterbox">
+ <dt class="portletHeader"><span>Sprache<span></dt>
+ <dd class="portletItem">
+ <ul>
+ {% for language in language_list %}
+ <li>
+ <a title="Sendungen auf {{ language.name }} anzeigen."
+ href="?language={{ language.slug }}">{{ language.name }}/{{ language.native_name }}</a>
+ </li>
+ {% endfor %}
+ </ul>
+ </dd>
+ </dl>
+{% endif %}
diff --git a/program/templates/day_schedule.html b/program/templates/day_schedule.html
index eb0d3d7..a117a10 100644
--- a/program/templates/day_schedule.html
+++ b/program/templates/day_schedule.html
@@ -46,6 +46,7 @@
{% musicfocus %}
{% showinformation %}
{% showtopic %}
+{% language %}
</div>
{% endcomment %}
diff --git a/program/templates/show_list.html b/program/templates/show_list.html
index d9b9a47..fc02872 100644
--- a/program/templates/show_list.html
+++ b/program/templates/show_list.html
@@ -15,6 +15,7 @@
{% musicfocus %}
{% showinformation %}
{% showtopic %}
+ {% language %}
</div>
<div id="content-main" class="show-list">
diff --git a/program/templatetags/content_boxes.py b/program/templatetags/content_boxes.py
index 2d1745e..ece466b 100644
--- a/program/templatetags/content_boxes.py
+++ b/program/templatetags/content_boxes.py
@@ -1,6 +1,6 @@
from django import template
-from program.models import BroadcastFormat, MusicFocus, ShowInformation, ShowTopic
+from program.models import BroadcastFormat, MusicFocus, ShowInformation, ShowTopic, Language
register = template.Library()
@@ -23,3 +23,8 @@ def showinformation():
@register.inclusion_tag('boxes/showtopic.html')
def showtopic():
return {'showtopic_list': ShowTopic.objects.all()}
+
+
+@register.inclusion_tag('boxes/language.html')
+def language():
+ return {'language_list': Language.objects.all()}
diff --git a/program/views.py b/program/views.py
index 365a4db..256ad5d 100644
--- a/program/views.py
+++ b/program/views.py
@@ -8,7 +8,7 @@ from django.views.generic.base import TemplateView
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
-from models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, ShowTopic, TimeSlot, Host
+from models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, ShowTopic, Language, TimeSlot, Host
from program.utils import tofirstdayinisoweek, get_cached_shows
@@ -43,6 +43,9 @@ class ShowListView(ListView):
elif 'showtopic' in self.request.GET:
showtopic = get_object_or_404(ShowTopic, slug=self.request.GET['showtopic'])
queryset = queryset.filter(showtopic=showtopic)
+ elif 'language' in self.request.GET:
+ language = get_object_or_404(Language, slug=self.request.GET['language'])
+ queryset = queryset.filter(language=language)
return queryset
@@ -108,6 +111,9 @@ class DayScheduleView(TemplateView):
elif 'showtopic' in self.request.GET:
showtopic = get_object_or_404(ShowTopic, slug=self.request.GET['showtopic'])
context['showtopic'] = timeslots.filter(show__showtopic=showtopic)
+ elif 'language' in self.request.GET:
+ language = get_object_or_404(Language, slug=self.request.GET['language'])
+ context['showtopic'] = timeslots.filter(show__language=language)
else:
context['timeslots'] = timeslots
return context
@@ -214,6 +220,7 @@ def json_day_schedule(request, year=None, month=None, day=None):
return HttpResponse(json.dumps(schedule, ensure_ascii=False, encoding='utf8').encode('utf8'),
content_type="application/json; charset=utf-8")
+
def json_timeslots_specials(request):
specials = {}
shows = get_cached_shows()['shows']