schedule & diffusions check/update + cleanup Schedule methods

This commit is contained in:
bkfox
2020-05-30 14:50:07 +02:00
parent 687238752c
commit dfdcf78344
8 changed files with 46 additions and 108 deletions

View File

@ -1,20 +1,33 @@
from copy import copy
from django.contrib import admin
from django.forms import ModelForm
from django.utils.translation import gettext_lazy as _
from ..models import Program, Schedule, Stream
from .page import PageAdmin
# In order to simplify schedule_post_save algorithm, an existing schedule can't
# update the following fields: "frequency", "date"
class ScheduleInlineForm(ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if self.initial:
self.fields['date'].disabled = True
self.fields['frequency'].disabled = True
class ScheduleInline(admin.TabularInline):
model = Schedule
form = ScheduleInlineForm
readonly_fields = ('timezone',)
extra = 1
class StreamInline(admin.TabularInline):
fields = ['delay', 'begin', 'end']
model = Stream
fields = ['delay', 'begin', 'end']
extra = 1
@ -71,4 +84,3 @@ class StreamAdmin(admin.ModelAdmin):
list_display = ('id', 'program', 'delay', 'begin', 'end')