def conditional_not_empty(key, data, errors, context):
     if is_sysadmin(context['user']) and data[('validation_override',)]:
         ignore_missing(key, data, errors, context)
     elif data[('catalog_type',)] != ctype:
         ignore_missing(key, data, errors, context)
     else:
         not_empty(key, data, errors, context)
 def conditional_not_empty(key, data, errors, context):
     if is_sysadmin(context['user']) and data[('validation_override', )]:
         ignore_missing(key, data, errors, context)
     elif data[('catalog_type', )] != ctype:
         ignore_missing(key, data, errors, context)
     else:
         not_empty(key, data, errors, context)
def not_empty_allow_override(key, data, errors, context):
    """
    Not empty, but allow sysadmins to override the validation error
    by setting a value in data[(validation_override,)].
    """
    if is_sysadmin(context['user']) and data.get(('validation_override',)):
        ignore_missing(key, data, errors, context)
    else:
        not_empty(key, data, errors, context)
Exemple #4
0
def check_access_request_url(key, data, errors, context):
    '''
    Validate dataset's access request URL.
    '''
    if data.get(('availability',)) == 'access_request':
        not_empty(key, data, errors, context)
    else:
        data.pop(key, None)
        raise StopOnError
Exemple #5
0
def check_through_provider_url(key, data, errors, context):
    '''
    Validate dataset's `through_provider_URL`.
    '''
    if data.get(('availability',)) == 'through_provider':
        not_empty(key, data, errors, context)
    else:
        data.pop(key, None)
        raise StopOnError
def not_empty_allow_override(key, data, errors, context):
    """
    Not empty, but allow sysadmins to override the validation error
    by setting a value in data[(validation_override,)].
    """
    if is_sysadmin(context['user']) and data.get(('validation_override', )):
        ignore_missing(key, data, errors, context)
    else:
        not_empty(key, data, errors, context)
Exemple #7
0
def check_access_request_url(key, data, errors, context):
    '''
    Validate dataset's access request URL.
    '''
    if data.get(('availability', )) == 'access_request':
        not_empty(key, data, errors, context)
    else:
        data.pop(key, None)
        raise StopOnError
def _not_empty_if_ready_to_publish(key, data, errors, context):
    """
    Not empty, but allow sysadmins to override the validation error
    by setting a value in data[(validation_override,)].
    """
    v = data.get(('ready_to_publish',), True)
    if v is missing or v:
        not_empty(key, data, errors, context)
    else:
        ignore_missing(key, data, errors, context)
Exemple #9
0
def validate_access_application_url(key, data, errors, context):
    '''
    Validate dataset's `access_application_URL`.

    Dummy value _must_ be added for a new form so that it can be overwritten
    in the same session in iPackageController `edit` hook. For REMS.
    '''
    if data.get(('availability',)) == 'access_application':
        if data.get(('access_application_new_form',)) in [u'True', u'on']:
            data[key] = h.full_current_url().replace('/edit/', '/')
        else:
            not_empty(key, data, errors, context)
            url_validator(key, data, errors, context)
    else:
        data.pop(key, None)
        raise StopOnError
Exemple #10
0
def validate_access_application_url(key, data, errors, context):
    '''
    Validate dataset's `access_application_URL`.

    Dummy value _must_ be added if user chooses either reetta option
    so that its value can be overwritten in ckanext-rems when it knows what
    the access_application_URL will be. If user has chosen the option to
    which access application URL is input directly, then validation checks
    its not empty and that it is an url.
    '''
    if data.get(('availability',)) == 'access_application_rems' or \
        data.get(('availability',)) == 'access_application_other':

        if  data.get(('availability',)) == 'access_application_rems':
            data[key] = h.full_current_url().replace('/edit/', '/')
        elif data.get(('availability',)) == 'access_application_other':
            not_empty(key, data, errors, context)
            url_validator(key, data, errors, context)
    else:
        data.pop(key, None)
        raise StopOnError
Exemple #11
0
def validate_access_application_url(key, data, errors, context):
    '''
    Validate dataset's `access_application_URL`.

    Dummy value _must_ be added if user chooses either reetta option
    so that its value can be overwritten in ckanext-rems when it knows what
    the access_application_URL will be. If user has chosen the option to
    which access application URL is input directly, then validation checks
    its not empty and that it is an url.
    '''
    if data.get(('availability',)) == 'access_application_rems' or \
        data.get(('availability',)) == 'access_application_other':

        if data.get(('availability', )) == 'access_application_rems':
            data[key] = h.full_current_url().replace('/edit/', '/')
        elif data.get(('availability', )) == 'access_application_other':
            not_empty(key, data, errors, context)
            url_validator(key, data, errors, context)
    else:
        data.pop(key, None)
        raise StopOnError
Exemple #12
0
def not_empty_if_langtitle_empty(key, data, errors, context):
    from ckan.lib.navl.validators import not_empty
    if not data.get(('langtitle', 0, 'value')):
        not_empty(key, data, errors, context)
def check_accessrequesturl(key, data, errors, context):
    if data[('access',)] in ('free', 'ident'):
        not_empty(key, data, errors, context)
def check_accessrights(key, data, errors, context):
    if data[('access',)] == 'form':
        not_empty(key, data, errors, context)
def check_project_dis(key, data, errors, context):
    if not ('projdis',) in data:
        not_empty(key, data, errors, context)
Exemple #16
0
def not_empty_if_langtitle_empty(key, data, errors, context):
    from ckan.lib.navl.validators import not_empty
    if not data.get(('langtitle', 0, 'value')):
        not_empty(key, data, errors, context)