コード例 #1
0
    def _show(self):
        schemas = [
            ("Dataset", scheming_dataset_schemas()),
            ("Group", scheming_group_schemas()),
            ("Organization", scheming_organization_schemas()),
        ]

        for n, s in schemas:
            print n, "schemas:"
            if s is None:
                print "    plugin not loaded or schema not specified\n"
                continue
            if not s:
                print "    no schemas"
            for typ in sorted(s):
                print " * " + json.dumps(typ)
                field_names = ('dataset_fields', 'fields', 'resource_fields')

                for field_name in field_names:
                    if s[typ].get(field_name):
                        if field_name == 'resource_fields':
                            print " * " + json.dumps("resource")
                        for field in s[typ][field_name]:
                            print "   - " + json.dumps(field['field_name']),
                            print scheming_language_text(field.get('label'))
            print
コード例 #2
0
    def _show(self):
        schemas = [
            ("Dataset", scheming_dataset_schemas()),
            ("Group", scheming_group_schemas()),
            ("Organization", scheming_organization_schemas()),
        ]

        for n, s in schemas:
            print n, "schemas:"
            if s is None:
                print "    plugin not loaded or schema not specified\n"
                continue
            if not s:
                print "    no schemas"
            for typ in sorted(s):
                print " * " + json.dumps(typ)
                field_names = ('dataset_fields', 'fields', 'resource_fields')

                for field_name in field_names:
                    if s[typ].get(field_name):
                        if field_name == 'resource_fields':
                            print " * " + json.dumps("resource")
                        for field in s[typ][field_name]:
                            print "   - " + json.dumps(field['field_name'])
            print
コード例 #3
0
ファイル: commands.py プロジェクト: ckylape/ckanext-scheming
 def _show(self):
     for n, s in (
             ("Dataset", scheming_dataset_schemas()),
             ("Group", scheming_group_schemas()),
             ("Organization", scheming_organization_schemas()),
             ):
         print n, "schemas:"
         if s is None:
             print "    plugin not loaded\n"
             continue
         if not s:
             print "    no schemas"
         for typ in sorted(s):
             print " * " + json.dumps(typ)
             for field in s[typ]['fields']:
                 print "   - " + json.dumps(field['field_name'])
         print
コード例 #4
0
 def _show(self):
     for n, s in (
         ("Dataset", scheming_dataset_schemas()),
         ("Group", scheming_group_schemas()),
         ("Organization", scheming_organization_schemas()),
     ):
         print n, "schemas:"
         if s is None:
             print "    plugin not loaded\n"
             continue
         if not s:
             print "    no schemas"
         for typ in sorted(s):
             print " * " + json.dumps(typ)
             for field in s[typ]['fields']:
                 print "   - " + json.dumps(field['field_name'])
         print
コード例 #5
0
ファイル: spc_package.py プロジェクト: roly97/ckanext-spc-pdh
    def choose_type(self):
        context = {
            'model': model,
            'session': model.Session,
            'user': g.user,
            'auth_user_obj': g.userobj
        }
        # Package needs to have a organization group in the call to
        # check_access and also to save it
        try:
            logic.check_access('package_create', context)
        except logic.NotAuthorized:
            abort(403, _('Unauthorized to create a package'))

        errors = {}
        error_summary = {}
        if 'POST' == request.method:
            try:
                dataset_type = request.params['type']
            except KeyError:
                errors = {'type': [_('Dataset type must be provided')]}
                error_summary = {
                    key.title(): value[0]
                    for key, value in errors.items()
                }
            else:
                return h.redirect_to(
                    'spc_dataset.new', package_type=dataset_type
                )

        options = [
            {
                'text': schema['about'],
                'value': schema['dataset_type']
            } for schema in
            sorted(scheming_helpers.scheming_dataset_schemas().values())
        ]
        data = {
            'form_vars': {
                'options': options,
                'error_summary': error_summary,
                'errors': errors,
            },
            'form_snippet': 'package/snippets/choose_type_form.html'
        }
        return render('package/choose_type.html', data)
コード例 #6
0
ファイル: helpers.py プロジェクト: pjodouin/ckanext-stcndm
def get_dataset_types():
    lc = ckanapi.LocalCKAN()
    types = lc.action.package_search(
        q='*:*',
        rows=0,
        facet='true',
        **{"facet.field": ["dataset_type"]}
    )['search_facets']['dataset_type']['items']
    schemas = scheming_dataset_schemas()
    result = {}

    for schema in schemas:
        result[schema] = {'title': schemas[schema]['catalog_type_label'], 'count': 0}

        for type in types:
            if schema == type['name']:
                result[schema]['count'] = type['count']
                break

    return sorted(result.iteritems(), key=lambda type: type[1], reverse=True)
コード例 #7
0
def get_dataset_types():
    lc = ckanapi.LocalCKAN()
    types = lc.action.package_search(
        q='*:*', rows=0, facet='true',
        **{"facet.field":
           ["dataset_type"]})['search_facets']['dataset_type']['items']
    schemas = scheming_dataset_schemas()
    result = {}

    for schema in schemas:
        result[schema] = {
            'title': schemas[schema]['catalog_type_label'],
            'count': 0
        }

        for type in types:
            if schema == type['name']:
                result[schema]['count'] = type['count']
                break

    return sorted(result.iteritems(), key=lambda type: type[1], reverse=True)
コード例 #8
0
ファイル: plugin.py プロジェクト: roly97/ckanext-spc-pdh
    def configure(self, config_):
        self.dataset_types = OrderedDict([
            (schema['dataset_type'], schema['about'])
            for schema in scheming_helpers.scheming_dataset_schemas().values()
        ])
        self.member_countries = OrderedDict([
            (choice['value'], choice['label'])
            for choice in scheming_helpers.scheming_get_preset(
                'member_countries')['choices']
        ])

        filepath = os.path.join(os.path.dirname(__file__), 'data/eez.json')
        if os.path.isfile(filepath):
            with open(filepath) as file:
                logger.debug('Updating EEZ list')
                collection = json.load(file)
                spc_utils.eez.update(collection['features'])

        toolkit.add_ckan_admin_tab(config_, 'search_queries.index',
                                   'Search Queries')
        toolkit.add_ckan_admin_tab(config_, 'ingest.index', 'Ingest')
コード例 #9
0
ファイル: logic.py プロジェクト: kolesarj/ckanext-scheming
def scheming_dataset_schema_list(context, data_dict):
    """
    Return a list of dataset types customized with the scheming extension
    """
    return list(scheming_dataset_schemas())
コード例 #10
0
ファイル: logic.py プロジェクト: DataShades/ckanext-scheming
def scheming_dataset_schema_list(context, data_dict):
    '''
    Return a list of dataset types customized with the scheming extension
    '''
    return list(scheming_dataset_schemas())