Filter out deleted users and organizations from the superuser list

Superusers were getting confused because the users/orgs were being disabled and renamed, but still appeared in the list until they were GCed by the background worker. Now we just hide them.

Fixes https://jira.coreos.com/browse/QUAY-936
This commit is contained in:
Joseph Schorr 2018-05-15 09:01:20 -04:00
parent 7878435805
commit b98c65b3a3
4 changed files with 55 additions and 7 deletions

View file

@ -825,10 +825,17 @@ def get_private_repo_count(username):
.count())
def get_active_users(disabled=True):
query = User.select().where(User.organization == False, User.robot == False)
def get_active_users(disabled=True, deleted=False):
query = (User
.select()
.where(User.organization == False, User.robot == False))
if not disabled:
query = query.where(User.enabled == True)
if not deleted:
query = query.where(User.id.not_in(DeletedNamespace.select(DeletedNamespace.namespace)))
return query