#29 make new idatasets form work with harvest source form
This commit is contained in:
parent
548d3c1c2a
commit
c754479014
|
@ -10,7 +10,7 @@ from ckan import model
|
|||
from ckan.model import Session, Package
|
||||
from ckan.logic import ValidationError, NotFound, get_action
|
||||
|
||||
from ckan.logic.schema import default_package_schema
|
||||
from ckan.logic.schema import default_create_package_schema
|
||||
from ckan.lib.navl.validators import ignore_missing,ignore
|
||||
from ckan.lib.munge import munge_title_to_name,substitute_ascii_equivalents
|
||||
|
||||
|
@ -124,7 +124,7 @@ class HarvesterBase(SingletonPlugin):
|
|||
'''
|
||||
try:
|
||||
# Change default schema
|
||||
schema = default_package_schema()
|
||||
schema = default_create_package_schema()
|
||||
schema['id'] = [ignore_missing, unicode]
|
||||
schema['__junk'] = [ignore]
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ def harvest_source_schema():
|
|||
|
||||
return schema
|
||||
|
||||
def harvest_source_form_to_db_schema():
|
||||
def harvest_source_create_package_schema():
|
||||
|
||||
schema = harvest_source_schema()
|
||||
schema['__extras'] = [harvest_source_extra_validator]
|
||||
|
@ -56,7 +56,7 @@ def harvest_source_form_to_db_schema():
|
|||
|
||||
return schema
|
||||
|
||||
def harvest_source_db_to_form_schema():
|
||||
def harvest_source_show_package_schema():
|
||||
|
||||
schema = harvest_source_schema()
|
||||
schema.update({
|
||||
|
|
|
@ -135,43 +135,35 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm):
|
|||
|
||||
p.toolkit.c.dataset_type = DATASET_TYPE_NAME
|
||||
|
||||
def form_to_db_schema_options(self, options):
|
||||
'''
|
||||
Similar to form_to_db_schema but with further options to allow
|
||||
slightly different schemas, eg for creation or deletion on the API.
|
||||
'''
|
||||
schema = self.form_to_db_schema()
|
||||
|
||||
# Tweak the default schema to allow using the same id as the harvest source
|
||||
# if creating datasets for the harvest sources
|
||||
if self.startup:
|
||||
schema['id'] = [unicode]
|
||||
return schema
|
||||
|
||||
def form_to_db_schema(self):
|
||||
def create_package_schema(self):
|
||||
'''
|
||||
Returns the schema for mapping package data from a form to a format
|
||||
suitable for the database.
|
||||
'''
|
||||
from ckanext.harvest.logic.schema import harvest_source_form_to_db_schema
|
||||
from ckanext.harvest.logic.schema import harvest_source_create_package_schema
|
||||
schema = harvest_source_create_package_schema()
|
||||
if self.startup:
|
||||
schema['id'] = [unicode]
|
||||
|
||||
return harvest_source_form_to_db_schema()
|
||||
return schema
|
||||
|
||||
def db_to_form_schema_options(self, options):
|
||||
def update_package_schema(self):
|
||||
'''
|
||||
Similar to db_to_form_schema but with further options to allow
|
||||
slightly different schemas, eg for creation or deletion on the API.
|
||||
Returns the schema for mapping package data from a form to a format
|
||||
suitable for the database.
|
||||
'''
|
||||
return self.db_to_form_schema()
|
||||
return self.create_package_schema()
|
||||
|
||||
def db_to_form_schema(self):
|
||||
|
||||
def show_package_schema(self):
|
||||
'''
|
||||
Returns the schema for mapping package data from the database into a
|
||||
format suitable for the form
|
||||
'''
|
||||
from ckanext.harvest.logic.schema import harvest_source_db_to_form_schema
|
||||
from ckanext.harvest.logic.schema import harvest_source_show_package_schema
|
||||
|
||||
return harvest_source_db_to_form_schema()
|
||||
return harvest_source_show_package_schema()
|
||||
|
||||
def check_data_dict(self, data_dict, schema=None):
|
||||
'''Check if the return data is correct, mostly for checking out
|
||||
|
|
Loading…
Reference in New Issue