mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-24 18:14:22 +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 club.models import Club, Membership
|
||||
from sith.settings import AE_GROUPS
|
||||
from sith.settings import AE_GROUPS, MAXIMUM_FREE_ROLE
|
||||
|
||||
class ClubListView(CanViewMixin, ListView):
|
||||
"""
|
||||
@ -42,7 +42,10 @@ class ClubMemberForm(forms.ModelForm):
|
||||
"""
|
||||
ret = super(ClubMemberForm, self).clean()
|
||||
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
|
||||
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")
|
||||
s.set_password("plop")
|
||||
s.save()
|
||||
s.view_groups=[settings.AE_GROUPS['members']['id']]
|
||||
s.save()
|
||||
# Adding user Guy
|
||||
u = User(username='guy', last_name="Carlier", first_name="Guy",
|
||||
email="guy@git.an",
|
||||
@ -54,12 +56,16 @@ Welcome to the wiki page!
|
||||
is_superuser=False, is_staff=False)
|
||||
u.set_password("plop")
|
||||
u.save()
|
||||
u.view_groups=[settings.AE_GROUPS['members']['id']]
|
||||
u.save()
|
||||
# Adding user Richard Batsbak
|
||||
r = User(username='rbatsbak', last_name="Batsbak", first_name="Richard",
|
||||
email="richard@git.an",
|
||||
date_of_birth="1982-06-12")
|
||||
r.set_password("plop")
|
||||
r.save()
|
||||
r.view_groups=[settings.AE_GROUPS['members']['id']]
|
||||
r.save()
|
||||
# Adding syntax help page
|
||||
p = Page(name='Aide_sur_la_syntaxe')
|
||||
p.save()
|
||||
|
@ -72,7 +72,6 @@ class CanViewMixin(View):
|
||||
"""
|
||||
def dispatch(self, request, *arg, **kwargs):
|
||||
res = super(CanViewMixin, self).dispatch(request, *arg, **kwargs)
|
||||
print("GUYGUYGUYGUYGUY")
|
||||
if hasattr(self, 'object'):
|
||||
obj = self.object
|
||||
elif hasattr(self, 'object_list'):
|
||||
|
@ -243,3 +243,7 @@ CLUB_ROLES = {
|
||||
1: 'Membre actif',
|
||||
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