Skip to content

Commit

Permalink
Fix bug where web UI user edit schema was not
Browse files Browse the repository at this point in the history
being used in validation
  • Loading branch information
johnglover committed Sep 26, 2013
1 parent a5ebd81 commit be791f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
14 changes: 10 additions & 4 deletions ckanext/ecportal/logic.py
Expand Up @@ -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)


Expand All @@ -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)
11 changes: 3 additions & 8 deletions ckanext/ecportal/schema.py
Expand Up @@ -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

0 comments on commit be791f8

Please sign in to comment.