Example #1
0
def resource_file_add_pre_process(resource,
                                  files,
                                  user,
                                  extract_metadata=False,
                                  source_names=[],
                                  **kwargs):
    if __debug__:
        assert (isinstance(source_names, list))
    resource_cls = resource.__class__
    if len(files) > 0:
        size = validate_resource_file_size(files)
        validate_user_quota(resource.get_quota_holder(), size)
        validate_resource_file_type(resource_cls, files)
        validate_resource_file_count(resource_cls, files, resource)

    file_validation_dict = {
        'are_files_valid': True,
        'message': 'Files are valid'
    }
    pre_add_files_to_resource.send(sender=resource_cls,
                                   files=files,
                                   resource=resource,
                                   user=user,
                                   source_names=source_names,
                                   validate_files=file_validation_dict,
                                   extract_metadata=extract_metadata,
                                   **kwargs)

    check_file_dict_for_error(file_validation_dict)
Example #2
0
def resource_file_add_pre_process(resource,
                                  files,
                                  user,
                                  extract_metadata=False,
                                  fed_res_file_names='',
                                  **kwargs):
    resource_cls = resource.__class__
    validate_resource_file_size(files)
    validate_resource_file_type(resource_cls, files)
    validate_resource_file_count(resource_cls, files, resource)

    file_validation_dict = {
        'are_files_valid': True,
        'message': 'Files are valid'
    }
    pre_add_files_to_resource.send(sender=resource_cls,
                                   files=files,
                                   resource=resource,
                                   user=user,
                                   fed_res_file_names=fed_res_file_names,
                                   validate_files=file_validation_dict,
                                   extract_metadata=extract_metadata,
                                   **kwargs)

    check_file_dict_for_error(file_validation_dict)
Example #3
0
def resource_file_add_pre_process(resource, files, user, extract_metadata=False,
                                  source_names=[], **kwargs):
    if __debug__:
        assert(isinstance(source_names, list))
    resource_cls = resource.__class__
    if len(files) > 0:
        size = validate_resource_file_size(files)
        validate_user_quota(resource.get_quota_holder(), size)
        validate_resource_file_type(resource_cls, files)
        validate_resource_file_count(resource_cls, files, resource)

    file_validation_dict = {'are_files_valid': True, 'message': 'Files are valid'}
    pre_add_files_to_resource.send(sender=resource_cls, files=files, resource=resource, user=user,
                                   source_names=source_names,
                                   validate_files=file_validation_dict,
                                   extract_metadata=extract_metadata, **kwargs)

    check_file_dict_for_error(file_validation_dict)