diff options
author | Michael Elkins <melkins@tislabs.com> | 2013-06-10 19:33:36 +0000 |
---|---|---|
committer | Michael Elkins <melkins@tislabs.com> | 2013-06-10 19:33:36 +0000 |
commit | 662fca17cd41c3d0c00e8d24b2b14646bceaaaa4 (patch) | |
tree | 698b8a7c0be57f35e4ba4843babb61c4b24105ca /rpkid/rpki/gui/app/views.py | |
parent | b0bba5b283f67a6bec630234371101067f1664ac (diff) |
decorate alert views to require a user to be logged in and a resource handle selected
closes #542
svn path=/trunk/; revision=5388
Diffstat (limited to 'rpkid/rpki/gui/app/views.py')
-rw-r--r-- | rpkid/rpki/gui/app/views.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/rpkid/rpki/gui/app/views.py b/rpkid/rpki/gui/app/views.py index 60a40e0a..077daf5a 100644 --- a/rpkid/rpki/gui/app/views.py +++ b/rpkid/rpki/gui/app/views.py @@ -28,6 +28,7 @@ import cStringIO import csv import logging +from django.utils.decorators import method_decorator from django.contrib.auth.decorators import login_required from django.shortcuts import get_object_or_404, render, redirect from django.utils.http import urlquote @@ -1253,12 +1254,22 @@ def user_edit(request, pk): class AlertListView(ListView): + # this nonsense is required to decorate CBVs + @method_decorator(handle_required) + def dispatch(*args, **kwargs): + return super(AlertDeleteView, self).dispatch(*args, **kwargs) + def get_queryset(self, **kwargs): conf = self.request.session['handle'] return conf.alerts.all() class AlertDetailView(DetailView): + # this nonsense is required to decorate CBVs + @method_decorator(handle_required) + def dispatch(*args, **kwargs): + return super(AlertDeleteView, self).dispatch(*args, **kwargs) + def get_queryset(self, **kwargs): conf = self.request.session['handle'] return conf.alerts.all() @@ -1274,6 +1285,11 @@ class AlertDetailView(DetailView): class AlertDeleteView(DeleteView): success_url = reverse_lazy('alert-list') + # this nonsense is required to decorate CBVs + @method_decorator(handle_required) + def dispatch(*args, **kwargs): + return super(AlertDeleteView, self).dispatch(*args, **kwargs) + def get_queryset(self, **kwargs): conf = self.request.session['handle'] return conf.alerts.all() |