Esempio n. 1
0
 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
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)
Esempio n. 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
Esempio n. 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
Esempio n. 6
0
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)
Esempio n. 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
Esempio n. 8
0
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)
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 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)
Esempio n. 13
0
def check_accessrequesturl(key, data, errors, context):
    if data[('access',)] in ('free', 'ident'):
        not_empty(key, data, errors, context)
Esempio n. 14
0
def check_accessrights(key, data, errors, context):
    if data[('access',)] == 'form':
        not_empty(key, data, errors, context)
Esempio n. 15
0
def check_project_dis(key, data, errors, context):
    if not ('projdis',) in data:
        not_empty(key, data, errors, context)
Esempio n. 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)