Meilleure gestion des permissions
Il n'est plus possible de modifier l'attribut `is_superuser` dans l'interface admin. les membres du burô ne doivent plus être super- utilisateurs en prévision de l'arrivée de l'appli K-Fêt. Pour donner les permissions adéquates au burô, il faut créer un groupe COF avec tous les droits sur les applis `gestioncof` et `bda` ainsi que les droits sur les d'utilisateurs et ajouter les membres du burô à ce groupe.
This commit is contained in:
parent
2989a6e186
commit
813cbe7b13
2 changed files with 14 additions and 2 deletions
|
@ -5,6 +5,7 @@ from __future__ import print_function
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from gestioncof.models import SurveyQuestionAnswer, SurveyQuestion, \
|
from gestioncof.models import SurveyQuestionAnswer, SurveyQuestion, \
|
||||||
CofProfile, EventOption, EventOptionChoice, Event, Club, CustomMail, \
|
CofProfile, EventOption, EventOptionChoice, Event, Club, CustomMail, \
|
||||||
Survey, EventCommentField, EventRegistration
|
Survey, EventCommentField, EventRegistration
|
||||||
|
@ -162,6 +163,13 @@ class UserProfileAdmin(UserAdmin):
|
||||||
return False
|
return False
|
||||||
is_cof.short_description = 'Membre du COF'
|
is_cof.short_description = 'Membre du COF'
|
||||||
is_cof.boolean = True
|
is_cof.boolean = True
|
||||||
|
|
||||||
|
fieldsets = [
|
||||||
|
(None, {'fields': ['username', 'password']}),
|
||||||
|
(_('Personal info'), {'fields': ['first_name', 'last_name', 'email']}),
|
||||||
|
(_('Groups'), {'fields': ['groups']})
|
||||||
|
]
|
||||||
|
|
||||||
list_display = ('profile_num',) + UserAdmin.list_display \
|
list_display = ('profile_num',) + UserAdmin.list_display \
|
||||||
+ ('profile_login_clipper', 'profile_phone', 'profile_occupation',
|
+ ('profile_login_clipper', 'profile_phone', 'profile_occupation',
|
||||||
'profile_mailing_cof', 'profile_mailing_bda',
|
'profile_mailing_cof', 'profile_mailing_bda',
|
||||||
|
@ -175,6 +183,11 @@ class UserProfileAdmin(UserAdmin):
|
||||||
CofProfileInline,
|
CofProfileInline,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def save_model(self, request, user, form, change):
|
||||||
|
if user.profile.is_buro:
|
||||||
|
user.is_staff = True
|
||||||
|
user.save()
|
||||||
|
|
||||||
|
|
||||||
# FIXME: This is absolutely horrible.
|
# FIXME: This is absolutely horrible.
|
||||||
def user_unicode(self):
|
def user_unicode(self):
|
||||||
|
|
|
@ -58,8 +58,7 @@ class COFCASBackend(CASBackend):
|
||||||
if not user.email:
|
if not user.email:
|
||||||
user.email = settings.CAS_EMAIL_FORMAT % profile.login_clipper
|
user.email = settings.CAS_EMAIL_FORMAT % profile.login_clipper
|
||||||
user.save()
|
user.save()
|
||||||
if profile.is_buro and not user.is_superuser:
|
if profile.is_buro and not user.is_staff:
|
||||||
user.is_superuser = True
|
|
||||||
user.is_staff = True
|
user.is_staff = True
|
||||||
user.save()
|
user.save()
|
||||||
return user
|
return user
|
||||||
|
|
Loading…
Reference in a new issue