from django import forms
from django.forms.models import modelformset_factory

from aircox import models
from .page import ChildPageForm


__all__ = ("EpisodeForm", "EpisodeSoundFormSet")


class EpisodeForm(ChildPageForm):
    class Meta:
        model = models.Episode
        fields = ChildPageForm.Meta.fields


EpisodeSoundFormSet = modelformset_factory(
    models.EpisodeSound,
    fields=(
        "position",
        "episode",
        "sound",
        "broadcast",
    ),
    widgets={
        "broadcast": forms.CheckboxInput(),
        "episode": forms.HiddenInput(),
        # "sound": forms.HiddenInput(),
        "position": forms.HiddenInput(),
    },
    can_delete=True,
    extra=0,
)
"""Formset used in EpisodeUpdateView."""
