mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Fix club rights
This commit is contained in:
parent
d90c0f86f4
commit
fe8f5bb2e3
@ -58,7 +58,7 @@ class Club(models.Model):
|
|||||||
"""
|
"""
|
||||||
Method to see if that object can be super edited by the given user
|
Method to see if that object can be super edited by the given user
|
||||||
"""
|
"""
|
||||||
if user.groups.filter(name=settings.AE_GROUPS['board']['name']).exists():
|
if user.is_in_group(settings.AE_GROUPS['board']['name']):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -117,5 +117,3 @@ class Membership(models.Model):
|
|||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('club:club_members', kwargs={'club_id': self.club.id})
|
return reverse('club:club_members', kwargs={'club_id': self.club.id})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class ClubMemberForm(forms.ModelForm):
|
|||||||
"""
|
"""
|
||||||
ret = super(ClubMemberForm, self).clean()
|
ret = super(ClubMemberForm, self).clean()
|
||||||
ms = self.instance.club.get_membership_for(self._user)
|
ms = self.instance.club.get_membership_for(self._user)
|
||||||
if ms is not None and ms.role >= self.cleaned_data['role']:
|
if (ms is not None and ms.role >= self.cleaned_data['role']) or self._user.is_superuser:
|
||||||
return ret
|
return ret
|
||||||
raise ValidationError("You do not have the permission to do that")
|
raise ValidationError("You do not have the permission to do that")
|
||||||
|
|
||||||
|
@ -96,6 +96,10 @@ class User(AbstractBaseUser, PermissionsMixin):
|
|||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
return self.__dict__
|
return self.__dict__
|
||||||
|
|
||||||
|
def is_in_group(self, group_name):
|
||||||
|
"""If the user is in the group passed in argument (as string)"""
|
||||||
|
return self.groups.filter(name=group_name).exists()
|
||||||
|
|
||||||
def get_profile(self):
|
def get_profile(self):
|
||||||
return {
|
return {
|
||||||
"last_name": self.last_name,
|
"last_name": self.last_name,
|
||||||
|
@ -72,9 +72,6 @@ class CanViewMixin(View):
|
|||||||
"""
|
"""
|
||||||
def dispatch(self, request, *arg, **kwargs):
|
def dispatch(self, request, *arg, **kwargs):
|
||||||
res = super(CanViewMixin, self).dispatch(request, *arg, **kwargs)
|
res = super(CanViewMixin, self).dispatch(request, *arg, **kwargs)
|
||||||
import traceback
|
|
||||||
traceback.print_stack(limit=10)
|
|
||||||
print(self.__dict__)
|
|
||||||
if hasattr(self, 'object'):
|
if hasattr(self, 'object'):
|
||||||
obj = self.object
|
obj = self.object
|
||||||
elif hasattr(self, 'object_list'):
|
elif hasattr(self, 'object_list'):
|
||||||
|
Loading…
Reference in New Issue
Block a user