Mercurial > kallithea
changeset 4759:1a2e7a8d144c
user: prevent deletion of users that are owners of a user group
TODO: make it possible to reassign group ownership
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 06 Jan 2015 00:54:36 +0100 |
parents | 5f0e40fad7da |
children | 716194520cc0 |
files | kallithea/model/db.py kallithea/model/user.py |
diffstat | 2 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/model/db.py Tue Jan 06 00:54:36 2015 +0100 +++ b/kallithea/model/db.py Tue Jan 06 00:54:36 2015 +0100 @@ -422,6 +422,7 @@ repositories = relationship('Repository') repo_groups = relationship('RepoGroup') + user_groups = relationship('UserGroup') user_followers = relationship('UserFollowing', primaryjoin='UserFollowing.follows_user_id==User.user_id', cascade='all') followings = relationship('UserFollowing', primaryjoin='UserFollowing.user_id==User.user_id', cascade='all')
--- a/kallithea/model/user.py Tue Jan 06 00:54:36 2015 +0100 +++ b/kallithea/model/user.py Tue Jan 06 00:54:36 2015 +0100 @@ -269,6 +269,13 @@ 'removed. Switch owners or remove those repository groups: %s') % (user.username, len(repogroups), ', '.join(repogroups)) ) + if user.user_groups: + usergroups = [x.users_group_name for x in user.user_groups] + raise UserOwnsReposException( + _(u'User "%s" still owns %s user groups and cannot be ' + 'removed. Switch owners or remove those user groups: %s') + % (user.username, len(usergroups), ', '.join(usergroups)) + ) self.sa.delete(user) from kallithea.lib.hooks import log_delete_user