fix(user_list.html & juser/views.py): only for user delete sshkey when downloaded, add generate butt

https://github.com/jumpserver/jumpserver/issues/62
pull/81/head
liuzheng712 2016-02-25 13:04:09 +08:00
parent a037108cf3
commit 27be35ae77
2 changed files with 11 additions and 3 deletions

View File

@ -453,7 +453,6 @@ def down_key(request):
uuid_r = request.GET.get('uuid', '')
else:
uuid_r = request.user.uuid
if uuid_r:
user = get_object(User, uuid=uuid_r)
if user:
@ -466,6 +465,7 @@ def down_key(request):
f.close()
response = HttpResponse(data, content_type='application/octet-stream')
response['Content-Disposition'] = 'attachment; filename=%s' % os.path.basename(private_key_file)
if request.user.role == 'CU':
os.unlink(private_key_file)
return response
return HttpResponse('No Key File. Contact Admin.')

View File

@ -70,7 +70,7 @@
{% if user.username|key_exist %}
<a href="{% url 'key_down' %}?uuid={{ user.uuid }}" >下载</a>
{% else %}
<span style="color: #586b7d">NoKey</span>
<a href="#" onclick="genSSH('{{ user.username }}','{% url 'key_gen' %}?uuid={{ user.uuid }}')">NoKey GenOne?</a>
{% endif %}
</td>
<td class="text-center">
@ -150,5 +150,13 @@
});
$('.shiftCheckbox').shiftcheckbox();
});
function genSSH(username, url) {
if (confirm('Are you sure to gen a sshkey for user ' + username)) {
$.get(url, function (data) {
alert(data);
location.reload()
})
}
}
</script>
{% endblock %}