Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
eb6e3c83
authored
Feb 19, 2013
by
Dányi Bence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webui: delete/add keys
parent
01c082b0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
2 deletions
+29
-2
cloud/urls.py
+3
-0
one/templates/box/key/box.html
+1
-1
one/templates/box/key/entry.html
+1
-1
one/views.py
+24
-0
No files found.
cloud/urls.py
View file @
eb6e3c83
...
...
@@ -95,4 +95,7 @@ urlpatterns = patterns('',
name
=
'group_ajax_remove_member'
),
url
(
r'^ajax/group/delete/$'
,
'school.views.group_ajax_delete'
,
name
=
'group_ajax_delete'
),
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'
),
)
one/templates/box/key/box.html
View file @
eb6e3c83
...
...
@@ -18,7 +18,7 @@
<div
class=
"clear"
></div>
</div>
<div
class=
"details"
>
<form
style=
"padding-bottom: 10px"
action=
"/key/add/"
>
<form
style=
"padding-bottom: 10px"
action=
"/key/add/"
method=
"POST"
>
{% csrf_token %}
<textarea
style=
"margin-bottom: 5px"
name=
"key"
placeholder=
"{% trans "
Public
key
in
OpenSSH
format
"
%}"
></textarea><br
/>
<input
type=
"submit"
style=
"margin-left: 10px;"
value=
"{% trans "
Save
"
%}"
/>
...
...
one/templates/box/key/entry.html
View file @
eb6e3c83
...
...
@@ -14,7 +14,7 @@
{{key}}
</div>
<div
class=
"actions"
>
<a
href=
"#"
class=
"remove"
data-id=
"{{key.id}}"
>
<a
href=
"#"
class=
"remove
delete-key-button
"
data-id=
"{{key.id}}"
>
<img
src=
"/static/icons/minus-circle.png"
alt=
"{% trans 'Remove' %}"
/>
</a>
</div>
...
...
one/views.py
View file @
eb6e3c83
...
...
@@ -431,4 +431,28 @@ def vm_restart(request, iid, *args, **kwargs):
messages
.
error
(
request
,
_
(
'Failed to restart virtual machine.'
))
return
redirect
(
'/'
)
@login_required
@require_POST
def
key_add
(
request
):
try
:
key
=
SshKey
()
#TODO: validate key
key
.
key
=
request
.
POST
[
'key'
]
key
.
user
=
request
.
user
key
.
save
()
except
:
messages
.
error
(
request
,
_
(
'Failed to add public key'
))
return
redirect
(
'/'
)
@login_required
@require_POST
def
key_ajax_delete
(
request
):
try
:
#TODO: permission check
key
=
get_object_or_404
(
SshKey
,
id
=
request
.
POST
[
'id'
])
key
.
delete
()
except
:
messages
.
error
(
request
,
_
(
'Failed to delete public key'
))
return
'OK'
# vim: et sw=4 ai fenc=utf8 smarttab :
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment