Commit 4a53c3f2 by Scott Duckworth

hook into django messaging framework

parent 09f1c6fc
...@@ -2,6 +2,7 @@ from django.http import HttpResponse, HttpResponseRedirect ...@@ -2,6 +2,7 @@ from django.http import HttpResponse, HttpResponseRedirect
from django.views.decorators.http import require_http_methods, require_GET from django.views.decorators.http import require_http_methods, require_GET
from django.shortcuts import get_object_or_404, render_to_response from django.shortcuts import get_object_or_404, render_to_response
from django.template import RequestContext from django.template import RequestContext
from django.contrib import messages
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
...@@ -59,6 +60,8 @@ def userkey_add(request): ...@@ -59,6 +60,8 @@ def userkey_add(request):
url = request.GET.get('next', default_redirect) url = request.GET.get('next', default_redirect)
if not is_safe_url(url=url, host=request.get_host()): if not is_safe_url(url=url, host=request.get_host()):
url = default_redirect url = default_redirect
message = 'SSH key <code>%s</code> was saved.' % userkey.name
messages.success(request, message, fail_silently=True)
return HttpResponseRedirect(url) return HttpResponseRedirect(url)
else: else:
form = UserKeyForm() form = UserKeyForm()
...@@ -82,6 +85,8 @@ def userkey_edit(request, pk): ...@@ -82,6 +85,8 @@ def userkey_edit(request, pk):
url = request.GET.get('next', default_redirect) url = request.GET.get('next', default_redirect)
if not is_safe_url(url=url, host=request.get_host()): if not is_safe_url(url=url, host=request.get_host()):
url = default_redirect url = default_redirect
message = 'SSH key <code>%s</code> was saved.' % userkey.name
messages.success(request, message, fail_silently=True)
return HttpResponseRedirect(url) return HttpResponseRedirect(url)
else: else:
form = UserKeyForm(instance=userkey) form = UserKeyForm(instance=userkey)
...@@ -98,4 +103,6 @@ def userkey_delete(request, pk): ...@@ -98,4 +103,6 @@ def userkey_delete(request, pk):
if userkey.user != request.user: if userkey.user != request.user:
raise PermissionDenied raise PermissionDenied
userkey.delete() userkey.delete()
message = 'SSH key %s was deleted.' % userkey.name
messages.success(request, message, fail_silently=True)
return HttpResponseRedirect(reverse('sshkey.views.userkey_list')) return HttpResponseRedirect(reverse('sshkey.views.userkey_list'))
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