def validate_content_uuid(self, tm, post_data): """ Checks to see if the content_uuid is OK, returns False if not valid """ ok = True label = post_data['label'].strip() predicate_uuid = post_data['predicate_uuid'].strip() content_uuid = post_data['content_uuid'].strip() if self.check_uuid_format(content_uuid): str_manage = StringManagement() str_manage.project_uuid = self.project_uuid # get an existing or create a new string object string_uuid = str_manage.check_string_exists(label, True) # now check to make sure the content_uuid is not # already used, skipping strings uuid_exists = self.check_uuid_exists(content_uuid, False) if uuid_exists: # the uuid is used for something that is not a string # this messes stuff up, so note the error ok = False self.errors[ 'content_uuid'] = 'Cannot use the UUID: ' + content_uuid self.errors['content_uuid'] += ', because it is already used.' elif string_uuid is not False and string_uuid != content_uuid: # conflict beteween the user submitted content_uuid # and the string_uuid for the same label ok = False self.errors[ 'content_uuid'] = 'Cannot create a category called "' + label + '" ' self.errors[ 'content_uuid'] += ', becuase the submitted content UUID: ' + content_uuid self.errors[ 'content_uuid'] += ' conflicts with the existing UUID: ' + string_uuid else: # now, one last check is to make sure the # current combinaiton of predicate_uuid and content_uuid does not exist type_exists = tm.check_exists_pred_uuid_content( predicate_uuid, content_uuid) if type_exists: ok = False self.errors[ 'content_uuid'] = 'Cannot create a category called "' + label + '" ' self.errors[ 'content_uuid'] += ', becuase the submitted content UUID: ' + content_uuid self.errors[ 'content_uuid'] += ' is already used with the Predicate UUID: ' + predicate_uuid else: ok = False self.errors[ 'content_uuid'] = 'Cannot create a category called "' + label + '"' self.errors[ 'content_uuid'] += ', becuase the submitted content UUID: ' + content_uuid self.errors['content_uuid'] += ' is badly formed.' if ok: return content_uuid else: return False
def validate_content_uuid(self, tm, post_data): """ Checks to see if the content_uuid is OK, returns False if not valid """ ok = True label = post_data['label'].strip() predicate_uuid = post_data['predicate_uuid'].strip() content_uuid = post_data['content_uuid'].strip() if self.check_uuid_format(content_uuid): str_manage = StringManagement() str_manage.project_uuid = self.project_uuid # get an existing or create a new string object string_uuid = str_manage.check_string_exists(label, True) # now check to make sure the content_uuid is not # already used, skipping strings uuid_exists = self.check_uuid_exists(content_uuid, False) if uuid_exists: # the uuid is used for something that is not a string # this messes stuff up, so note the error ok = False message = 'Cannot use the UUID: ' + content_uuid message += ', because it is already used.' self.errors.append(message) elif string_uuid is not False and string_uuid != content_uuid: # conflict beteween the user submitted content_uuid # and the string_uuid for the same label ok = False message = 'Cannot create a category called "' + label + '" ' message += ', becuase the submitted content UUID: ' + content_uuid message += ' conflicts with the existing UUID: ' + string_uuid self.errors.append(message) else: # now, one last check is to make sure the # current combinaiton of predicate_uuid and content_uuid does not exist type_exists = tm.check_exists_pred_uuid_content(predicate_uuid, content_uuid) if type_exists: ok = False message = 'Cannot create a category called "' + label + '" ' message += ', becuase the submitted content UUID: ' + content_uuid message += ' is already used with the Predicate UUID: ' + predicate_uuid self.errors.append(message) else: ok = False message = 'Cannot create a category called "' + label + '"' message += ', becuase the submitted content UUID: ' + content_uuid message += ' is badly formed.' self.errors.append(message) if ok: return content_uuid else: return False
def check_exists_pred_uuid_content(self, predicate_uuid, content, show_uuid=False): """ Checks if a predicate_uuid and a content string already exists This is useful, since it does not change anything in the database, it just checks to see if a content string is used with a predicate """ found = False str_manage = StringManagement() str_manage.project_uuid = self.project_uuid # get an existing or create a new string object content_uuid = str_manage.check_string_exists(content, True) if content_uuid is not False: # we've seen the string before, so # now check if found = self.check_exists_pred_uuid_content_uuid(predicate_uuid, content_uuid, show_uuid) return found
def check_exists_pred_uuid_content(self, predicate_uuid, content, show_uuid=False): """ Checks if a predicate_uuid and a content string already exists This is useful, since it does not change anything in the database, it just checks to see if a content string is used with a predicate """ found = False str_manage = StringManagement() str_manage.project_uuid = self.project_uuid # get an existing or create a new string object content_uuid = str_manage.check_string_exists(content, True) if content_uuid is not False: # we've seen the string before, so # now check if found = self.check_exists_pred_uuid_content_uuid( predicate_uuid, content_uuid, show_uuid) return found