summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2021-02-17 13:33:49 (GMT)
committerChristian Pointner <equinox@helsinki.at>2021-02-17 13:33:49 (GMT)
commit8fa0d03d3509290ea6f523c2223966b1a2b73488 (patch)
treebe1ce4416b7edc8cb51a096d0990546b5c874057
parent1b2eb2aea52e754ad167c63259eec80e35497dfa (diff)
add language to model
-rw-r--r--program/admin.py14
-rw-r--r--program/migrations/0012_add_language.py32
-rw-r--r--program/models.py14
3 files changed, 56 insertions, 4 deletions
diff --git a/program/admin.py b/program/admin.py
index eb55554..d5be9a1 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 = ('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/migrations/0012_add_language.py b/program/migrations/0012_add_language.py
new file mode 100644
index 0000000..59be77d
--- /dev/null
+++ b/program/migrations/0012_add_language.py
@@ -0,0 +1,32 @@
+# -*- 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)),
+ ('name', models.CharField(max_length=32, verbose_name='Language')),
+ ('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..dd6cac4 100644
--- a/program/models.py
+++ b/program/models.py
@@ -208,6 +208,19 @@ class MusicFocus(models.Model):
return u'%s' % self.focus
+class Language(models.Model):
+ name = models.CharField(_("Language"), max_length=32)
+ native_name = models.CharField(_("Native Name"), max_length=32)
+
+ class Meta:
+ ordering = ('language',)
+ 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 +246,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"))
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"))