summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2021-02-24 22:26:27 (GMT)
committerChristian Pointner <equinox@helsinki.at>2021-02-24 22:26:27 (GMT)
commita1064414914efd53ef1c44ee12392fef8a0c0b0f (patch)
tree60588ab162cdd607f5236d73750e4d3d6217d793 /program
parent1b2eb2aea52e754ad167c63259eec80e35497dfa (diff)
parentf7f4a5d5378b37c32b64bf0f71d0a438fd5d19d8 (diff)
Merge branch 'add-languages' into stable
Diffstat (limited to 'program')
-rw-r--r--program/admin.py14
-rw-r--r--program/fixtures/languages.yaml90
-rw-r--r--program/migrations/0012_add_language.py33
-rw-r--r--program/models.py15
-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
9 files changed, 179 insertions, 6 deletions
diff --git a/program/admin.py b/program/admin.py
index eb55554..16d6973 100644
--- a/program/admin.py
+++ b/program/admin.py
@@ -1,7 +1,7 @@
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
-from models import BroadcastFormat, MusicFocus, ShowInformation, ShowTopic, Host, Note, ProgramSlot, Show, TimeSlot
+from models import BroadcastFormat, MusicFocus, ShowInformation, ShowTopic, Language, Host, Note, ProgramSlot, Show, TimeSlot
from forms import MusicFocusForm
from datetime import date, datetime, timedelta
@@ -69,6 +69,10 @@ class ShowTopicAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ('topic',)}
+class LanguageAdmin(admin.ModelAdmin):
+ list_display = ('slug', 'name', 'native_name')
+
+
class HostAdmin(admin.ModelAdmin):
list_display = ('name',)
list_filter = (ActiveHostsFilter, 'is_always_visible',)
@@ -142,16 +146,16 @@ class ProgramSlotInline(admin.TabularInline):
class ShowAdmin(admin.ModelAdmin):
- filter_horizontal = ('hosts', 'owners', 'musicfocus', 'showinformation', 'showtopic')
+ filter_horizontal = ('hosts', 'owners', 'musicfocus', 'showinformation', 'showtopic', 'language')
inlines = (ProgramSlotInline,)
list_display = ('name', 'short_description')
- list_filter = (ActiveShowsFilter, 'broadcastformat', 'showinformation', 'showtopic', 'musicfocus')
+ list_filter = (ActiveShowsFilter, 'broadcastformat', 'showinformation', 'showtopic', 'musicfocus', 'language')
ordering = ('slug',)
prepopulated_fields = {'slug': ('name',)}
search_fields = ('name', 'short_description', 'description')
fields = (
'predecessor', 'broadcastformat', 'name', 'slug', 'image', 'image_enabled', 'short_description', 'description',
- 'email', 'website', 'hosts', 'owners', 'showinformation', 'showtopic',
+ 'email', 'website', 'hosts', 'owners', 'showinformation', 'showtopic', 'language',
'musicfocus',
)
@@ -166,10 +170,12 @@ class ShowAdmin(admin.ModelAdmin):
return super(ShowAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
+
admin.site.register(BroadcastFormat, BroadcastFormatAdmin)
admin.site.register(MusicFocus, MusicFocusAdmin)
admin.site.register(ShowInformation, ShowInformationAdmin)
admin.site.register(ShowTopic, ShowTopicAdmin)
+admin.site.register(Language, LanguageAdmin)
admin.site.register(Host, HostAdmin)
admin.site.register(Note, NoteAdmin)
admin.site.register(ProgramSlot, ProgramSlotAdmin)
diff --git a/program/fixtures/languages.yaml b/program/fixtures/languages.yaml
new file mode 100644
index 0000000..157bb9b
--- /dev/null
+++ b/program/fixtures/languages.yaml
@@ -0,0 +1,90 @@
+- model: program.language
+ pk: 1
+ fields:
+ name: Deutsch
+ native_name: Deutsch
+ slug: de
+- model: program.language
+ pk: 2
+ fields:
+ name: Englisch
+ native_name: English
+ slug: en
+- model: program.language
+ pk: 3
+ fields:
+ name: Ungarisch
+ native_name: Magyar
+ slug: hu
+- model: program.language
+ pk: 4
+ fields:
+ name: Italienisch
+ native_name: Italiano
+ slug: it
+- model: program.language
+ pk: 5
+ fields:
+ name: Spanisch
+ native_name: Español
+ slug: es
+- model: program.language
+ pk: 6
+ fields:
+ name: Rumänisch
+ native_name: Română
+ slug: ro
+- model: program.language
+ pk: 7
+ fields:
+ name: Französisch
+ native_name: Français
+ slug: fr
+- model: program.language
+ pk: 8
+ fields:
+ name: Albanisch
+ native_name: Shqip
+ slug: sq
+- model: program.language
+ pk: 9
+ fields:
+ name: Bosnisch
+ native_name: Bosanski
+ slug: bs
+- model: program.language
+ pk: 10
+ fields:
+ name: Kroatisch
+ native_name: Hrvatski
+ slug: hr
+- model: program.language
+ pk: 11
+ fields:
+ name: Serbisch
+ native_name: Српски
+ slug: sr
+- model: program.language
+ pk: 12
+ fields:
+ name: Russisch
+ native_name: Русский
+ slug: ru
+- model: program.language
+ pk: 13
+ fields:
+ name: Slowenisch
+ native_name: Slovenščina
+ slug: sl
+- model: program.language
+ pk: 14
+ fields:
+ name: Türkisch
+ native_name: Türkçe
+ slug: tr
+- model: program.language
+ pk: 15
+ fields:
+ name: Kurdisch
+ native_name: كوردی
+ slug: ku
diff --git a/program/migrations/0012_add_language.py b/program/migrations/0012_add_language.py
new file mode 100644
index 0000000..21d3c4f
--- /dev/null
+++ b/program/migrations/0012_add_language.py
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('program', '0011_programslot_remove_is_active'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Language',
+ fields=[
+ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+ ('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={
+ 'ordering': ('language',),
+ 'verbose_name': 'Language',
+ 'verbose_name_plural': 'Languages',
+ },
+ ),
+ migrations.AddField(
+ model_name='show',
+ name='language',
+ field=models.ManyToManyField(related_name='language', verbose_name='Language', to='program.Language', blank=True),
+ ),
+ ]
diff --git a/program/models.py b/program/models.py
index d52d1bf..7951c35 100644
--- a/program/models.py
+++ b/program/models.py
@@ -208,6 +208,20 @@ class MusicFocus(models.Model):
return u'%s' % self.focus
+class Language(models.Model):
+ 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 = ('name',)
+ verbose_name = _("Language")
+ verbose_name_plural = _("Languages")
+
+ def __unicode__(self):
+ return '%s' % self.name
+
+
class Host(models.Model):
name = models.CharField(_("Name"), max_length=128)
is_always_visible = models.BooleanField(_("Is always visible"), default=False)
@@ -233,6 +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='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..2215211 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..0602335 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']