aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilo Casagrande <milo@ubuntu.com>2013-05-17 19:09:50 +0200
committerMilo Casagrande <milo@ubuntu.com>2013-05-17 19:09:50 +0200
commit73a0d43b8cec8b9d8c08f5a94a4c18360a360da7 (patch)
tree67644003ee0fff1c7146451945a1f75c92908aa4
parente04b375ed1acc33c3d2ab4878dc381e99bdbb597 (diff)
Fixed a problem with validators.
* We were getting a KeyError when the file system group does not exists.
-rw-r--r--rhodecode/model/validators.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/rhodecode/model/validators.py b/rhodecode/model/validators.py
index 18825bb6..48c58e49 100644
--- a/rhodecode/model/validators.py
+++ b/rhodecode/model/validators.py
@@ -486,7 +486,13 @@ def CanWriteGroup(old_data=None):
val = HasReposGroupPermissionAny('group.write', 'group.admin')
can_create_repos = HasPermissionAny('hg.admin', 'hg.create.repository')
forbidden = not val(gr_name, 'can write into group validator')
- value_changed = old_data['repo_group'].get('group_id') != safe_int(value)
+ # Linaro changes: we were getting a KeyError when creating new
+ # repository: this might happen when the repo_group has not been
+ # created yet on the system.
+ value_changed = False
+ repo_group = old_data.get('repo_group', None)
+ if repo_group:
+ value_changed = repo_group.get('group_id') != safe_int(value)
if value_changed: # do check if we changed the value
#parent group need to be existing
if gr and forbidden: