Skip to content

Commit

Permalink
[#2375] Fix broken organization_name_validator
Browse files Browse the repository at this point in the history
This function was crashing when example_iorganizationform plugin was
active (when no such plugin is active this validator function doesn't
seem to get used so wasn't causing a problem)
  • Loading branch information
Sean Hammond committed Sep 13, 2012
1 parent 49f26e9 commit 96166d9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ckan/logic/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,12 @@ def organization_name_validator(key, data, errors, context):
organization = context.get('organization')

query = session.query(model.Group.name).filter_by(name=data[key])
if group:
group_id = organization.id
if organization:
organization_id = organization.id
else:
group_id = data.get(key[:-1] + ('id',))
if group_id and group_id is not missing:
query = query.filter(model.Group.id <> group_id)
organization_id = data.get(key[:-1] + ('id',))
if organization_id and organization_id is not missing:
query = query.filter(model.Group.id != organization_id)
result = query.first()
if result:
errors[key].append(_('Organization name already exists in database'))
Expand Down

0 comments on commit 96166d9

Please sign in to comment.