# HG changeset patch # User Marcin Kuzminski # Date 2013-04-10 16:03:11 # Node ID 8a40028eaf73011837470053c3299013b6386aef # Parent a8f520540ab05b5886e5d595d97a84a32718d4ed fixed overwrite default user group permission flag diff --git a/rhodecode/model/forms.py b/rhodecode/model/forms.py --- a/rhodecode/model/forms.py +++ b/rhodecode/model/forms.py @@ -319,6 +319,7 @@ def DefaultPermissionsForm(repo_perms_ch filter_extra_fields = True overwrite_default_repo = v.StringBoolean(if_missing=False) overwrite_default_group = v.StringBoolean(if_missing=False) + overwrite_default_user_group = v.StringBoolean(if_missing=False) anonymous = v.StringBoolean(if_missing=False) default_repo_perm = v.OneOf(repo_perms_choices) default_group_perm = v.OneOf(group_perms_choices) diff --git a/rhodecode/model/permission.py b/rhodecode/model/permission.py --- a/rhodecode/model/permission.py +++ b/rhodecode/model/permission.py @@ -30,7 +30,7 @@ from sqlalchemy.exc import DatabaseError from rhodecode.model import BaseModel from rhodecode.model.db import User, Permission, UserToPerm, UserRepoToPerm,\ - UserRepoGroupToPerm + UserRepoGroupToPerm, UserUserGroupToPerm from rhodecode.lib.utils2 import str2bool log = logging.getLogger(__name__) @@ -145,6 +145,16 @@ class PermissionModel(BaseModel): g2p.permission = _def self.sa.add(g2p) + if form_result['overwrite_default_user_group'] == True: + _def_name = form_result['default_user_group_perm'].split('usergroup.')[-1] + # groups + _def = Permission.get_by_key('usergroup.' + _def_name) + for g2p in self.sa.query(UserUserGroupToPerm)\ + .filter(UserUserGroupToPerm.user == perm_user)\ + .all(): + g2p.permission = _def + self.sa.add(g2p) + self.sa.commit() except (DatabaseError,): log.error(traceback.format_exc())