Skip to content

forms

AnalysisGroupForm

Bases: ModelForm

Form class that enables setting the reverse relationships to Podcast, Season, and Episode.

Attributes:

Name Type Description
name CharField

Name of the group

description TextField

Description of the group

podcasts ModelMultipleChoiceField

List of podcasts

seasons ModelMultipleChoiceField

List of seasons

episodes ModelMultipleChoiceField

List of episodes

PersonMergeForm

Bases: Form

Form class for validating person merge operations.

Attributes:

Name Type Description
source_person ModelChoiceField

Source person

destination_person ModelChoiceField

Destination person

clean

clean()

Run standard clean and then validate that user is not trying to merge a record into itself.

Source code in src/podcast_analyzer/forms.py
def clean(self):
    """
    Run standard clean and then validate that user is not trying
    to merge a record into itself.
    """
    self.cleaned_data = super().clean()
    dest = self.cleaned_data.get("destination_person")
    source = self.cleaned_data.get("source_person")
    if dest == source:
        msg = "A record cannot be merged into itself!"
        raise ValidationError(msg)
    return self.cleaned_data