From bced5b655086191693bd03a594128b35da90d259 Mon Sep 17 00:00:00 2001 From: ingo <ingo.leindecker@fro.at> Date: Tue, 2 Jan 2018 15:53:42 +0100 Subject: [PATCH] Always use fallback ID instead of fallback playlist or pool See #21 --- program/admin.py | 8 ++-- program/migrations/0017_auto_20180102_1535.py | 39 +++++++++++++++++++ program/models.py | 8 ++-- program/serializers.py | 6 +-- program/templates/calendar.html | 4 +- program/templates/collisions.html | 2 +- 6 files changed, 54 insertions(+), 13 deletions(-) create mode 100644 program/migrations/0017_auto_20180102_1535.py diff --git a/program/admin.py b/program/admin.py index b4ff8fe9..bf09bea5 100644 --- a/program/admin.py +++ b/program/admin.py @@ -163,7 +163,7 @@ class TimeSlotAdmin(admin.ModelAdmin): class ScheduleAdmin(admin.ModelAdmin): actions = ('renew',) inlines = (TimeSlotInline,) - fields = (('rrule', 'byweekday'), ('dstart', 'tstart', 'tend'), 'until', 'is_repetition', 'automation_id', 'fallback_playlist_id') + fields = (('rrule', 'byweekday'), ('dstart', 'tstart', 'tend'), 'until', 'is_repetition', 'automation_id', 'fallback_id') list_display = ('get_show_name', 'byweekday', 'rrule', 'tstart', 'tend', 'until') list_filter = (ActiveSchedulesFilter, 'byweekday', 'rrule', 'is_repetition') ordering = ('byweekday', 'dstart') @@ -203,7 +203,7 @@ class ShowAdmin(admin.ModelAdmin): fields = ( 'predecessor', 'type', 'name', 'slug', 'image', 'logo', 'short_description', 'description', 'email', 'website', 'hosts', 'owners', 'language', 'category', 'rtrcategory', 'topic', - 'musicfocus', 'fallback_pool', 'cba_series_id', + 'musicfocus', 'fallback_id', 'cba_series_id', ) @@ -346,7 +346,7 @@ class ShowAdmin(admin.ModelAdmin): until = datetime.strptime(request.POST.get('ps_save_until'), '%Y-%m-%d').date() is_repetition = request.POST.get('ps_save_is_repetition') automation_id = int(request.POST.get('ps_save_automation_id')) if request.POST.get('ps_save_automation_id') != 'None' else 0 - fallback_playlist_id = int(request.POST.get('fallback_playlist_id')) if request.POST.get('ps_save_fallback_playlist_id') != 'None' else 0 + fallback_id = int(request.POST.get('fallback_id')) if request.POST.get('ps_save_fallback_id') != 'None' else 0 # Put timeslot POST vars into lists with same indices for i in range(num_inputs): @@ -391,7 +391,7 @@ class ShowAdmin(admin.ModelAdmin): until=until, is_repetition=is_repetition, automation_id=automation_id, - fallback_playlist_id=fallback_playlist_id) + fallback_id=fallback_id) # Only save schedule if any timeslots changed if len(resolved_timeslots) > 0: diff --git a/program/migrations/0017_auto_20180102_1535.py b/program/migrations/0017_auto_20180102_1535.py new file mode 100644 index 00000000..bc5a82cb --- /dev/null +++ b/program/migrations/0017_auto_20180102_1535.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.3 on 2018-01-02 15:35 +from __future__ import unicode_literals + +from django.db import migrations, models +import versatileimagefield.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('program', '0016_auto_20171213_1737'), + ] + + operations = [ + migrations.RemoveField( + model_name='schedule', + name='fallback_playlist_id', + ), + migrations.RemoveField( + model_name='show', + name='fallback_pool', + ), + migrations.AddField( + model_name='schedule', + name='fallback_id', + field=models.IntegerField(blank=True, null=True, verbose_name='Fallback ID'), + ), + migrations.AddField( + model_name='show', + name='fallback_id', + field=models.CharField(blank=True, max_length=255, verbose_name='Fallback ID'), + ), + migrations.AlterField( + model_name='host', + name='image', + field=versatileimagefield.fields.VersatileImageField(blank=True, height_field='height', help_text="Upload a picture of yourself. Images are automatically cropped around the 'Primary Point of Interest'. Click in the image to change it and press Save.", null=True, upload_to='host_images', verbose_name='Profile picture', width_field='width'), + ), + ] diff --git a/program/models.py b/program/models.py index 378a2aa1..21ec31c5 100644 --- a/program/models.py +++ b/program/models.py @@ -241,7 +241,7 @@ class Language(models.Model): class Host(models.Model): name = models.CharField(_("Name"), max_length=128) - is_always_visible = models.BooleanField(_("Is always visible"), default=False) + is_always_visible = models.BooleanField(_("Is always visible"), default=False) # Deprecated? email = models.EmailField(_("E-Mail"), blank=True) website = models.URLField(_("Website"), blank=True, help_text=_("URL to your personal website.")) biography = tinymce_models.HTMLField(_("Biography"), blank=True, null=True, help_text=_("Describe yourself and your fields of interest in a few sentences.")) @@ -281,6 +281,8 @@ class Host(models.Model): class Show(models.Model): + # TODO: add field 'is_always_visible'? + # -> categories 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")) @@ -302,7 +304,7 @@ class Show(models.Model): email = models.EmailField(_("E-Mail"), blank=True, null=True, help_text=_("The main contact email address for your show.")) website = models.URLField(_("Website"), blank=True, null=True, help_text=_("Is there a website to your show? Type in its URL.")) cba_series_id = models.IntegerField(_("CBA Series ID"), blank=True, null=True, help_text=_("Link your show to a CBA series by giving its ID. This will enable CBA upload and will automatically link your show to your CBA archive. Find out your ID under https://cba.fro.at/series")) - fallback_pool = models.CharField(_("Fallback Pool"), max_length=255, blank=True) + fallback_id = models.CharField(_("Fallback ID"), max_length=255, blank=True) created = models.DateTimeField(auto_now_add=True, editable=False) last_updated = models.DateTimeField(auto_now=True, editable=False) @@ -387,7 +389,7 @@ class Schedule(models.Model): tend = models.TimeField(_("End time")) until = models.DateField(_("Last date")) is_repetition = models.BooleanField(_("Is repetition"), default=False) - fallback_playlist_id = models.IntegerField(_("Fallback Playlist ID"), blank=True, null=True) + fallback_id = models.IntegerField(_("Fallback ID"), blank=True, null=True) automation_id = models.IntegerField(_("Automation ID"), blank=True, null=True, choices=get_automation_id_choices()) # Deprecated created = models.DateTimeField(auto_now_add=True, editable=False, null=True) #-> both see https://stackoverflow.com/questions/1737017/django-auto-now-and-auto-now-add last_updated = models.DateTimeField(auto_now=True, editable=False, null=True) diff --git a/program/serializers.py b/program/serializers.py index 4d0a5f2c..fb950785 100644 --- a/program/serializers.py +++ b/program/serializers.py @@ -229,7 +229,7 @@ class ShowSerializer(serializers.HyperlinkedModelSerializer): model = Show fields = ('id', 'name', 'slug', 'image', 'logo', 'short_description', 'description', 'email', 'website', 'created', 'last_updated', 'type', 'rtrcategory', - 'predecessor_id', 'cba_series_id', 'fallback_pool', 'category', 'hosts', + 'predecessor_id', 'cba_series_id', 'fallback_id', 'category', 'hosts', 'owners', 'language', 'topic', 'musicfocus') @@ -275,7 +275,7 @@ class ShowSerializer(serializers.HyperlinkedModelSerializer): instance.website = validated_data.get('website', instance.website) instance.predecessor_id = validated_data.get('predecessor_id', instance.predecessor_id) instance.cba_series_id = validated_data.get('cba_series_id', instance.cba_series_id) - instance.fallback_pool = validated_data.get('fallback_pool', instance.fallback_pool) + instance.fallback_id = validated_data.get('fallback_id', instance.fallback_id) # Only superusers may update the following fields if user.is_superuser: @@ -324,7 +324,7 @@ class ScheduleSerializer(serializers.ModelSerializer): instance.tend = validated_data.get('tend', instance.tend) instance.until = validated_data.get('until', instance.until) instance.is_repetition = validated_data.get('is_repetition', instance.is_repetition) - instance.fallback_playlist_id = validated_data.get('fallback_playlist_id', instance.fallback_playlist_id) + instance.fallback_id = validated_data.get('fallback_id', instance.fallback_id) instance.automation_id = validated_data.get('automation_id', instance.automation_id) instance.rrule = validated_data.get('rrule', instance.rrule) instance.show = validated_data.get('show', instance.show) diff --git a/program/templates/calendar.html b/program/templates/calendar.html index da3bf26e..75b9e6ad 100644 --- a/program/templates/calendar.html +++ b/program/templates/calendar.html @@ -103,7 +103,7 @@ <p></p> <div id="playlist-id"></div> <div id="is-repetition"></div> - <div id="fallback-playlist-id"></div> + <div id="fallback-id"></div> <p></p> <div id="show-hosts"></div> <div id="show-categories"></div> @@ -194,7 +194,7 @@ jQuery("#show-musicfocus").html('Music focus: ' + calEvent.show_musicfocus); jQuery("#is-repetition").html('WH: ' + calEvent.is_repetition); jQuery("#playlist-id").html('Playlist ID: ' + calEvent.playlist_id); - jQuery("#fallback-playlist-id").html('Fallback ID: ' + calEvent.fallback_playlist_id); + jQuery("#fallback-id").html('Fallback ID: ' + calEvent.fallback_id); jQuery("#memo").html(calEvent.memo); }, diff --git a/program/templates/collisions.html b/program/templates/collisions.html index 84de2053..24836912 100644 --- a/program/templates/collisions.html +++ b/program/templates/collisions.html @@ -136,7 +136,7 @@ <input type="hidden" name="ps_save_until" value="{{ schedule.until|date:"Y-m-d" }}" /> <input type="hidden" name="ps_save_is_repetition" value="{{ schedule.is_repetition }}" /> <input type="hidden" name="ps_save_automation_id" value="{{ schedule.automation_id }}" /> - <input type="hidden" name="ps_save_fallback_playlist_id" value="{{ schedule.fallback_playlist_id }}" /> + <input type="hidden" name="ps_save_fallback_id" value="{{ schedule.fallback_id }}" /> <input type="hidden" name="ps_save_show_id" value="{{ schedule.show_id }} " /> <input type="hidden" name="num_inputs" value="{{ num_inputs }}" /> <input type="hidden" name="step" value="{{ step }}" /> -- GitLab