forked from rc/aircox
schedule & diffusions check/update + cleanup Schedule methods
This commit is contained in:
@ -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')
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user