diff --git a/data/model/user.py b/data/model/user.py index 1079f8e0d..d05ea1693 100644 --- a/data/model/user.py +++ b/data/model/user.py @@ -651,9 +651,12 @@ def detach_external_login(user, service_name): def delete_user(user): - user.delete_instance(recursive=True, delete_nullable=True) + # Delete any repositories under the user's namespace. + for repo in list(Repository.select().where(Repository.namespace_user == user)): + repository.purge_repository(user.username, repo.name) - # TODO: also delete any repository data associated + # Delete the user itself. + user.delete_instance(recursive=True, delete_nullable=True) def get_pull_credentials(robotname):