(self)
Validates allowed combinations of time-values
Validates allowed combinations of time-values
Validates allowed combinations of time - values
def clean(self):
        """Validates allowed combinations of time-values"""
        PLAY_ACTION_KEYS = ("started", "stopped", "total")

        # Key found, but must not be supplied (no play action!)
        if self.action != EpisodeHistoryEntry.PLAY:
            for key in PLAY_ACTION_KEYS:
                if getattr(self, key, None) is not None:
                    raise ValidationError('%s only allowed in "play" entries' % key)

        # Sanity check: If started or total are given, require stopped
        if (
            (self.started is not None) or (self.total is not None)
        ) and self.stopped is None:
            raise ValidationError("started and total require position")

        # Sanity check: total and playmark can only appear together
        if ((self.total is not None) or (self.started is not None)) and (
            (self.total is None) or (self.started is None)
        ):
            raise ValidationError("total and started can only appear together")
def clean ( self ) : PLAY_ACTION_KEYS = ( "started" , "stopped" , "total" ) # Key found, but must not be supplied (no play action!) if self . action != EpisodeHistoryEntry . PLAY : for key in PLAY_ACTION_KEYS : if getattr ( self , key , None ) is not None : raise ValidationError ( '%s only allowed in "play" entries' % key ) # Sanity check: If started or total are given, require stopped if ( ( self . started is not None ) or ( self . total is not None ) ) and self . stopped is None : raise ValidationError ( "started and total require position" ) # Sanity check: total and playmark can only appear together if ( ( self . total is not None ) or ( self . started is not None ) ) and ( ( self . total is None ) or ( self . started is None ) ) : raise ValidationError ( "total and started can only appear together" )