diff --git a/ckanext/ecportal/logic.py b/ckanext/ecportal/logic.py index 1b774c2..8f9ba08 100644 --- a/ckanext/ecportal/logic.py +++ b/ckanext/ecportal/logic.py @@ -589,8 +589,11 @@ def user_create(context, data_dict): :returns: the newly created user :rtype: dictionary ''' - new_context = context.copy() # Don't modify caller's context - new_context['schema'] = schema.default_user_schema() + if 'schema' not in context: + new_context = context.copy() # Don't modify caller's context + new_context['schema'] = schema.default_update_user_schema() + else: + new_context = context return logic.action.create.user_create(new_context, data_dict) @@ -609,6 +612,9 @@ def user_update(context, data_dict): :rtype: dictionary ''' - new_context = context.copy() # Don't modify caller's context - new_context['schema'] = schema.default_update_user_schema() + if 'schema' not in context: + new_context = context.copy() # Don't modify caller's context + new_context['schema'] = schema.default_update_user_schema() + else: + new_context = context return logic.action.update.user_update(new_context, data_dict) diff --git a/ckanext/ecportal/schema.py b/ckanext/ecportal/schema.py index ec2b41b..3e9d401 100644 --- a/ckanext/ecportal/schema.py +++ b/ckanext/ecportal/schema.py @@ -4,29 +4,24 @@ def default_user_schema(): + # changes from core: + # - username can be uppercase + # - email is not required schema = core_schema.default_user_schema() - - # username can be uppercase schema['name'] = [navl_validators.not_empty, core_validators.user_name_validator, unicode] - - # email is not required schema['email'] = [navl_validators.default(u''), unicode] - return schema def default_update_user_schema(): schema = default_user_schema() - schema['name'] = [navl_validators.ignore_missing, core_validators.user_name_validator, unicode] - schema['password'] = [core_validators.user_password_validator, navl_validators.ignore_missing, unicode] - return schema