mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
clubs: use standard rights for ClubMailingView
This commit is contained in:
parent
a0e39b8904
commit
da25480993
@ -502,7 +502,7 @@ class ClubStatView(TemplateView):
|
|||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
class ClubMailingView(ClubTabsMixin, DetailFormView):
|
class ClubMailingView(ClubTabsMixin, CanEditMixin, DetailFormView):
|
||||||
"""
|
"""
|
||||||
A list of mailing for a given club
|
A list of mailing for a given club
|
||||||
"""
|
"""
|
||||||
@ -513,27 +513,13 @@ class ClubMailingView(ClubTabsMixin, DetailFormView):
|
|||||||
template_name = "club/mailing.jinja"
|
template_name = "club/mailing.jinja"
|
||||||
current_tab = "mailing"
|
current_tab = "mailing"
|
||||||
|
|
||||||
def authorized(self):
|
|
||||||
return (
|
|
||||||
self.get_object().has_rights_in_club(self.request.user)
|
|
||||||
or self.request.user.is_root
|
|
||||||
or self.request.user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID)
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_form_kwargs(self, *args, **kwargs):
|
def get_form_kwargs(self, *args, **kwargs):
|
||||||
kwargs = super(ClubMailingView, self).get_form_kwargs(*args, **kwargs)
|
kwargs = super(ClubMailingView, self).get_form_kwargs(*args, **kwargs)
|
||||||
kwargs["club_id"] = self.get_object().id
|
kwargs["club_id"] = self.get_object().id
|
||||||
kwargs["user_id"] = self.request.user.id
|
kwargs["user_id"] = self.request.user.id
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
|
||||||
res = super(ClubMailingView, self).dispatch(request, *args, **kwargs)
|
|
||||||
if not self.authorized():
|
|
||||||
raise PermissionDenied
|
|
||||||
return res
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
self.object = self.get_object()
|
|
||||||
kwargs = super(ClubMailingView, self).get_context_data(**kwargs)
|
kwargs = super(ClubMailingView, self).get_context_data(**kwargs)
|
||||||
kwargs["club"] = self.get_object()
|
kwargs["club"] = self.get_object()
|
||||||
kwargs["user"] = self.request.user
|
kwargs["user"] = self.request.user
|
||||||
|
Loading…
Reference in New Issue
Block a user