Commit 55490625 by Scott Duckworth

add setting SSHKEY_ALLOW_EDIT

parent 008ac513
......@@ -29,6 +29,7 @@
from django.conf import settings
SSHKEY_AUTHORIZED_KEYS_OPTIONS = getattr(settings, 'SSHKEY_AUTHORIZED_KEYS_OPTIONS', None)
SSHKEY_ALLOW_EDIT = getattr(settings, 'SSHKEY_ALLOW_KEY_EDIT', True)
SSHKEY_EMAIL_ADD_KEY = getattr(settings, 'SSHKEY_EMAIL_ADD_KEY', True)
SSHKEY_EMAIL_ADD_KEY_SUBJECT = getattr(settings, 'SSHKEY_EMAIL_ADD_KEY_SUBJECT',
"A new public key was added to your account"
......
......@@ -14,7 +14,9 @@
<td>{{ userkey.fingerprint }}</td>
<td>{{ userkey.created }}</td>
<td>{{ userkey.last_modified }}</td>
{% if allow_edit %}
<td><a href="{% url django_sshkey.views.userkey_edit userkey.pk %}">Edit</a></td>
{% endif %}
<td><a href="{% url django_sshkey.views.userkey_delete userkey.pk %}">Delete</a></td>
</tr>
{% endfor %}
......
......@@ -68,7 +68,7 @@ def userkey_list(request):
userkey_list = UserKey.objects.filter(user=request.user)
return render_to_response(
'sshkey/userkey_list.html',
{ 'userkey_list': userkey_list },
{ 'userkey_list': userkey_list, 'allow_edit': settings.SSHKEY_ALLOW_EDIT },
context_instance = RequestContext(request),
)
......@@ -99,6 +99,8 @@ def userkey_add(request):
@login_required
@require_http_methods(['GET', 'POST'])
def userkey_edit(request, pk):
if not settings.SSHKEY_ALLOW_EDIT:
raise PermissionDenied
userkey = get_object_or_404(UserKey, pk=pk)
if userkey.user != request.user:
raise PermissionDenied
......
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