Changeset - 5f0e40fad7da
[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 repo group

TODO: make it possible to reassign group ownership
2 files changed with 10 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/model/db.py
Show inline comments
 
@@ -421,6 +421,7 @@ class User(Base, BaseModel):
 
    user_perms = relationship('UserToPerm', primaryjoin="User.user_id==UserToPerm.user_id", cascade='all')
 

	
 
    repositories = relationship('Repository')
 
    repo_groups = relationship('RepoGroup')
 
    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
 
@@ -258,10 +258,17 @@ class UserModel(BaseModel):
 
        if user.repositories:
 
            repos = [x.repo_name for x in user.repositories]
 
            raise UserOwnsReposException(
 
                _(u'user "%s" still owns %s repositories and cannot be '
 
                  'removed. Switch owners or remove those repositories. %s')
 
                _(u'User "%s" still owns %s repositories and cannot be '
 
                  'removed. Switch owners or remove those repositories: %s')
 
                % (user.username, len(repos), ', '.join(repos))
 
            )
 
        if user.repo_groups:
 
            repogroups = [x.group_name for x in user.repo_groups]
 
            raise UserOwnsReposException(
 
                _(u'User "%s" still owns %s repository groups and cannot be '
 
                  'removed. Switch owners or remove those repository groups: %s')
 
                % (user.username, len(repogroups), ', '.join(repogroups))
 
            )
 
        self.sa.delete(user)
 

	
 
        from kallithea.lib.hooks import log_delete_user
0 comments (0 inline, 0 general)