mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 11:04:20 +00:00
core: add UserIsLoggedMixin to check if an user is not anonymous
This commit is contained in:
parent
b18746e769
commit
9b7b96a310
@ -214,6 +214,17 @@ class FormerSubscriberMixin(View):
|
|||||||
return super(FormerSubscriberMixin, self).dispatch(request, *args, **kwargs)
|
return super(FormerSubscriberMixin, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class UserIsLoggedMixin(View):
|
||||||
|
"""
|
||||||
|
This view check if the user is logged
|
||||||
|
"""
|
||||||
|
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
if request.user.is_anonymous:
|
||||||
|
raise PermissionDenied
|
||||||
|
return super(UserIsLoggedMixin, self).dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class TabedViewMixin(View):
|
class TabedViewMixin(View):
|
||||||
"""
|
"""
|
||||||
This view provide the basic functions for displaying tabs in the template
|
This view provide the basic functions for displaying tabs in the template
|
||||||
|
@ -52,6 +52,7 @@ from core.views import (
|
|||||||
CanViewMixin,
|
CanViewMixin,
|
||||||
CanEditMixin,
|
CanEditMixin,
|
||||||
CanEditPropMixin,
|
CanEditPropMixin,
|
||||||
|
UserIsLoggedMixin,
|
||||||
TabedViewMixin,
|
TabedViewMixin,
|
||||||
QuickNotifMixin,
|
QuickNotifMixin,
|
||||||
)
|
)
|
||||||
@ -762,7 +763,7 @@ class UserUpdateGroupView(UserTabsMixin, CanEditPropMixin, UpdateView):
|
|||||||
current_tab = "groups"
|
current_tab = "groups"
|
||||||
|
|
||||||
|
|
||||||
class UserToolsView(QuickNotifMixin, UserTabsMixin, TemplateView):
|
class UserToolsView(QuickNotifMixin, UserTabsMixin, UserIsLoggedMixin, TemplateView):
|
||||||
"""
|
"""
|
||||||
Displays the logged user's tools
|
Displays the logged user's tools
|
||||||
"""
|
"""
|
||||||
@ -770,11 +771,6 @@ class UserToolsView(QuickNotifMixin, UserTabsMixin, TemplateView):
|
|||||||
template_name = "core/user_tools.jinja"
|
template_name = "core/user_tools.jinja"
|
||||||
current_tab = "tools"
|
current_tab = "tools"
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
|
||||||
if request.user.is_anonymous:
|
|
||||||
raise PermissionDenied
|
|
||||||
return super(UserToolsView, self).dispatch(request, *args, **kwargs)
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
self.object = self.request.user
|
self.object = self.request.user
|
||||||
from launderette.models import Launderette
|
from launderette.models import Launderette
|
||||||
|
Loading…
Reference in New Issue
Block a user