mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 02:24:26 +00:00
Small fix (le gaulois)
This commit is contained in:
parent
c3fb581f97
commit
7d7652e319
@ -8,7 +8,7 @@ from django.core.exceptions import ValidationError
|
|||||||
|
|
||||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin
|
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin
|
||||||
from club.models import Club, Membership
|
from club.models import Club, Membership
|
||||||
from sith.settings import AE_GROUPS
|
from sith.settings import AE_GROUPS, MAXIMUM_FREE_ROLE
|
||||||
|
|
||||||
class ClubListView(CanViewMixin, ListView):
|
class ClubListView(CanViewMixin, ListView):
|
||||||
"""
|
"""
|
||||||
@ -42,7 +42,10 @@ 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']) or self._user.is_in_group(AE_GROUPS['board']['name']) or self._user.is_superuser:
|
if (self.cleaned_data['role'] <= MAXIMUM_FREE_ROLE or
|
||||||
|
(ms is not None and ms.role >= self.cleaned_data['role']) or
|
||||||
|
self._user.is_in_group(AE_GROUPS['board']['name']) 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")
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@ Welcome to the wiki page!
|
|||||||
date_of_birth="1942-06-12")
|
date_of_birth="1942-06-12")
|
||||||
s.set_password("plop")
|
s.set_password("plop")
|
||||||
s.save()
|
s.save()
|
||||||
|
s.view_groups=[settings.AE_GROUPS['members']['id']]
|
||||||
|
s.save()
|
||||||
# Adding user Guy
|
# Adding user Guy
|
||||||
u = User(username='guy', last_name="Carlier", first_name="Guy",
|
u = User(username='guy', last_name="Carlier", first_name="Guy",
|
||||||
email="guy@git.an",
|
email="guy@git.an",
|
||||||
@ -54,12 +56,16 @@ Welcome to the wiki page!
|
|||||||
is_superuser=False, is_staff=False)
|
is_superuser=False, is_staff=False)
|
||||||
u.set_password("plop")
|
u.set_password("plop")
|
||||||
u.save()
|
u.save()
|
||||||
|
u.view_groups=[settings.AE_GROUPS['members']['id']]
|
||||||
|
u.save()
|
||||||
# Adding user Richard Batsbak
|
# Adding user Richard Batsbak
|
||||||
r = User(username='rbatsbak', last_name="Batsbak", first_name="Richard",
|
r = User(username='rbatsbak', last_name="Batsbak", first_name="Richard",
|
||||||
email="richard@git.an",
|
email="richard@git.an",
|
||||||
date_of_birth="1982-06-12")
|
date_of_birth="1982-06-12")
|
||||||
r.set_password("plop")
|
r.set_password("plop")
|
||||||
r.save()
|
r.save()
|
||||||
|
r.view_groups=[settings.AE_GROUPS['members']['id']]
|
||||||
|
r.save()
|
||||||
# Adding syntax help page
|
# Adding syntax help page
|
||||||
p = Page(name='Aide_sur_la_syntaxe')
|
p = Page(name='Aide_sur_la_syntaxe')
|
||||||
p.save()
|
p.save()
|
||||||
|
@ -72,7 +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)
|
||||||
print("GUYGUYGUYGUYGUY")
|
|
||||||
if hasattr(self, 'object'):
|
if hasattr(self, 'object'):
|
||||||
obj = self.object
|
obj = self.object
|
||||||
elif hasattr(self, 'object_list'):
|
elif hasattr(self, 'object_list'):
|
||||||
|
@ -243,3 +243,7 @@ CLUB_ROLES = {
|
|||||||
1: 'Membre actif',
|
1: 'Membre actif',
|
||||||
0: 'Curieux',
|
0: 'Curieux',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This corresponds to the maximum role a user can freely subscribe to
|
||||||
|
# In this case, MAXIMUM_FREE_ROLE=1 means that a user can set himself as "Membre actif" or "Curieux", but not higher
|
||||||
|
MAXIMUM_FREE_ROLE=1
|
||||||
|
Loading…
Reference in New Issue
Block a user