def clean(self): if self.agreement_with_terms_of_use and not self.terms_of_use: raise ValidationError( "When agreement with terms of use is " "required, a link to terms of use must be provided.") if self.streams.count() > 1: if self.mutually_exclusive is None: raise ValidationError( "Since this resource has multiple " "Streams, you must specify a value for mutually_exclusive." ) if self.account_email and not self.registration_url: raise ValidationError( "When pre-registration is required, " "a link to the registration page must be provided.") if (self.authorization_method == self.PROXY and not self.requested_access_duration): raise ValidationError({ "requested_access_duration": [ "When authorization method is proxy, " "requested_access_duration field must be checked." ] }) if self.target_url: # Validate the form for the uniqueness of self.target_url across # all PROXY and BUNDLE partners/streams. validation_error_msg = check_for_target_url_duplication_and_generate_error_message( self, partner=True) if validation_error_msg: raise ValidationError({"target_url": validation_error_msg})
def clean(self): if self.target_url: # Validate the form for the uniqueness of self.target_url across # all PROXY and BUNDLE partners/streams. validation_error_msg = check_for_target_url_duplication_and_generate_error_message( self, stream=True) if validation_error_msg: raise ValidationError({"target_url": validation_error_msg})
def clean(self): if self.agreement_with_terms_of_use and not self.terms_of_use: raise ValidationError( "When agreement with terms of use is " "required, a link to terms of use must be provided.") if self.streams.count() > 1: if self.mutually_exclusive is None: raise ValidationError( "Since this resource has multiple " "Streams, you must specify a value for mutually_exclusive." ) if self.account_email and not self.registration_url: raise ValidationError( "When pre-registration is required, " "a link to the registration page must be provided.") if (self.authorization_method == self.PROXY and not self.requested_access_duration): raise ValidationError({ "requested_access_duration": [ "When authorization method is proxy, " "requested_access_duration field must be checked." ] }) if self.target_url: # Validate the form for the uniqueness of self.target_url across # all PROXY and BUNDLE partners/streams. validation_error_msg = ( check_for_target_url_duplication_and_generate_error_message( self, partner=True)) if validation_error_msg: raise ValidationError({"target_url": validation_error_msg}) if self.authorization_method in [self.CODES, self.LINK ] and (not self.user_instructions): raise ValidationError( "Partners with automatically sent messages require user instructions to be entered" ) if self.authorization_method in [self.PROXY, self.BUNDLE ] and (not self.specific_stream): # Validate that target_url should not be empty # when authorization method is PROXY or BUNDLE if not self.target_url: raise ValidationError( "Proxy and Bundle partners require a target URL.") # If new_tags is not empty, validate with JSONSchema if self.new_tags is not None: try: validate( instance=self.new_tags, schema=get_tags_json_schema(), ) except JSONSchemaValidationError: raise ValidationError( mark_safe( "Error trying to insert a tag: please choose a tag from <a rel='noopener' target='_blank' href='https://github.com/WikipediaLibrary/TWLight/blob/production/locale/en/tag_names.json'>tag_names.json</a>." ))
def clean(self): if self.agreement_with_terms_of_use and not self.terms_of_use: raise ValidationError( "When agreement with terms of use is " "required, a link to terms of use must be provided." ) if self.streams.count() > 1: if self.mutually_exclusive is None: raise ValidationError( "Since this resource has multiple " "Streams, you must specify a value for mutually_exclusive." ) if self.account_email and not self.registration_url: raise ValidationError( "When pre-registration is required, " "a link to the registration page must be provided." ) if ( self.authorization_method == self.PROXY and not self.requested_access_duration ): raise ValidationError( { "requested_access_duration": [ "When authorization method is proxy, " "requested_access_duration field must be checked." ] } ) if self.target_url: # Validate the form for the uniqueness of self.target_url across # all PROXY and BUNDLE partners/streams. validation_error_msg = ( check_for_target_url_duplication_and_generate_error_message( self, partner=True ) ) if validation_error_msg: raise ValidationError({"target_url": validation_error_msg}) if self.authorization_method in [self.CODES, self.LINK] and ( not self.user_instructions ): raise ValidationError( "Partners with automatically sent messages require user instructions to be entered" ) if self.authorization_method in [self.PROXY, self.BUNDLE] and ( not self.specific_stream ): # Validate that target_url should not be empty # when authorization method is PROXY or BUNDLE if not self.target_url: raise ValidationError("Proxy and Bundle partners require a target URL.")