Exemple #1
0
def resource_create(context, data_dict):
    #TODO This doesn't actually do anything

    model = context['model']
    user = context['user']

    data, errors = validate(data_dict, default_resource_schema(), context)
Exemple #2
0
def showcase_base_schema():
    schema = {
        'id': [empty],
        'revision_id': [ignore],
        'name': [not_empty, unicode, name_validator, package_name_validator],
        'title': [if_empty_same_as("name"), unicode],
        'author': [ignore_missing, unicode],
        'author_email': [ignore_missing, unicode],
        'notes': [ignore_missing, unicode],
        'url': [ignore_missing, unicode],
        'state': [ignore_not_package_admin, ignore_missing],
        'type': [ignore_missing, unicode],
        'log_message': [ignore_missing, unicode, no_http],
        '__extras': [ignore],
        '__junk': [empty],
        'resources': default_resource_schema(),
        'tags': default_tags_schema(),
        'tag_string': [ignore_missing, tag_string_convert],
        'extras': default_extras_schema(),
        'save': [ignore],
        'return_to': [ignore],
        'image_url': [toolkit.get_validator('ignore_missing'),
                      toolkit.get_converter('convert_to_extras')],
        'original_related_item_id': [
            toolkit.get_validator('ignore_missing'),
            toolkit.get_converter('convert_to_extras')]
    }
    return schema
Exemple #3
0
def resource_create(context, data_dict):
    model = context['model']
    user = context['user']

    data, errors = validate(data_dict,
                            default_resource_schema(),
                            context)
Exemple #4
0
    def db_to_form_schema(self):
        log.debug("Enter db to form")
        #c.categorization = gv.categorization
        #c.update_frequency = gv.update_frequency
        schema = logic.schema.package_form_schema()
        schema.update({
            'schema_name': [convert_from_extras, ignore_missing, unicode],
            'schema_language': [convert_from_extras, ignore_missing, unicode],
            'maintainer_link': [convert_from_extras, ignore_missing, unicode],
            'date_released': [convert_from_extras, ignore_missing, unicode],
            'begin_datetime': [convert_from_extras, ignore_missing, unicode],
            'end_datetime': [convert_from_extras, ignore_missing, unicode],
            'metadata_linkage': [convert_from_extras, ignore_missing, unicode],
            'attribute_description': [convert_from_extras, ignore_missing, unicode],
            'publisher': [convert_from_extras, ignore_missing, unicode],
            'geographic_toponym': [convert_from_extras, ignore_missing, unicode],
            'geographic_bbox': [convert_from_extras, ignore_missing, unicode],
            'lineage_quality': [convert_from_extras, ignore_missing, unicode],
            'en_title_and_desc': [convert_from_extras, ignore_missing, unicode],
            'license_citation':[convert_from_extras, ignore_missing, unicode],
            'metadata_identifier':[convert_from_extras, ignore_missing, unicode],
            'metadata_modified':[convert_from_extras, ignore_missing, unicode],
            'date_updated':[convert_from_extras, ignore_missing, unicode],
            'resources': default_schema.default_resource_schema(),
            'categorization': [convert_from_extras, ignore_missing],
            'update_frequency': [convert_from_extras, ignore_missing],
            'publishing_date': [convert_from_extras, ignore_missing],
            'publishing_state': [convert_from_extras, ignore_missing],
            'extras': {
                'key': [],
                'value': [],
                '__extras': [keep_extras]
            },
            'tags': {
                '__extras': [keep_extras]
            },
            'mandate': [convert_from_extras, ignore_missing],
            'national_statistic': [convert_from_extras, ignore_missing],
            '__extras': [keep_extras],
        })

        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],
            'language':[ignore_missing],
            'characterset':[ignore_missing]
        })
        
        return schema
Exemple #5
0
def resource_create(context, data_dict):
    #TODO This doesn't actually do anything

    model = context['model']
    user = context['user']

    data, errors = validate(data_dict,
                            default_resource_schema(),
                            context)
Exemple #6
0
def resources_schema():
    schema = default_schema.default_resource_schema()
    # don't convert values to ints - that doesn't work for extensions
    # (see conversation with John Glover)
    schema.update({
        'created': [ignore_missing],
        'position': [ignore_missing],
        'last_modified': [ignore_missing],
        'cache_last_updated': [ignore_missing],
        'webstore_last_updated': [ignore_missing]
    })
    return schema
Exemple #7
0
def resources_schema():
    schema = default_schema.default_resource_schema()
    # don't convert values to ints - that doesn't work for extensions
    # (see conversation with John Glover)
    schema.update({
        'created': [ignore_missing],
        'position': [ignore_missing],
        'last_modified': [ignore_missing],
        'cache_last_updated': [ignore_missing],
        'webstore_last_updated': [ignore_missing]
    })
    return schema
Exemple #8
0
    def form_to_db_schema(self):
        log.fatal("Enter form to db!!!")
        
        schema = {
                  'title': [if_empty_same_as("name"), unicode],
                  'name': [not_empty, unicode, val.name_validator, val.package_name_validator],
                  'license_id': [not_empty, unicode],
                  'maintainer': [ignore_missing, unicode],
                  'schema_name': [ignore_missing, unicode, convert_to_extras],
                  'maintainer_link': [ignore_missing, unicode, convert_to_extras],
                  'schema_language': [ignore_missing, unicode,convert_to_extras],
                  'schema_characterset': [ignore_missing, unicode,convert_to_extras],
                  'date_released': [ignore_missing, unicode, convert_to_extras],
                  'begin_datetime': [ignore_missing, unicode, convert_to_extras],
                  'end_datetime': [ignore_missing, unicode, convert_to_extras],
                  'metadata_linkage': [ignore_missing, unicode, convert_to_extras],
                  'attribute_description': [ignore_missing, unicode, convert_to_extras],
                  'publisher': [ignore_missing, unicode, convert_to_extras],
                  'geographic_toponym': [ignore_missing, unicode, convert_to_extras],
                  'geographic_bbox': [ignore_missing, unicode, convert_to_extras],
                  'lineage_quality': [ignore_missing, unicode, convert_to_extras],
                  'en_title_and_desc': [ignore_missing, unicode, convert_to_extras],
                  'license_citation':[ignore_missing, unicode, convert_to_extras],
                  'metadata_identifier':[ignore_missing, unicode, convert_to_extras],
                  'metadata_modified':[ignore_missing, unicode, convert_to_extras],
                  'date_updated':[ignore_missing, unicode, convert_to_extras],
                  'publishing_date':[ignore_missing, unicode, convert_to_extras],
                  'publishing_state':[ignore_missing, unicode, convert_to_extras],
                  'url': [ignore_missing, unicode],
                  'resources': default_schema.default_resource_schema(),
                  'state': [val.ignore_not_admin, ignore_missing],
                  'log_message': [unicode, val.no_http],
                  '__extras': [ignore], 
                  'revision_id': [ignore],
                  'update_frequency': [ignore_missing, unicode, convert_to_extras],
                  'categorization': [ignore_missing, unicode, self.add_to_extras],
                  'notes': [ignore_missing, unicode],
                  'tag_string': [ignore_missing, val.tag_string_convert],
                  'groups': {
                             'id': [ignore_missing, unicode],
                             'capacity': [ignore_missing, unicode],
                             '__extras': [ignore],
                            },
                  }
        
        schema['resources'].update({
                    'language':[ignore_missing], 
                    'characterset':[ignore_missing]
                       })


        return schema
Exemple #9
0
    def form_to_db_schema_options(self, package_type=None, options=None):
        schema = form_to_db_package_schema()
        for key in self.kata_fields_required:
            schema[key] = [not_empty, self.convert_to_extras_kata, unicode]
        for key in self.kata_fields_recommended:
            schema[key] = [ignore_missing, self.convert_to_extras_kata, unicode]
        schema['temporal_coverage_begin'].append(validate_lastmod)
        schema['temporal_coverage_end'].append(validate_lastmod)
        schema['language'] = [validate_language, self.convert_to_extras_kata, unicode]
        schema['phone'].append(validate_phonenum)
        schema['maintainer_email'].append(validate_email)
        schema['tag_string'].append(not_empty)
        schema.update({
           'version': [not_empty, unicode, validate_lastmod, check_last_and_update_pid],
           'versionPID': [self.update_pid, unicode, self.pid_to_extras],
           'author': {'value': [not_empty, unicode, org_auth_to_extras]},
           'organization': {'value': [not_empty, unicode, org_auth_to_extras]},
           'access': [not_missing, self.convert_to_extras_kata, validate_access],
           'accessRights': [ignore_missing, self.convert_to_extras_kata, unicode],
           'langdis': [default(False), unicode],
           '__extras': [check_author_org],
           'projdis': [default(False), unicode, check_project],
           '__junk': [check_junk],
           'name': [unicode, ignore_missing, self.update_name],
           'accessRights': [check_accessrights, self.convert_to_extras_kata, unicode],
           'accessrequestURL': [check_accessrequesturl, self.convert_to_extras_kata, unicode],
           'project_name': [check_project_dis, unicode, self.convert_to_extras_kata],
           'funder': [check_project_dis, unicode, self.convert_to_extras_kata],
           'project_funding': [check_project_dis, unicode, self.convert_to_extras_kata],
           'project_homepage': [check_project_dis, unicode, self.convert_to_extras_kata],
           'resources': default_resource_schema(),
           'discipline': [add_to_group],
        })
        schema['title'] = {'value': [not_missing, ltitle_to_extras],
                           'lang': [not_missing]}

        schema['evtype'] = {'value': [ignore_missing, unicode, event_to_extras]}
        schema['evwho'] = {'value': [ignore_missing, unicode, event_to_extras]}
        schema['evwhen'] = {'value': [ignore_missing, unicode, event_to_extras]}
        schema['evdescr'] = {'value': [ignore_missing, unicode, event_to_extras]}
        schema['groups'] = {
                'id': [ignore_missing, unicode],
                'name': [ignore_missing, unicode],
                'title': [ignore_missing, unicode],
                '__extras': [ignore],
            }
        return schema
def _modify_resource_schema():
    # Mandatory fields

    schema = default_resource_schema()

    schema['package_id'] = [ignore_missing]

    schema['name'] = [not_empty, string_max_length(255), unicode]

    schema['description'] = [not_empty, string_max_length(64000), unicode]

    schema['format'] = [not_empty, string_max_length(255), unicode]

    schema['url'] = [url_or_upload_not_empty, ignore_missing, unicode]

    schema['upload'] = [url_or_upload_not_empty, ignore_missing]

    # Optional fields

    schema['license_id'] = [ignore_missing, unicode]

    schema['openness_rating'] = [ignore_missing, int_validator, int_range(0, 5)
                                 ]

    schema['quality'] = [ignore_missing, int_validator, int_range(0, 5)]

    schema['standard_name'] = [ignore_missing, string_max_length(255), unicode]

    schema['standard_rating'] = [ignore_missing, int_validator, int_range(0, 5)
                                 ]

    schema['standard_version'] = [ignore_missing, string_max_length(255),
                                  unicode]

    schema['creation_date'] = [ignore_missing, iso_date, unicode]

    schema['extras'] = custom_resource_extras_schema()

    # Internal fields

    schema['ec_api_version_id'] = [ignore_missing, unicode]

    return schema
    'owner_org': {'ui_options': ['sort_choices'],},
    'license_id': {'ui_options': ['disabled'],},
    'resource:size': {'ui_options': ['hidden'],}
    }

# Resource fields (no sections)
RESOURCE_FIELDS = [
    'name',
    'resource_type',
    'url',
    'size',
    'format',
    'language',
    ]

EXISTING_RESOURCE_FIELDS = set(default_resource_schema())

BILINGUAL_RESOURCE_FIELDS = set([
    'name',
    ])

EXISTING_FIELDS = set(default_create_package_schema()
    ) | set(['spatial'])

# The field order here must match the proposed schema spreadsheet
ProposedField = namedtuple("ProposedField", """
    class_
    sub_class
    property_name
    property_label
    iso_multiplicity
from .user_creation import helpers as user_creation_helpers

import plugin
from authenticator import unlock_account, LOGIN_THROTTLE_EXPIRY

LOG = getLogger(__name__)

LOGGED_IN = UserController.logged_in
PACKAGE_EDIT = PackageController._save_edit
RESOURCE_EDIT = PackageController.resource_edit

DEFAULT_USER_SCHEMA = schemas.default_user_schema()
USER_NEW_FORM_SCHEMA = schemas.user_new_form_schema()
USER_EDIT_FORM_SCHEMA = schemas.user_edit_form_schema()
DEFAULT_UPDATE_USER_SCHEMA = schemas.default_update_user_schema()
RESOURCE_SCHEMA = schemas.default_resource_schema()

UPLOAD = Upload.upload
if storage_enabled:
    STORAGE_DOWNLOAD = StorageController.file
RESOURCE_DOWNLOAD = PackageController.resource_download

EMAIL_REGEX = re.compile(r"[^@]+@[^@]+\.[^@]+")


def configure(config):
    global password_min_length
    global password_patterns

    password_min_length = int(config.get('password_min_length', '10'))
    password_patterns = config.get(
Exemple #13
0
def resource_create(context, data_dict):
    model = context['model']
    user = context['user']

    data, errors = validate(data_dict, default_resource_schema(), context)
Exemple #14
0
def showcase_base_schema():
    schema = {
        'id': [empty],
        'revision_id': [ignore],
        'name': [not_empty, unicode, name_validator, package_name_validator],
        'title': [if_empty_same_as("name"), unicode],
        'author': [ignore_missing, unicode],
        'author_email': [ignore_missing, unicode],
        'notes': [ignore_missing, unicode],
        'url': [ignore_missing, unicode],
        'state': [ignore_not_package_admin, ignore_missing],
        'type': [ignore_missing, unicode],
        'log_message': [ignore_missing, unicode, no_http],
        '__extras': [ignore],
        '__junk': [empty],
        'resources': default_resource_schema(),
        'tags': default_tags_schema(),
        'tag_string': [ignore_missing, tag_string_convert],
        'extras': default_extras_schema(),
        'save': [ignore],
        'return_to': [ignore],
        'groups': [ignore_missing, convert_group_names_to_group_objects],
    }

    # Extras
    schema['image_url'] = [
        toolkit.get_validator('ignore_missing'),
        toolkit.get_converter('convert_to_extras')
    ]
    schema['original_related_item_id'] = [
        toolkit.get_validator('ignore_missing'),
        toolkit.get_converter('convert_to_extras')
    ]
    schema['related_datasets'] = [
        toolkit.get_validator('ignore_missing'),
        toolkit.get_converter('convert_to_extras')
    ]
    schema['related_stories'] = [
        toolkit.get_validator('ignore_missing'),
        toolkit.get_converter('convert_to_extras')
    ]
    schema['story_date'] = [
        toolkit.get_validator('ignore_missing'),
        toolkit.get_converter('convert_to_extras')
    ]
    schema['story_type'] = [
        toolkit.get_validator('ignore_missing'),
        toolkit.get_converter('convert_to_extras')
    ]
    schema['methodology'] = [
        toolkit.get_validator('ignore_missing'),
        toolkit.get_converter('convert_to_extras')
    ]
    schema['spatial_text'] = [
        toolkit.get_validator('ignore_missing'),
        toolkit.get_converter('convert_to_extras')
    ]
    schema['author_title'] = [
        toolkit.get_validator('ignore_missing'),
        toolkit.get_converter('convert_to_extras')
    ]
    schema['author_workplace'] = [
        toolkit.get_validator('ignore_missing'),
        toolkit.get_converter('convert_to_extras')
    ]
    schema['author_profile'] = [
        toolkit.get_validator('ignore_missing'),
        toolkit.get_converter('convert_to_extras')
    ]

    # Extras (conditional)
    if config.get('disqus.name'):
        schema['allow_commenting'] = [
            toolkit.get_validator('ignore_missing'),
            toolkit.get_validator('boolean_validator'),
            toolkit.get_converter('convert_to_extras')
        ]

    return schema
Exemple #15
0
    'resource:size': {
        'ui_options': ['hidden'],
    }
}

# Resource fields (no sections)
RESOURCE_FIELDS = [
    'name',
    'resource_type',
    'url',
    'size',
    'format',
    'language',
]

EXISTING_RESOURCE_FIELDS = set(default_resource_schema())

BILINGUAL_RESOURCE_FIELDS = set([
    'name',
])

EXISTING_FIELDS = set(default_create_package_schema()) | set(['spatial'])

# The field order here must match the proposed schema spreadsheet
ProposedField = namedtuple(
    "ProposedField", """
    class_
    sub_class
    property_name
    property_label
    iso_multiplicity