users: Add posix user messages to other user management forms

- Slightly modify the message in user update form
This commit is contained in:
Sunil Mohan Adapa 2015-01-25 01:31:05 +05:30
parent baa9205852
commit d27cd02193
5 changed files with 36 additions and 6 deletions

View File

@ -48,8 +48,11 @@ than 63 characters in length.'),
'password': forms.PasswordInput,
}
help_texts = {
'username': _('Choose a username and password to access this web\
interface. The password can be changed and other users can be added later.'),
'username':
_('Choose a username and password to access this web interface. '
'The password can be changed and other users can be added '
'later. A POSIX system user with administrative privileges '
'(sudo) is also created.'),
}
def save(self, commit=True):

View File

@ -31,6 +31,12 @@
{{ form|bootstrap }}
{% if is_posix_user %}
<p>This user is also a POSIX system user and password for POSIX system
user will also be updated.
</p>
{% endif %}
<input type="submit" class="btn btn-primary" value="Save Password"/>
</form>

View File

@ -24,6 +24,12 @@
<h3>Delete User <em>{{ object.username }}</em></h3>
{% if is_posix_user %}
<p>This user is also a POSIX system user. POSIX system user will also be
deleted.
</p>
{% endif %}
<p>Delete user permanently?</p>
<form class="form" method="post">

View File

@ -46,10 +46,11 @@
{{ form|bootstrap }}
{% if is_posix_user %}
<p>This user is also a POSIX user and (if active) can log in to the
system through SSH.</p>
{% endif %}
{% if is_posix_user %}
<p>This user is also a POSIX system user and, if active, can log in to
the system through SSH.
</p>
{% endif %}
<input type="submit" class="btn btn-primary" value="Save Changes"/>

View File

@ -94,6 +94,13 @@ class UserDelete(ContextMixin, DeleteView):
success_url = reverse_lazy('users:index')
title = _('Delete User')
def get_context_data(self, **kwargs):
"""Return the data to be used for rendering templates."""
context = super(UserDelete, self).get_context_data(**kwargs)
output = actions.run('check-user-exists', [self.kwargs['slug']])
context['is_posix_user'] = 'User exists' in output
return context
def delete(self, *args, **kwargs):
"""Set the success message of deleting the user.
@ -119,6 +126,13 @@ class UserChangePassword(ContextMixin, SuccessMessageMixin, FormView):
kwargs['user'] = User.objects.get(username=self.kwargs['slug'])
return kwargs
def get_context_data(self, **kwargs):
"""Return the data to be used for rendering templates."""
context = super(UserChangePassword, self).get_context_data(**kwargs)
output = actions.run('check-user-exists', [self.kwargs['slug']])
context['is_posix_user'] = 'User exists' in output
return context
def get_success_url(self):
return reverse('users:edit', kwargs={'slug': self.kwargs['slug']})