def clean(self):
    super(ValidationRun, self).clean()
    if ((self.interval_from is None) and (self.interval_to is not None)):
        raise ValidationError({'interval_from': 'What has an end must have a beginning.'})
    if ((self.interval_from is not None) and (self.interval_to is None)):
        raise ValidationError({'interval_to': 'What has a beginning must have an end.'})
    if ((self.interval_from is not None) and (self.interval_to is not None) and (self.interval_from > self.interval_to)):
        raise ValidationError({'interval_from': 'From must be before To', 'interval_to': 'From must be before To'})
    if (self.anomalies == self.CLIMATOLOGY):
        if ((self.anomalies_from is None) or (self.anomalies_to is None)):
            raise ValidationError({'anomalies': 'Need valid time period to calculate climatology from.'})
        if (self.anomalies_from > self.anomalies_to):
            raise ValidationError({'anomalies_from': 'Start of climatology period must be before end.', 'anomalies_to': 'Start of climatology period must be before end.'})
    elif ((self.anomalies_from is not None) or (self.anomalies_to is not None)):
        raise ValidationError({'anomalies': 'Time period makes no sense for anomalies calculation without climatology.'})
    box = {'min_lat': self.min_lat, 'min_lon': self.min_lon, 'max_lat': self.max_lat, 'max_lon': self.max_lon}
    if (any(((x is None) for x in box.values())) and any(((x is not None) for x in box.values()))):
        affected_fields = {}
        for (key, value) in box.items():
            if (value is None):
                affected_fields[key] = 'For spatial subsetting, please set all bounding box coordinates.'
        raise ValidationError(affected_fields)
def clean(self):
    super(ValidationRun, self).clean()
    if ((self.interval_from is None) and (self.interval_to is not None)):
        raise ValidationError({'interval_from': 'What has an end must have a beginning.'})
    if ((self.interval_from is not None) and (self.interval_to is None)):
        raise ValidationError({'interval_to': 'What has a beginning must have an end.'})
    if ((self.interval_from is not None) and (self.interval_to is not None) and (self.interval_from > self.interval_to)):
        raise ValidationError({'interval_from': 'From must be before To', 'interval_to': 'From must be before To'})
    if (self.anomalies == self.CLIMATOLOGY):
        if ((self.anomalies_from is None) or (self.anomalies_to is None)):
            raise ValidationError({'anomalies': 'Need valid time period to calculate climatology from.'})
        if (self.anomalies_from > self.anomalies_to):
            raise ValidationError({'anomalies_from': 'Start of climatology period must be before end.', 'anomalies_to': 'Start of climatology period must be before end.'})
    elif ((self.anomalies_from is not None) or (self.anomalies_to is not None)):
        raise ValidationError({'anomalies': 'Time period makes no sense for anomalies calculation without climatology.'})
    box = {'min_lat': self.min_lat, 'min_lon': self.min_lon, 'max_lat': self.max_lat, 'max_lon': self.max_lon}
    if (any(((x is None) for x in box.values())) and any(((x is not None) for x in box.values()))):
        affected_fields = {}
        for (key, value) in box.items():
            if (value is None):
                affected_fields[key] = 'For spatial subsetting, please set all bounding box coordinates.'
        raise ValidationError(affected_fields)