mirror of https://gitlab.crans.org/bde/nk20
Update permissions to create clubs.
For now, only superusers can edit the roles of a user.
This commit is contained in:
parent
c14d37eaeb
commit
aa66361ac7
|
@ -26,7 +26,6 @@ from note_kfet.middlewares import _set_current_user_and_ip
|
||||||
from permission.backends import PermissionBackend
|
from permission.backends import PermissionBackend
|
||||||
from permission.models import Role
|
from permission.models import Role
|
||||||
from permission.views import ProtectQuerysetMixin
|
from permission.views import ProtectQuerysetMixin
|
||||||
from wei.models import WEIClub
|
|
||||||
|
|
||||||
from .forms import ProfileForm, ClubForm, MembershipForm, CustomAuthenticationForm, UserForm
|
from .forms import ProfileForm, ClubForm, MembershipForm, CustomAuthenticationForm, UserForm
|
||||||
from .models import Club, Membership
|
from .models import Club, Membership
|
||||||
|
@ -432,7 +431,7 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView):
|
||||||
club = Club.objects.filter(PermissionBackend.filter_queryset(self.request.user, Club, "view"))\
|
club = Club.objects.filter(PermissionBackend.filter_queryset(self.request.user, Club, "view"))\
|
||||||
.get(pk=self.kwargs["club_pk"], weiclub=None)
|
.get(pk=self.kwargs["club_pk"], weiclub=None)
|
||||||
form.fields['credit_amount'].initial = club.membership_fee_paid
|
form.fields['credit_amount'].initial = club.membership_fee_paid
|
||||||
form.fields['roles'].queryset = Role.objects.filter(Q(weirole__isnull=not isinstance(club, WEIClub))
|
form.fields['roles'].queryset = Role.objects.filter(Q(weirole__isnull=not hasattr(club, 'weiclub'))
|
||||||
& (Q(for_club__isnull=True) | Q(for_club=club))).all()
|
& (Q(for_club__isnull=True) | Q(for_club=club))).all()
|
||||||
form.fields['roles'].initial = Role.objects.filter(name="Membre de club").all()
|
form.fields['roles'].initial = Role.objects.filter(name="Membre de club").all()
|
||||||
|
|
||||||
|
@ -453,7 +452,7 @@ class ClubAddMemberView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView):
|
||||||
user = old_membership.user
|
user = old_membership.user
|
||||||
form.fields['user'].initial = user
|
form.fields['user'].initial = user
|
||||||
form.fields['user'].disabled = True
|
form.fields['user'].disabled = True
|
||||||
form.fields['roles'].queryset = Role.objects.filter(Q(weirole__isnull=not isinstance(club, WEIClub))
|
form.fields['roles'].queryset = Role.objects.filter(Q(weirole__isnull=not hasattr(club, 'weiclub'))
|
||||||
& (Q(for_club__isnull=True) | Q(for_club=club))).all()
|
& (Q(for_club__isnull=True) | Q(for_club=club))).all()
|
||||||
form.fields['roles'].initial = old_membership.roles.all()
|
form.fields['roles'].initial = old_membership.roles.all()
|
||||||
form.fields['date_start'].initial = old_membership.date_end + timedelta(days=1)
|
form.fields['date_start'].initial = old_membership.date_end + timedelta(days=1)
|
||||||
|
@ -647,10 +646,10 @@ class ClubManageRolesView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
|
||||||
del form.fields['bank']
|
del form.fields['bank']
|
||||||
|
|
||||||
club = self.object.club
|
club = self.object.club
|
||||||
form.fields['roles'].queryset = Role.objects.filter(Q(weirole__isnull=not isinstance(club, WEIClub))
|
form.fields['roles'].queryset = Role.objects.filter(Q(weirole__isnull=not hasattr(club, 'weiclub'))
|
||||||
& (Q(for_club__isnull=True) | Q(for_club=club))).all()
|
& (Q(for_club__isnull=True) | Q(for_club=club))).all()
|
||||||
|
|
||||||
return form
|
return form
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse_lazy('member:club_detail', kwargs={'pk': self.object.club.id})
|
return reverse_lazy('member:user_detail', kwargs={'pk': self.object.user.id})
|
||||||
|
|
|
@ -801,7 +801,7 @@
|
||||||
],
|
],
|
||||||
"query": "{\"club\": [\"club\"]}",
|
"query": "{\"club\": [\"club\"]}",
|
||||||
"type": "view",
|
"type": "view",
|
||||||
"mask": 1,
|
"mask": 3,
|
||||||
"field": "",
|
"field": "",
|
||||||
"permanent": false,
|
"permanent": false,
|
||||||
"description": "View club's memberships"
|
"description": "View club's memberships"
|
||||||
|
@ -833,7 +833,7 @@
|
||||||
],
|
],
|
||||||
"query": "{\"club\": [\"club\"]}",
|
"query": "{\"club\": [\"club\"]}",
|
||||||
"type": "change",
|
"type": "change",
|
||||||
"mask": 2,
|
"mask": 3,
|
||||||
"field": "roles",
|
"field": "roles",
|
||||||
"permanent": false,
|
"permanent": false,
|
||||||
"description": "Update user roles"
|
"description": "Update user roles"
|
||||||
|
@ -2234,6 +2234,22 @@
|
||||||
{
|
{
|
||||||
"model": "permission.permission",
|
"model": "permission.permission",
|
||||||
"pk": 139,
|
"pk": 139,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"note",
|
||||||
|
"noteclub"
|
||||||
|
],
|
||||||
|
"query": "{}",
|
||||||
|
"type": "add",
|
||||||
|
"mask": 3,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "Create any noteclub"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 140,
|
||||||
"fields": {
|
"fields": {
|
||||||
"model": [
|
"model": [
|
||||||
"member",
|
"member",
|
||||||
|
@ -2247,6 +2263,38 @@
|
||||||
"description": "Create any club"
|
"description": "Create any club"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 141,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"auth",
|
||||||
|
"user"
|
||||||
|
],
|
||||||
|
"query": "{\"memberships__club\": [\"club\"], \"memberships__date__start__lte\": [\"today\"], \"memberships__date__end__gte\": [\"today\"]}",
|
||||||
|
"type": "view",
|
||||||
|
"mask": 3,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "View members of our club"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"model": "permission.permission",
|
||||||
|
"pk": 142,
|
||||||
|
"fields": {
|
||||||
|
"model": [
|
||||||
|
"note",
|
||||||
|
"noteclub"
|
||||||
|
],
|
||||||
|
"query": "{\"club\": [\"club\"]}",
|
||||||
|
"type": "view",
|
||||||
|
"mask": 2,
|
||||||
|
"field": "",
|
||||||
|
"permanent": false,
|
||||||
|
"description": "View club note"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"model": "permission.role",
|
"model": "permission.role",
|
||||||
"pk": 1,
|
"pk": 1,
|
||||||
|
@ -2323,7 +2371,8 @@
|
||||||
"permissions": [
|
"permissions": [
|
||||||
22,
|
22,
|
||||||
47,
|
47,
|
||||||
49
|
49,
|
||||||
|
140
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2335,8 +2384,9 @@
|
||||||
"name": "Pr\u00e9sident\u00b7e de club",
|
"name": "Pr\u00e9sident\u00b7e de club",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
50,
|
50,
|
||||||
51,
|
62,
|
||||||
62
|
141,
|
||||||
|
142
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2356,7 +2406,9 @@
|
||||||
61,
|
61,
|
||||||
62,
|
62,
|
||||||
127,
|
127,
|
||||||
133
|
133,
|
||||||
|
141,
|
||||||
|
142
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2564,7 +2616,10 @@
|
||||||
136,
|
136,
|
||||||
137,
|
137,
|
||||||
138,
|
138,
|
||||||
139
|
139,
|
||||||
|
140,
|
||||||
|
141,
|
||||||
|
142
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue