Changeset - 1a2e7a8d144c
[Not reviewed]
default
0 2 0
Mads Kiilerich - 11 years ago 2015-01-06 00:54:36
madski@unity3d.com
user: prevent deletion of users that are owners of a user group

TODO: make it possible to reassign group ownership
2 files changed with 8 insertions and 0 deletions:
0 comments (0 inline, 0 general)
kallithea/model/db.py
Show inline comments
 
@@ -422,6 +422,7 @@ class User(Base, BaseModel):
 

	
 
    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')
 

	
kallithea/model/user.py
Show inline comments
 
@@ -269,6 +269,13 @@ class UserModel(BaseModel):
 
                  '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
0 comments (0 inline, 0 general)