mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 15:15:22 +00:00
accounts/edit added is_staff and is_superuser checkboxes
list all users (previously staff and admins were not displayed)
This commit is contained in:
parent
39f3c9e12b
commit
71c6161291
3 changed files with 20 additions and 2 deletions
|
@ -9,6 +9,8 @@ class UserAddForm(forms.Form):
|
|||
error_messages={'required': _('No User name has been entered')},
|
||||
max_length=20)
|
||||
password = forms.CharField(required=True, error_messages={'required': _('No password has been entered')},)
|
||||
is_staff = forms.BooleanField(required=True)
|
||||
is_superuser = forms.BooleanField(required=True)
|
||||
|
||||
def clean_name(self):
|
||||
name = self.cleaned_data['name']
|
||||
|
|
|
@ -71,6 +71,18 @@
|
|||
<input type="password" name="user_pass" class="form-control" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label">{% trans "Is staff" %}</label>
|
||||
<div class="col-sm-2">
|
||||
<input type="checkbox" name="user_is_staff" {% if user.is_staff %}checked{% endif %}>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label">{% trans "Is superuser" %}</label>
|
||||
<div class="col-sm-2">
|
||||
<input type="checkbox" name="user_is_superuser" {% if user.is_superuser %}checked{% endif %}>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="pull-left btn btn-danger" name="delete">
|
||||
|
@ -99,4 +111,4 @@
|
|||
{% endfor %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -75,7 +75,7 @@ def accounts(request):
|
|||
return HttpResponseRedirect(reverse('index'))
|
||||
|
||||
error_messages = []
|
||||
users = User.objects.filter(is_staff=False, is_superuser=False)
|
||||
users = User.objects.all()
|
||||
|
||||
if request.method == 'POST':
|
||||
if 'create' in request.POST:
|
||||
|
@ -92,8 +92,12 @@ def accounts(request):
|
|||
if 'edit' in request.POST:
|
||||
user_id = request.POST.get('user_id', '')
|
||||
user_pass = request.POST.get('user_pass', '')
|
||||
user_is_staff = request.POST.get('user_is_staff', False)
|
||||
user_is_superuser = request.POST.get('user_is_superuser', False)
|
||||
user_edit = User.objects.get(id=user_id)
|
||||
user_edit.set_password(user_pass)
|
||||
user_edit.is_staff = user_is_staff
|
||||
user_edit.is_superuser = user_is_superuser
|
||||
user_edit.save()
|
||||
return HttpResponseRedirect(request.get_full_path())
|
||||
if 'block' in request.POST:
|
||||
|
|
Loading…
Reference in a new issue