users: Handle errors better during POSIX user operations

- If during an action, user does not exist ignore.

- If during an action, return a non-zero exist status.

- Catch an errors during actions as exceptions.

- Display a message that corresponding POSIX operation failed.
This commit is contained in:
Sunil Mohan Adapa committed 2015-01-25 01:45:51 +05:30
1 parent d27cd02193
commit a3de3ae277
9 files changed
+114 -35

No files matched your search

-14
View File
@@ -19,12 +19,9 @@
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']
@@ -36,14 +33,3 @@ 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])