@@ -199,7 +191,7 @@
- {% for group in user.groups.all %}
+ {% for group in user_object.groups.all %}
{{ group.name }}
@@ -226,7 +218,7 @@
jumpserver.groups_selected = {};
function updateUserGroups(groups) {
- var the_url = "{% url 'api-users:user-update-group' pk=user.id %}";
+ var the_url = "{% url 'api-users:user-update-group' pk=user_object.id %}";
var body = {
groups: Object.assign([], groups)
};
@@ -266,7 +258,7 @@ $(document).ready(function() {
})
})
.on('click', '#is_active', function() {
- var the_url = "{% url 'api-users:user-detail' pk=user.id %}";
+ var the_url = "{% url 'api-users:user-detail' pk=user_object.id %}";
var checked = $(this).prop('checked');
var body = {
'is_active': checked
@@ -279,7 +271,7 @@ $(document).ready(function() {
});
})
.on('click', '#enable_otp', function() {
- var the_url = "{% url 'api-users:user-detail' pk=user.id %}";
+ var the_url = "{% url 'api-users:user-detail' pk=user_object.id %}";
var checked = $(this).prop('checked');
var body = {
'enable_otp': checked
@@ -319,7 +311,7 @@ $(document).ready(function() {
updateUserGroups(groups)
}).on('click', '#btn_reset_password', function() {
function doReset() {
- var the_url = '{% url "api-users:user-reset-password" pk=user.id %}';
+ var the_url = '{% url "api-users:user-reset-password" pk=user_object.id %}';
var body = {};
var success = function() {
var msg = "{% trans "An e-mail has been sent to the user\'s mailbox." %}";
@@ -333,7 +325,7 @@ $(document).ready(function() {
}
swal({
title: "{% trans 'Are you sure?' %}",
- text: "{% trans 'This will reset the user\'s password.' %}",
+ text: "{% trans 'This will reset the user\'s password. A password-reset email will be sent to the user\'s mailbox.' %}",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
@@ -344,7 +336,7 @@ $(document).ready(function() {
});
}).on('click', '#btn_reset_pk', function() {
function doReset() {
- var the_url = '{% url "api-users:user-public-key-reset" pk=user.id %}';
+ var the_url = '{% url "api-users:user-public-key-reset" pk=user_object.id %}';
var body = {};
var success = function() {
var msg = "{% trans 'The reset-ssh-public-key E-mail has been sent successfully. Please inform the user to update his new ssh public key.' %}";
@@ -367,32 +359,6 @@ $(document).ready(function() {
}, function() {
doReset();
});
-}).on('click', '#btn_user_update_pk', function(){
- var $this = $(this);
- var pk = $('#txt_pk').val();
- var the_url = '{% url "api-users:user-public-key-reset" pk=user.id %}';
- var body = {'_public_key': pk};
- var success = function() {
- $('#txt_pk').val('');
- $this.closest('.modal').modal('hide');
- var msg = "{% trans 'Successfully updated the SSH public key.' %}";
- swal("{% trans 'User SSH Public Key Update' %}", msg, "success");
- };
- var fail = function(msg) {
- swal({
- title: "{% trans 'User SSH Public Key Update' %}",
- text: msg,
- type: "error",
- showCancelButton: false,
- confirmButtonColor: "#DD6B55",
- confirmButtonText: "{% trans 'Confirm' %}",
- closeOnConfirm: true
- }, function () {
- $('#txt_pk').focus();
- }
- );
- };
- APIUpdateAttr({ url: the_url, body: JSON.stringify(body), success: success, error: fail});
-});
+})
{% endblock %}
diff --git a/apps/users/views/user.py b/apps/users/views/user.py
index d96e3da29..c5494ac6e 100644
--- a/apps/users/views/user.py
+++ b/apps/users/views/user.py
@@ -106,7 +106,7 @@ class UserUpdateView(AdminUserRequiredMixin, UpdateView):
class UserDetailView(AdminUserRequiredMixin, DetailView):
model = User
template_name = 'users/user_detail.html'
- context_object_name = "user"
+ context_object_name = "user_object"
def get_context_data(self, **kwargs):
groups = UserGroup.objects.exclude(id__in=self.object.groups.all())
|