Delete posix user when deleting plinth user.

This commit is contained in:
James Valleroy authored and Sunil Mohan Adapa committed 2015-01-20 12:36:02 +05:30
1 parent f3ea867e07
commit 46dd2225f7
2 files changed
+48

No files matched your search

+14
View File
@@ -19,9 +19,12 @@
Plinth module to manage users
"""
from django.db.models.signals import post_delete
from django.contrib.auth.models import User
from gettext import gettext as _
from plinth import cfg
from plinth import actions
__all__ = ['init']
@@ -33,3 +36,14 @@ def init():
menu = cfg.main_menu.get('system:index')
menu.add_urlname(_('Users and Groups'), 'glyphicon-user', 'users:index',
15)
post_delete.connect(delete_posix_user)
def delete_posix_user(sender, instance=None, **kwargs):
try:
instance
except User.DoesNotExist:
pass
else:
actions.superuser_run('delete-user', [instance.username])