Example #1
0
    def show_package_schema(self):
        schema = super(ECPortalDatasetForm, self).show_package_schema()
        schema['tags']['__extras'].append(tk.get_converter('free_tags_only'))
        schema.update({
            'id': [tk.get_validator('ignore_missing'), unicode],
            'alternative_title': [tk.get_converter('convert_from_extras'), tk.get_validator('ignore_missing')],
            'status': [tk.get_converter('convert_from_tags')(STATUS_VOCAB_NAME), tk.get_validator('ignore_missing')],
            'identifier': [tk.get_converter('convert_from_extras'), tk.get_validator('ignore_missing')],
            'interoperability_level': [tk.get_converter('convert_from_tags')(INTEROP_VOCAB_NAME),
                                       tk.get_validator('ignore_missing')],
            'type_of_dataset': [tk.get_converter('convert_from_tags')(DATASET_TYPE_VOCAB_NAME),
                                tk.get_validator('ignore_missing')],
            'capacity': [convert_from_groups('capacity')],
            'release_date': [tk.get_converter('convert_from_extras'), tk.get_validator('ignore_missing')],
            'modified_date': [tk.get_converter('convert_from_extras'), tk.get_validator('ignore_missing')],
            'accrual_periodicity': [tk.get_converter('convert_from_extras'), tk.get_validator('ignore_missing')],
            'temporal_coverage_from': [tk.get_converter('convert_from_extras'), tk.get_validator('ignore_missing')],
            'temporal_coverage_to': [tk.get_converter('convert_from_extras'), tk.get_validator('ignore_missing')],
            'temporal_granularity': [tk.get_converter('convert_from_tags')(TEMPORAL_VOCAB_NAME),
                                     tk.get_validator('ignore_missing')],
            'geographical_coverage': [tk.get_converter('convert_from_tags')(GEO_VOCAB_NAME),
                                      tk.get_validator('ignore_missing')],
            'concepts_eurovoc': [helpers.filter_tags(EUROVOC_CONCEPTS_VOCAB_NAME),
                                 tk.get_validator('ignore_missing')],
            'domains_eurovoc': [helpers.filter_tags(EUROVOC_DOMAINS_VOCAB_NAME),
                                tk.get_validator('ignore_missing')],
            'language': [tk.get_converter('convert_from_tags')(LANGUAGE_VOCAB_NAME),
                         tk.get_validator('ignore_missing')],
            'metadata_language': [tk.get_converter('convert_from_extras'), tk.get_validator('ignore_missing')],
            'version_description': [tk.get_converter('convert_from_extras'), tk.get_validator('ignore_missing')],
            'rdf': [tk.get_converter('convert_from_extras'), tk.get_validator('ignore_missing')],
            'contact_name': [tk.get_converter('convert_from_extras'), tk.get_validator('ignore_missing')],
            'contact_email': [tk.get_converter('convert_from_extras'), tk.get_validator('ignore_missing')],
            'contact_address': [tk.get_converter('convert_from_extras'), tk.get_validator('ignore_missing')],
            'contact_telephone': [tk.get_converter('convert_from_extras'), tk.get_validator('ignore_missing')],
            'contact_webpage': [tk.get_converter('convert_from_extras'), tk.get_validator('ignore_missing')],
            'license_url': [tk.get_validator('ignore_missing')],
            'license_title': [tk.get_validator('ignore_missing')],
            'views_total': [tk.get_validator('ignore_missing')],
            'download_total': [tk.get_validator('ignore_missing')],
            'metadata_created': [tk.get_validator('ignore_missing')],
            'metadata_modified': [tk.get_validator('ignore_missing')],
            '__after': [tk.get_validator('duplicate_extras_key'),
                        rename('tags', 'keywords'),
                        rename('notes', 'description')]
        })

        schema['resources'].update({
            'created': [tk.get_validator('ignore_missing')],
            'position': [],
            'last_modified': [tk.get_validator('ignore_missing')],
            'cache_last_updated': [tk.get_validator('ignore_missing')],
            'webstore_last_updated': [tk.get_validator('ignore_missing')],
            'download_total_resource':[tk.get_validator('ignore_missing')],
            'iframe_code': [tk.get_validator('ignore_missing')]
        })
        # schema['groups'].update({
        #     'type': [tk.get_validator('ignore_missing')],
        # })
        return schema
Example #2
0
    def db_to_form_schema(data, package_type=None):
        schema = logic.schema.package_form_schema()
        schema.update({
            'id': [ignore_missing, unicode],
            'tags': {
                '__extras': [keep_extras, free_tags_only]
            },
            'alternative_title': [convert_from_extras, ignore_missing],
            'status': [convert_from_tags(STATUS_VOCAB_NAME), ignore_missing],
            'identifier': [convert_from_extras, ignore_missing],
            'interoperability_level': [convert_from_tags(INTEROP_VOCAB_NAME),
                                       ignore_missing],
            'type_of_dataset': [convert_from_tags(DATASET_TYPE_VOCAB_NAME),
                                ignore_missing],
            'published_by': [convert_from_groups('name')],
            'capacity': [convert_from_groups('capacity')],
            'release_date': [convert_from_extras, ignore_missing],
            'modified_date': [convert_from_extras, ignore_missing],
            'accrual_periodicity': [convert_from_extras, ignore_missing],
            'temporal_coverage_from': [convert_from_extras, ignore_missing],
            'temporal_coverage_to': [convert_from_extras, ignore_missing],
            'temporal_granularity': [convert_from_tags(TEMPORAL_VOCAB_NAME),
                                     ignore_missing],
            'geographical_coverage': [convert_from_tags(GEO_VOCAB_NAME),
                                      ignore_missing],
            'language': [convert_from_tags(LANGUAGE_VOCAB_NAME),
                         ignore_missing],
            'metadata_language': [convert_from_extras, ignore_missing],
            'version_description': [convert_from_extras, ignore_missing],
            'rdf': [convert_from_extras, ignore_missing],
            'contact_name': [convert_from_extras, ignore_missing],
            'contact_email': [convert_from_extras, ignore_missing],
            'contact_address': [convert_from_extras, ignore_missing],
            'contact_telephone': [convert_from_extras, ignore_missing],
            'contact_webpage': [convert_from_extras, ignore_missing],
            'license_url': [ignore_missing],
            'license_title': [ignore_missing],
            'metadata_created': [ignore_missing],
            'metadata_modified': [ignore_missing],
            '__after': [duplicate_extras_key,
                        rename('tags', 'keywords'),
                        rename('notes', 'description')]
        })

        schema['groups'].update({
            'name': [not_empty, unicode],
            'title': [ignore_missing],
            'capacity': [ignore_missing, unicode]
        })

        schema['resources'].update({
            'created': [ignore_missing],
            'position': [not_empty],
            'last_modified': [ignore_missing],
            'cache_last_updated': [ignore_missing],
            'webstore_last_updated': [ignore_missing]
        })

        return schema
Example #3
0
    def form_to_db_schema(self, package_type=None):
        schema = logic.schema.package_form_schema()
        schema.update({
            'name': [not_empty, unicode, ecportal_name_validator,
                     package_name_validator],
            'license_id': [ignore_missing, reduce_list, map_licenses, unicode],
            'keyword_string': [ignore_missing, keyword_string_convert],
            'alternative_title': [ignore_missing, unicode, convert_to_extras],
            'description': [not_empty, unicode],
            'status': [not_empty, convert_to_tags(STATUS_VOCAB_NAME)],
            'identifier': [ignore_missing, unicode, convert_to_extras],
            'interoperability_level': [ignore_missing, convert_to_tags(INTEROP_VOCAB_NAME)],
            'type_of_dataset': [ignore_missing, convert_to_tags(DATASET_TYPE_VOCAB_NAME)],
            'published_by': [not_empty, unicode, publisher_exists,
                             convert_to_groups('name')],
            'capacity': [ignore_missing, unicode, default(u'private'),
                         convert_to_groups('capacity')],
            'release_date': [ignore_missing, ecportal_date_to_db, convert_to_extras],
            'modified_date': [ignore_missing, ecportal_date_to_db, convert_to_extras],
            'accrual_periodicity': [ignore_missing, unicode, convert_to_extras],
            'temporal_coverage_from': [ignore_missing, ecportal_date_to_db,
                                       convert_to_extras],
            'temporal_coverage_to': [ignore_missing, ecportal_date_to_db,
                                     convert_to_extras],
            'temporal_granularity': [ignore_missing, convert_to_tags(TEMPORAL_VOCAB_NAME)],
            'geographical_coverage': [ignore_missing, convert_to_tags(GEO_VOCAB_NAME)],
            'language': [ignore_missing, convert_to_tags(LANGUAGE_VOCAB_NAME)],
            'metadata_language': [ignore_missing, member_of_vocab(LANGUAGE_VOCAB_NAME), convert_to_extras],
            'version_description': [ignore_missing, unicode, convert_to_extras],
            'rdf': [ignore_missing, unicode, update_rdf, convert_to_extras],
            'contact_name': [ignore_missing, unicode, convert_to_extras],
            'contact_email': [ignore_missing, requires_field('contact_name'),
                              unicode, convert_to_extras],
            'contact_address': [ignore_missing, requires_field('contact_name'),
                                unicode, convert_to_extras],
            'contact_telephone': [ignore_missing, requires_field('contact_name'),
                                  unicode, convert_to_extras],
            'contact_webpage': [ignore_missing, requires_field('contact_name'),
                                unicode, convert_to_extras],
            '__after': [duplicate_extras_key,
                        rename('keywords', 'tags'),
                        rename('description', 'notes')],
        })

        schema['groups'].update({
            'capacity': [ignore_missing, unicode]
        })

        schema['resources'].update({
            'type': [ignore_missing, unicode, convert_resource_type]
        })

        return schema
Example #4
0
    def _modify_package_schema(self, schema):
        helpers.tags = None
        schema.update({
            'name': [unicode, ecportal_name_validator,
                     tk.get_validator('package_name_validator')],
            'license_id': [tk.get_validator('ignore_missing'), reduce_list, map_licenses, unicode],
            'keyword_string': [tk.get_validator('ignore_missing'), keyword_string_convert],
            'alternative_title': [tk.get_validator('ignore_missing'), unicode, tk.get_converter('convert_to_extras')],
            'capacity': [tk.get_validator('ignore_missing'), unicode, tk.get_validator('default')(u'private'),
                         convert_to_groups('capacity')],
            'description': [unicode, ecportal_description_validator],
            'url': [unicode, ecportal_uri_validator],
            'status': [tk.get_converter('convert_to_tags')(STATUS_VOCAB_NAME)],
            'identifier': [tk.get_validator('ignore_missing'), unicode, tk.get_converter('convert_to_extras')],
            'interoperability_level': [tk.get_validator('ignore_missing'),
                                       tk.get_converter('convert_to_tags')(INTEROP_VOCAB_NAME)],
            'type_of_dataset': [tk.get_validator('ignore_missing'),
                                tk.get_converter('convert_to_tags')(DATASET_TYPE_VOCAB_NAME)],
            'release_date': [tk.get_validator('ignore_missing'), ecportal_date_to_db,
                             tk.get_converter('convert_to_extras')],
            'modified_date': [tk.get_validator('ignore_missing'), ecportal_date_to_db,
                              tk.get_converter('convert_to_extras')],
            'accrual_periodicity': [tk.get_validator('ignore_missing'), unicode,
                                    tk.get_converter('convert_to_extras')],
            'temporal_coverage_from': [tk.get_validator('ignore_missing'), ecportal_date_to_db,
                                       tk.get_converter('convert_to_extras')],
            'temporal_coverage_to': [tk.get_validator('ignore_missing'), ecportal_date_to_db,
                                     tk.get_converter('convert_to_extras')],
            'temporal_granularity': [tk.get_validator('ignore_missing'),
                                     tk.get_converter('convert_to_tags')(TEMPORAL_VOCAB_NAME)],
            'geographical_coverage': [tk.get_validator('ignore_missing'),
                                      tk.get_converter('convert_to_tags')(GEO_VOCAB_NAME)],
            'concepts_eurovoc': [tk.get_validator('ignore_missing'),
                                 tk.get_converter('convert_to_tags')(EUROVOC_CONCEPTS_VOCAB_NAME)],
            'language': [tk.get_validator('ignore_missing'), tk.get_converter('convert_to_tags')(LANGUAGE_VOCAB_NAME)],
            'metadata_language': [tk.get_validator('ignore_missing'),
                                  member_of_vocab(LANGUAGE_VOCAB_NAME),
                                  tk.get_converter('convert_to_extras')],
            'version_description': [tk.get_validator('ignore_missing'), unicode,
                                    tk.get_converter('convert_to_extras')],
            'rdf': [tk.get_validator('ignore_missing'), unicode, update_rdf, tk.get_converter('convert_to_extras')],
            'contact_name': [tk.get_validator('ignore_missing'), unicode, tk.get_converter('convert_to_extras')],
            'contact_email': [tk.get_validator('ignore_missing'), requires_field('contact_name'),
                              unicode, tk.get_converter('convert_to_extras')],
            'contact_address': [tk.get_validator('ignore_missing'), requires_field('contact_name'),
                                unicode, tk.get_converter('convert_to_extras')],
            'contact_telephone': [tk.get_validator('ignore_missing'),
                                  requires_field('contact_name'),
                                  unicode, tk.get_converter('convert_to_extras')],
            'contact_webpage': [tk.get_validator('ignore_missing'), requires_field('contact_name'),
                                unicode, tk.get_converter('convert_to_extras')],
            'groups': [tk.get_validator('ignore_missing'), requires_field('groups'),
                       unicode, tk.get_converter('convert_to_extras')],
            '__after': [duplicate_extras_key,
                        rename('keywords', 'tags'),
                        rename('description', 'notes')],
        })

        # TODO: check if this still relevant in new model
        # schema['groups'].update({
        #     'type': [tk.get_validator('ignore_missing'), unicode, convert_resource_type]
        # })
        return schema