From 50a4b9b9884f53ad71547434de9bc3d43eb8b46d Mon Sep 17 00:00:00 2001 From: Ernesto Rico Schmidt <ernesto@helsinki.at> Date: Fri, 16 Jul 2021 11:58:10 -0400 Subject: [PATCH] Rename `default_id` to `default_playlist_id` --- program/admin.py | 10 ++++---- program/migrations/0003_auto_20210713_0420.py | 23 +++++++++++++++++++ program/models.py | 8 +++---- program/serializers.py | 6 ++--- program/views.py | 6 ++--- 5 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 program/migrations/0003_auto_20210713_0420.py diff --git a/program/admin.py b/program/admin.py index c93c9a14..91fbed9d 100644 --- a/program/admin.py +++ b/program/admin.py @@ -210,7 +210,7 @@ class ScheduleAdmin(admin.ModelAdmin): fields = ( ('rrule', 'byweekday'), ('tstart', 'tend'), 'dstart', 'until', 'is_repetition', ('add_days_no', 'add_business_days_only'), - 'default_id', 'automation_id',) + 'default_playlist_id', 'automation_id',) list_display = ('get_show_name', 'byweekday', 'rrule', 'tstart', 'tend', 'until') list_filter = (ActiveSchedulesFilter, 'byweekday', 'rrule', 'is_repetition') ordering = ('byweekday', 'dstart') @@ -252,7 +252,7 @@ class ShowAdmin(admin.ModelAdmin): fields = ( 'predecessor', 'type', 'name', 'slug', 'image', 'logo', 'short_description', 'description', 'email', 'website', 'hosts', 'owners', 'language', 'category', 'fundingcategory', 'topic', - 'musicfocus', 'default_id', 'cba_series_id', 'is_active', 'is_public' + 'musicfocus', 'default_playlist_id', 'cba_series_id', 'is_active', 'is_public' ) class Media: @@ -419,8 +419,8 @@ class ShowAdmin(admin.ModelAdmin): 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 - default_id = int(request.POST.get('ps_save_default_id')) if request.POST.get( - 'ps_save_default_id') != 'None' else 0 + default_playlist_id = int(request.POST.get('ps_save_default_playlist_id')) if request.POST.get( + 'ps_save_default_playlist_id') != 'None' else 0 add_days_no = int(request.POST.get('ps_save_add_days_no')) if request.POST.get( 'ps_save_add_days_no') != 'None' and int(request.POST.get('ps_save_add_days_no')) > 0 else None add_business_days_only = request.POST.get('ps_save_add_business_days_only') @@ -467,7 +467,7 @@ class ShowAdmin(admin.ModelAdmin): until=until, is_repetition=is_repetition, automation_id=automation_id, - default_id=default_id, + default_playlist_id=default_playlist_id, add_days_no=add_days_no, add_business_days_only=add_business_days_only) diff --git a/program/migrations/0003_auto_20210713_0420.py b/program/migrations/0003_auto_20210713_0420.py new file mode 100644 index 00000000..88314acb --- /dev/null +++ b/program/migrations/0003_auto_20210713_0420.py @@ -0,0 +1,23 @@ +# Generated by Django 2.2.12 on 2021-07-13 02:20 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('program', '0002_auto_20210426_2345'), + ] + + operations = [ + migrations.RenameField( + model_name='schedule', + old_name='default_id', + new_name='default_playlist_id' + ), + migrations.RenameField( + model_name='show', + old_name='default_id', + new_name='default_playlist_id' + ), + ] diff --git a/program/models.py b/program/models.py index fd72bf0d..daba737d 100644 --- a/program/models.py +++ b/program/models.py @@ -358,7 +358,7 @@ class Show(models.Model): 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 show's ID under https://cba.fro.at/series")) - default_id = models.IntegerField(_("Default ID"), blank=True, null=True, help_text=_( + default_playlist_id = models.IntegerField(_("Default Playlist ID"), blank=True, null=True, help_text=_( "If a timeslot of your show is empty, this playlist will be aired as a backup.")) created = models.DateTimeField(auto_now_add=True, editable=False) last_updated = models.DateTimeField(auto_now=True, editable=False) @@ -449,7 +449,7 @@ class Schedule(models.Model): is_repetition = models.BooleanField(_("Is repetition"), default=False) add_days_no = models.IntegerField(_("Add days"), blank=True, null=True) add_business_days_only = models.BooleanField(_("Only add business days?"), default=False) - default_id = models.IntegerField(_("Default ID"), blank=True, null=True) + default_playlist_id = models.IntegerField(_("Default Playlist ID"), blank=True, null=True) automation_id = models.IntegerField(_("Automation ID"), blank=True, null=True, choices=get_automation_id_choices()) # Deprecated # -> both see https://stackoverflow.com/questions/1737017/django-auto-now-and-auto-now-add @@ -488,7 +488,7 @@ class Schedule(models.Model): show = Show.objects.get(pk=int(show_pk)) is_repetition = True if 'is_repetition' in sdl and sdl['is_repetition'] is True else False - default_id = int(sdl['default_id']) if sdl['default_id'] else None + default_playlist_id = int(sdl['default_playlist_id']) if sdl['default_playlist_id'] else None automation_id = int(sdl['automation_id']) if sdl['automation_id'] else None add_days_no = int(sdl['add_days_no']) if sdl['add_days_no'] > 0 else None add_business_days_only = True if 'add_business_days_only' in sdl and sdl['add_business_days_only'] is True else False @@ -520,7 +520,7 @@ class Schedule(models.Model): schedule = Schedule(pk=pk, byweekday=sdl['byweekday'], rrule=rrule, dstart=dstart, tstart=tstart, tend=tend, until=until, is_repetition=is_repetition, - default_id=default_id, show=show, + default_playlist_id=default_playlist_id, show=show, add_days_no=add_days_no, add_business_days_only=add_business_days_only) return schedule diff --git a/program/serializers.py b/program/serializers.py index 20047eac..cff27afb 100644 --- a/program/serializers.py +++ b/program/serializers.py @@ -266,7 +266,7 @@ class ShowSerializer(serializers.HyperlinkedModelSerializer): model = Show fields = ('id', 'name', 'slug', 'image', 'ppoi', 'logo', 'short_description', 'description', 'email', 'website', 'created', 'last_updated', 'type', 'fundingcategory', - 'predecessor', 'cba_series_id', 'default_id', 'category', 'hosts', + 'predecessor', 'cba_series_id', 'default_playlist_id', 'category', 'hosts', 'owners', 'language', 'topic', 'musicfocus', 'thumbnails', 'is_active', 'is_public') def create(self, validated_data): @@ -311,7 +311,7 @@ class ShowSerializer(serializers.HyperlinkedModelSerializer): instance.email = validated_data.get('email', instance.email) instance.website = validated_data.get('website', instance.website) instance.cba_series_id = validated_data.get('cba_series_id', instance.cba_series_id) - instance.default_id = validated_data.get('default_id', instance.default_id) + instance.default_playlist_id = validated_data.get('default_playlist_id', instance.default_playlist_id) # Only superusers may update the following fields if user.is_superuser: @@ -361,7 +361,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.default_id = validated_data.get('default_id', instance.default_id) + instance.default_playlist_id = validated_data.get('default_playlist_id', instance.default_playlist_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/views.py b/program/views.py index 7aed784b..520e003b 100644 --- a/program/views.py +++ b/program/views.py @@ -120,8 +120,8 @@ def json_playout(request): 'schedule_id': ts.schedule.id, 'is_repetition': ts.is_repetition, 'playlist_id': ts.playlist_id, - 'schedule_default_id': ts.schedule.default_id, - 'show_default_id': ts.show.default_id, + 'schedule_default_playlist_id': ts.schedule.default_playlist_id, + 'show_default_playlist_id': ts.show.default_playlist_id, 'show_id': ts.show.id, 'show_name': ts.show.name + is_repetition, 'show_hosts': hosts, @@ -471,7 +471,7 @@ class APIScheduleViewSet(viewsets.ModelViewSet): # First update submit -> return projected timeslots and collisions if 'solutions' not in request.data: - # TODO: If nothing else than default_id, automation_id or is_repetition changed -> just save and don't do anything + # TODO: If nothing else than default_playlist_id, automation_id or is_repetition changed -> just save and don't do anything return Response(Schedule.make_conflicts(request.data['schedule'], pk, show_pk)) # Otherwise try to resolve -- GitLab