Ejemplo n.º 1
0
def show_package_schema():
    """
    Add our custom fields for converting from the db
    """
    schema = default_show_package_schema()
    _schema_update(schema, 'show')
    return schema
Ejemplo n.º 2
0
def show_package_schema():
    """
    Add our custom fields for converting from the db
    """
    schema = default_show_package_schema()
    _schema_update(schema, 'show')
    return schema
Ejemplo n.º 3
0
def show_package_schema():

    schema = default_show_package_schema()

    convert_from_extras = get_converter('convert_from_extras')

    schema['openness_rating'] = [convert_from_extras]

    schema['quality'] = [convert_from_extras]

    schema['published_on_behalf_of'] = [convert_from_extras]

    schema['usage_guidance'] = [convert_from_extras]

    schema['category'] = [convert_from_extras]

    schema['theme'] = [convert_from_extras]

    schema['standard_name'] = [convert_from_extras]

    schema['standard_rating'] = [convert_from_extras]

    schema['standard_version'] = [convert_from_extras]

    schema['resources'] = resource_schema()

    schema['needs_approval'] = [convert_from_extras]


    return schema
Ejemplo n.º 4
0
 def show_package_schema(self):
     schema = default_show_package_schema()
     schema.update({
         'tags': {
             '__extras': [keep_extras, free_tags_only]
         },
         'vocab_tags_selected': [convert_from_tags(TEST_VOCAB_NAME), ignore_missing],
     })
     return schema
Ejemplo n.º 5
0
 def show_package_schema(self):
     schema = default_show_package_schema()
     schema.update({
         'tags': {
             '__extras': [keep_extras, free_tags_only]
         },
         'vocab_tags_selected': [convert_from_tags(TEST_VOCAB_NAME), ignore_missing],
     })
     return schema
Ejemplo n.º 6
0
def project_show_schema():
    schema = default_show_package_schema()
    schema.update({
        'country': [convert_from_extras, ignore_missing, unicode],
        'province_state': [convert_from_extras, ignore_missing, unicode],
        'district_county': [convert_from_extras, ignore_missing, unicode],
        'cadasta_id': [convert_from_extras, ignore_missing, unicode],
        'ona_api_key': [convert_from_extras, ignore_missing, unicode],
    })

    return schema
Ejemplo n.º 7
0
    def test_package_show_with_custom_schema(self):
        dataset1 = factories.Dataset()
        from ckan.logic.schema import default_show_package_schema
        custom_schema = default_show_package_schema()

        def foo(key, data, errors, context):
            data[key] = 'foo'
        custom_schema['new_field'] = [foo]

        dataset2 = helpers.call_action('package_show', id=dataset1['id'],
                                       context={'schema': custom_schema})

        eq(dataset2['new_field'], 'foo')
Ejemplo n.º 8
0
def show_package_schema():
    convert_from_extras = get_converter('convert_from_extras')
    convert_to_tags = get_converter('convert_from_tags')
    schema = default_show_package_schema()
    schema['tags']['__extras'].append(p.toolkit.get_converter('free_tags_only'))
    schema[DATASET_TYPE_VOCABULARY] = [convert_to_tags(DATASET_TYPE_VOCABULARY)]
    schema['temporal_extent'] = [convert_from_extras, ignore_missing]
    schema['update_frequency'] = [convert_from_extras, ignore_missing]
    schema['affiliation'] = [convert_from_extras, ignore_missing]
    schema['contributors'] = [convert_from_extras, ignore_missing]
    schema['promoted'] = [convert_from_extras, ignore_missing]
    # This is the same as the extras field with key=spatial for ckanext-spatial
    schema['spatial'] = [convert_from_extras, ignore_missing]
    return schema
Ejemplo n.º 9
0
    def show_package_schema(cls):
        """
        The data fields that are returned from CKAN for each dataset can be changed with this method.
        This method is called when viewing or editing a dataset.

        :rtype: schema
        """

        schema = default_show_package_schema()
        # Put back validators for several keys into the schema so validation
        # doesn't bring back the keys from the package dicts if the values are
        # 'missing' (i.e. None).
        # See few lines into 'default_show_package_schema()'
        schema['author'] = [ignore_missing]
        schema['author_email'] = [ignore_missing]
        schema['organization'] = [ignore_missing]

        for key in settings.KATA_FIELDS:
            schema[key] = [
                co.convert_from_extras_kata, ignore_missing, unicode
            ]

        schema['agent'] = [co.flattened_from_extras, ignore_missing]
        schema['contact'] = [co.flattened_from_extras, ignore_missing]
        schema['event'] = [co.flattened_from_extras, ignore_missing]
        schema['langdis'] = [unicode]
        # schema['organization'] = [ignore_missing, unicode]
        schema['pids'] = [co.flattened_from_extras, ignore_missing]
        # schema['projdis'] = [unicode]

        # co.gen_translation_str_from_extras updates the title field to show the JSON
        # translation string if old format titles are found from extras
        schema['title'] = [
            ignore_missing, co.gen_translation_str_from_extras,
            co.set_language_for_title
        ]

        schema['notes'] = [co.ensure_valid_notes]

        # schema['langtitle'] = {'value': [unicode, co.gen_translation_str_from_langtitle],
        #                        'lang': [unicode, co.convert_languages]}

        #schema['version_PID'] = [version_pid_from_extras, ignore_missing, unicode]
        schema['xpaths'] = [co.from_extras_json, ignore_missing, unicode]
        #schema['resources']['resource_type'] = [from_resource]

        return schema
Ejemplo n.º 10
0
    def show_package_schema(cls):
        """
        The data fields that are returned from CKAN for each dataset can be changed with this method.
        This method is called when viewing or editing a dataset.

        :rtype: schema
        """

        schema = default_show_package_schema()
        # Put back validators for several keys into the schema so validation
        # doesn't bring back the keys from the package dicts if the values are
        # 'missing' (i.e. None).
        # See few lines into 'default_show_package_schema()'
        schema['author'] = [ignore_missing]
        schema['author_email'] = [ignore_missing]
        schema['organization'] = [ignore_missing]

        for key in settings.KATA_FIELDS:
            schema[key] = [co.convert_from_extras_kata, ignore_missing, unicode]

        schema['__after'] = [co.check_primary_pids]
        schema['agent'] = [co.flattened_from_extras, ignore_missing]
        schema['contact'] = [co.flattened_from_extras, ignore_missing]
        schema['access_application_new_form'] = [unicode],
        schema['event'] = [co.flattened_from_extras, ignore_missing]
        schema['langdis'] = [unicode]
        # schema['organization'] = [ignore_missing, unicode]
        schema['pids'] = [co.flattened_from_extras, ignore_missing]
        # schema['projdis'] = [unicode]

        # co.gen_translation_str_from_extras updates the title field to show the JSON
        # translation string if old format titles are found from extras
        schema['title'] = [ignore_missing, co.gen_translation_str_from_extras, co.set_language_for_title]

        schema['notes'] = [co.ensure_valid_notes]

        # schema['langtitle'] = {'value': [unicode, co.gen_translation_str_from_langtitle],
        #                        'lang': [unicode, co.convert_languages]}

        #schema['version_PID'] = [version_pid_from_extras, ignore_missing, unicode]
        schema['xpaths'] = [co.from_extras_json, ignore_missing, unicode]
        #schema['resources']['resource_type'] = [from_resource]

        return schema
Ejemplo n.º 11
0
def package_show_schema():
    schema = default_show_package_schema()
    schema.update({
        'frequency_time_modifier':
        [convert_from_extras, ignore_missing, unicode],
        'frequency_count':
        [convert_from_extras, ignore_missing, is_positive_integer],
        'frequency_update_period': [convert_from_extras, ignore_missing],
        'frequency_period': [convert_from_extras, ignore_missing],

        # frequency is constructed from the other frequency_ fields
        'frequency': [collate_frequency_fields, ignore_missing],
        'retention_count':
        [convert_from_extras, ignore_missing, is_positive_integer],
        'retention_period': [convert_from_extras, ignore_missing],
        'delivery_unit': [convert_from_extras, ignore_missing],
        'service': [convert_from_extras, ignore_missing],
        'next_update': [convert_from_extras, ignore_missing],
        'review_date': [convert_from_extras, ignore_missing],
        'coverage_start_date': [convert_from_extras, ignore_missing],
        'coverage_end_date': [convert_from_extras, ignore_missing],
    })
    return schema
Ejemplo n.º 12
0
 def show_package_schema(self):
     from ckan.logic.schema import default_show_package_schema
     schema = schema_defs.show_package_schema(default_show_package_schema())
     schema.update({
         'theme-primary': [
             toolkit.get_converter('convert_from_extras'),
             toolkit.get_validator('ignore_missing')
         ],
         'licence-custom': [
             toolkit.get_converter('convert_from_extras'),
             toolkit.get_validator('ignore_missing')
         ],
         'schema-vocabulary': [
             toolkit.get_converter('convert_from_extras'),
             toolkit.get_validator('ignore_missing')
         ],
         'codelist': [
             toolkit.get_converter('convert_from_extras'),
             toolkit.get_validator('ignore_missing')
         ],
     })
     for contact_key in [
             'contact-name', 'contact-email', 'contact-phone', 'foi-name',
             'foi-email', 'foi-web', 'foi-phone'
     ]:
         schema.update({
             contact_key: [
                 toolkit.get_converter('convert_from_extras'),
                 toolkit.get_validator('ignore_missing')
             ]
         })
     schema['resources'].update({
         'resource-type': [toolkit.get_validator('ignore_missing')],
         'datafile-date': [toolkit.get_validator('ignore_missing')]
     })
     return schema
Ejemplo n.º 13
0
def package_show_schema():
    schema = default_show_package_schema()
    schema.update({
        'frequency_time_modifier': [convert_from_extras, ignore_missing,
                                    unicode],
        'frequency_count': [convert_from_extras, ignore_missing,
                            is_positive_integer],
        'frequency_update_period': [convert_from_extras, ignore_missing],
        'frequency_period': [convert_from_extras, ignore_missing],

        # frequency is constructed from the other frequency_ fields
        'frequency': [collate_frequency_fields, ignore_missing],

        'retention_count': [convert_from_extras, ignore_missing,
                            is_positive_integer],
        'retention_period': [convert_from_extras, ignore_missing],
        'delivery_unit': [convert_from_extras, ignore_missing],
        'service': [convert_from_extras, ignore_missing],
        'next_update': [convert_from_extras, ignore_missing],
        'review_date': [convert_from_extras, ignore_missing],
        'coverage_start_date': [convert_from_extras, ignore_missing],
        'coverage_end_date': [convert_from_extras, ignore_missing],
    })
    return schema
 def show_package_schema(self):
     return default_schema.default_show_package_schema()
Ejemplo n.º 15
0
 def show_package_schema(self):
     return default_schema.default_show_package_schema()
Ejemplo n.º 16
0
 def show_package_schema(self) -> Schema:
     return schema.default_show_package_schema()