@csrf_protect
@superuser_required
def ssh_settings(request, template_name=u'admin/ssh_settings.html'):
 client = SSHClient()
 key = client.get_user_key()
 if (request.method == u'POST'):
  form = SSHSettingsForm(request.POST, request.FILES)
  if form.is_valid():
   if (form.did_request_delete() and (client.get_user_key() is not None)):
    try:
     form.delete()
     return HttpResponseRedirect(u'.')
    except Exception as e:
     logging.error((u'Deleting SSH key failed: %s' % e))
   else:
    try:
     form.create(request.FILES)
     return HttpResponseRedirect(u'.')
    except Exception as e:
     logging.error((u'Uploading SSH key failed: %s' % e))
 else:
  form = SSHSettingsForm()
 if key:
  fingerprint = humanize_key(key)
 else:
  fingerprint = None
 return render_to_response(template_name, RequestContext(request, {u'key': key, u'fingerprint': fingerprint, u'public_key': client.get_public_key(key), u'form': form}))

@ csrf_protect @ superuser_required def ssh_settings ( request , template_name = u'admin/ssh_settings.html' ) : client = SSHClient ( ) key = client . get_user_key ( ) if ( request . method == u'POST' ) : form = SSHSettingsForm ( request . POST , request . FILES ) if form . is_valid ( ) : if ( form . did_request_delete ( ) and ( client . get_user_key ( ) is not None ) ) : try : form . delete ( ) return HttpResponseRedirect ( u'.' ) except Exception as e : logging . error ( ( u'Deleting SSH key failed: %s' % e ) ) else : try : form . create ( request . FILES ) return HttpResponseRedirect ( u'.' ) except Exception as e : logging . error ( ( u'Uploading SSH key failed: %s' % e ) ) else : form = SSHSettingsForm ( ) if key : fingerprint = humanize_key ( key ) else : fingerprint = None return render_to_response ( template_name , RequestContext ( request , { u'key' : key , u'fingerprint' : fingerprint , u'public_key' : client . get_public_key ( key ) , u'form' : form } ) )
render the ssh settings page .