Example #1
0
def dgu_package_update(context, data_dict):
    model = context['model']
    user = context.get('user')
    user_obj = model.User.get(user)
    package = get_package_object(context, data_dict)

    # Allow sysadmins to edit anything
    # This includes UKLP harvested and organogram datasets.
    #   Note: the harvest user *is* a sysadmin
    #   Note: if changing this, check the code and comments in
    #         ckanext/forms/dataset_form.py:DatasetForm.form_to_db_schema_options()
    if user_obj.sysadmin:
        return {'success': True}

    # UKLP datasets and other harvested datasets cannot be edited by the
    # average admin/editor because changes will be overwritten on next harvest.
    if dgu_helpers.was_dataset_harvested(package.extras):
        return {'success': False,
                'msg': _('User %s not authorized to edit harvested datasets')
                % str(user)}

    # Organogram datasets are managed by Drupal via the API
    if dgu_helpers.is_dataset_organogram(package.extras):
        return {'success': False,
                'msg': _('User %s not authorized to edit organogram datasets')
                % str(user)}

    # Leave the core CKAN auth to work out the hierarchy stuff
    return ckan.logic.auth.update.package_update(context, data_dict)
Example #2
0
    def add_collections(cls, pkg_dict):
        pkg_dict['collection'] = []

        if asbool(pkg_dict.get('core-dataset', False)):
            pkg_dict['collection'].append('National Information Infrastructure')
        if asbool(pkg_dict.get('its-dataset', False)):
            pkg_dict['collection'].append('Intelligent Transport Systems')
        if dgu_helpers.is_dataset_organogram(pkg_dict):
            pkg_dict['collection'].append('Organogram')

        # maybe put this in a property?
        #if 'API' in [p.upper() for p in pkg_dict['res_format']]:  # what about wfs?
        #    pkg_dict['collection'].append('API access')

        log.debug('Collection: %s', pkg_dict['collection'])
Example #3
0
    def add_collections(cls, pkg_dict):
        pkg_dict['collection'] = []

        if asbool(pkg_dict.get('core-dataset', False)):
            pkg_dict['collection'].append(
                'National Information Infrastructure')
        if asbool(pkg_dict.get('its-dataset', False)):
            pkg_dict['collection'].append('Intelligent Transport Systems')
        if asbool(pkg_dict.get('register', False)):
            pkg_dict['collection'].append('Registers')
        if dgu_helpers.is_dataset_organogram(pkg_dict):
            pkg_dict['collection'].append('Organogram')

        # maybe put this in a property?
        #if 'API' in [p.upper() for p in pkg_dict['res_format']]:  # what about wfs?
        #    pkg_dict['collection'].append('API access')

        log.debug('Collection: %s', pkg_dict['collection'])