Commit 899decd8 by Dányi Bence

webui: reset keys

parent 9905d78d
......@@ -101,4 +101,6 @@ urlpatterns = patterns('',
url(r'^key/add/$', 'one.views.key_add', name='key_add'),
url(r'^ajax/key/delete/$', 'one.views.key_ajax_delete',
name='key_ajax_delete'),
url(r'^ajax/key/reset/$', 'one.views.key_ajax_reset',
name='key_ajax_reset'),
)
......@@ -29,7 +29,18 @@ $(function() {
});
});
});
$('.entry .summary').unbind('click').click(toggleDetails);
$('#reset-key').click(function(e){
vm_confirm_popup(gettext('Are you sure about reseting store credentials'), gettext('Reset'), function(){
$.ajax({
type: 'POST',
url: '/ajax/key/reset/',
success: function(){
window.location.reload();
}
})
});
});
$('.entry .summary').click(toggleDetails);
if(window.navigator.userAgent.indexOf('cloud-gui') > -1) {
$('.connect-vm').click(function(e) {
e.preventDefault();
......
......@@ -610,4 +610,7 @@ table {
#new-key .name {
background-image: url(/static/icons/key--plus.png);
}
#reset-key .name {
background-image: url(/static/icons/key--exclamation.png);
}
}
......@@ -25,5 +25,11 @@
</form>
</div>
</li>
<li class="entry small-row">
<div class="summary" id="reset-key">
<div class="name">{% trans "Reset key" %}</div>
<div class="clear"></div>
</div>
</li>
</ul>
{% endblock content %}
......@@ -460,6 +460,17 @@ def key_ajax_delete(request):
key.delete()
except:
messages.error(request, _('Failed to delete public key'))
return 'OK'
return HttpResponse('OK')
@login_required
@require_POST
def key_ajax_reset(request):
try:
det=UserCloudDetails.objects.get(user=request.user)
det.reset_smb()
det.reset_keys()
except:
messages.error(request, _('Failed to reset keys'))
return HttpResponse('OK')
# vim: et sw=4 ai fenc=utf8 smarttab :
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment