Example #1
0
 def db_to_form_schema(self):
     schema = package_form_schema()
     schema.update({
         'tags': {
             '__extras': [keep_extras, free_tags_only]
         },
         'vocab_tags_selected': [convert_from_tags(TEST_VOCAB_NAME), ignore_missing],
     })
     return schema
Example #2
0
 def form_to_db_schema(self):
     """
     Returns the schema for mapping package data from a form to a format
     suitable for the database.
     """
     schema = package_form_schema()
     schema.update({
         'published_by': [ignore_missing, unicode, convert_to_extras],
         'genre_tags': [ignore_missing, convert_to_tags(GENRE_VOCAB)],
         'composer_tags': [ignore_missing, convert_to_tags(COMPOSER_VOCAB)]
     })
     return schema
Example #3
0
    def _check_data_dict(self, data_dict):
        '''Check if the return data is correct, mostly for checking out if
        spammers are submitting only part of the form'''

        surplus_keys_schema = ['__extras', '__junk', 'state', 'groups',
                               'extras_validation', 'save', 'preview',
                               'return_to']

        schema_keys = package_form_schema().keys()
        keys_in_schema = set(schema_keys) - set(surplus_keys_schema)

        if keys_in_schema - set(data_dict.keys()):
            log.info('incorrect form fields posted')
            raise DataError(data_dict)
Example #4
0
 def form_to_db_schema(self):
     """
     Returns the schema for mapping package data from a form to a format
     suitable for the database.
     """
     schema = package_form_schema()
     schema.update({
         'published_by': [ignore_missing, unicode, convert_to_extras],
         'genre_tags': [ignore_missing,
                        convert_to_tags(GENRE_VOCAB)],
         'composer_tags': [ignore_missing,
                           convert_to_tags(COMPOSER_VOCAB)]
     })
     return schema
Example #5
0
    def _check_data_dict(self, data_dict):
        '''Check if the return data is correct, mostly for checking out if
        spammers are submitting only part of the form'''

        # Resources might not exist yet (eg. Add Dataset)
        surplus_keys_schema = ['__extras', '__junk', 'state', 'groups',
                               'extras_validation', 'save', 'return_to',
                               'resources']

        schema_keys = package_form_schema().keys()
        keys_in_schema = set(schema_keys) - set(surplus_keys_schema)

        missing_keys = keys_in_schema - set(data_dict.keys())

        if missing_keys:
            #print data_dict
            #print missing_keys
            log.info('incorrect form fields posted')
            raise DataError(data_dict)
Example #6
0
    def _check_data_dict(self, data_dict):
        '''Check if the return data is correct, mostly for checking out if
        spammers are submitting only part of the form'''

        # Resources might not exist yet (eg. Add Dataset)
        surplus_keys_schema = ['__extras', '__junk', 'state', 'groups',
                               'extras_validation', 'save', 'return_to',
                               'resources']

        schema_keys = package_form_schema().keys()
        keys_in_schema = set(schema_keys) - set(surplus_keys_schema)

        missing_keys = keys_in_schema - set(data_dict.keys())

        if missing_keys:
            #print data_dict
            #print missing_keys
            log.info('incorrect form fields posted')
            raise DataError(data_dict)
Example #7
0
 def db_to_form_schema(self):
     """
     Returns the schema for mapping package data from the database into a
     format suitable for the form (optional)
     """
     schema = package_form_schema()
     schema.update({
         'tags': {
             '__extras': [keep_extras, free_tags_only]
         },
         'genre_tags_selected':
         [convert_from_tags(GENRE_VOCAB), ignore_missing],
         'composer_tags_selected':
         [convert_from_tags(COMPOSER_VOCAB), ignore_missing],
         'published_by': [convert_from_extras, ignore_missing],
     })
     schema['groups'].update({
         'name': [not_empty, unicode],
         'title': [ignore_missing]
     })
     return schema
Example #8
0
    def db_to_form_schema(self):
        schema = package_form_schema()

        # Configuration to get working the extension
        schema.update({
            'id': [ignore_missing, unicode],
            'isopen': [ignore_missing],
        })

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

        # SourcePlanet customization
        schema.update({
            'dataset_type': [ignore_missing],
            'evaluations': evaluation_model,
        })

        return schema
Example #9
0
    def db_to_form_schema(self):
        schema = package_form_schema()

        # Configuration to get working the extension
        schema.update({
            'id': [ignore_missing, unicode],
            'isopen': [ignore_missing],
        })

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

        # SourcePlanet customization
        schema.update({
            'dataset_type': [ignore_missing],
            'evaluations': evaluation_model,
        })

        return schema
Example #10
0
 def db_to_form_schema(self):
     """
     Returns the schema for mapping package data from the database into a
     format suitable for the form (optional)
     """
     schema = package_form_schema()
     schema.update({
         'tags': {
             '__extras': [keep_extras, free_tags_only]
         },
         'genre_tags_selected': [
             convert_from_tags(GENRE_VOCAB), ignore_missing
         ],
         'composer_tags_selected': [
             convert_from_tags(COMPOSER_VOCAB), ignore_missing
         ],
         'published_by': [convert_from_extras, ignore_missing],
     })
     schema['groups'].update({
         'name': [not_empty, unicode],
         'title': [ignore_missing]
     })
     return schema
Example #11
0
 def form_to_db_schema(self):
     """
     Returns the schema for mapping package data from a form to a format
     suitable for the database.
     """
     return package_form_schema()
Example #12
0
 def _form_to_db_schema(self):
     return package_form_schema()
Example #13
0
 def _form_to_db_schema(self):
     return package_form_schema()
Example #14
0
 def form_to_db_schema(self):
     """
     Returns the schema for mapping package data from a form to a format
     suitable for the database.
     """
     return package_form_schema()
Example #15
0
 def form_to_db_schema(self):
     schema = package_form_schema()
     schema.update({
         'vocab_tags': [ignore_missing, convert_to_tags(TEST_VOCAB_NAME)],
     })
     return schema