Commit 726b6590 by Őry Máté

dashboard: add RedirectToLoginMixin

parent 216d708c
...@@ -91,6 +91,21 @@ def search_user(keyword): ...@@ -91,6 +91,21 @@ def search_user(keyword):
return User.objects.get(email=keyword) return User.objects.get(email=keyword)
class RedirectToLoginMixin(AccessMixin):
redirect_exception_classes = (PermissionDenied, )
def dispatch(self, request, *args, **kwargs):
try:
return super(RedirectToLoginMixin, self).dispatch(
request, *args, **kwargs)
except self.redirect_exception_classes:
if not request.user.is_authenticated():
return redirect_to_login(request.get_full_path(),
self.get_login_url(),
self.get_redirect_field_name())
class GroupCodeMixin(object): class GroupCodeMixin(object):
@classmethod @classmethod
...@@ -498,7 +513,7 @@ class VmRawDataUpdate(SuperuserRequiredMixin, UpdateView): ...@@ -498,7 +513,7 @@ class VmRawDataUpdate(SuperuserRequiredMixin, UpdateView):
return self.get_object().get_absolute_url() + "#resources" return self.get_object().get_absolute_url() + "#resources"
class OperationView(DetailView): class OperationView(RedirectToLoginMixin, DetailView):
template_name = 'dashboard/operate.html' template_name = 'dashboard/operate.html'
show_in_toolbar = True show_in_toolbar = True
......
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