cosmetic: python-black
This commit is contained in:
parent
75e3d2e1c0
commit
e15bde964f
1 changed files with 31 additions and 14 deletions
|
@ -15,6 +15,7 @@ from calendrier.models import Event
|
|||
|
||||
class UserProfileInline(admin.StackedInline):
|
||||
"""Affichage du profil ernestophone dans la vue UserAdmin"""
|
||||
|
||||
model = ErnestoUser
|
||||
|
||||
|
||||
|
@ -24,10 +25,12 @@ def ProfileInfo(field, short_description, boolean=False):
|
|||
return getattr(self.profile, field)
|
||||
except ErnestoUser.DoesNotExist:
|
||||
return ""
|
||||
|
||||
getter.short_description = short_description
|
||||
getter.boolean = boolean
|
||||
return getter
|
||||
|
||||
|
||||
User.profile_phone = ProfileInfo("phone", "Telephone")
|
||||
User.profile_instru = ProfileInfo("instru", "Instrument joué")
|
||||
User.profile_is_ern = ProfileInfo("is_ernesto", "Ernestophoniste")
|
||||
|
@ -42,20 +45,32 @@ class UserProfileAdmin(UserAdmin):
|
|||
d'édition des comptes et événements mais il ne peuvent pas en créer via
|
||||
l'interface admin.
|
||||
"""
|
||||
list_display = ['username', 'first_name', 'last_name', 'email',
|
||||
'profile_phone', 'profile_instru', 'profile_is_ern',
|
||||
'profile_is_chef']
|
||||
list_display_links = ['username', 'email', 'first_name', 'last_name']
|
||||
list_filter = ['profile__instru']
|
||||
ordering = ['username']
|
||||
search_fields = ['username', 'first_name', 'last_name', 'profile__phone',
|
||||
'profile__instru']
|
||||
|
||||
list_display = [
|
||||
"username",
|
||||
"first_name",
|
||||
"last_name",
|
||||
"email",
|
||||
"profile_phone",
|
||||
"profile_instru",
|
||||
"profile_is_ern",
|
||||
"profile_is_chef",
|
||||
]
|
||||
list_display_links = ["username", "email", "first_name", "last_name"]
|
||||
list_filter = ["profile__instru"]
|
||||
ordering = ["username"]
|
||||
search_fields = [
|
||||
"username",
|
||||
"first_name",
|
||||
"last_name",
|
||||
"profile__phone",
|
||||
"profile__instru",
|
||||
]
|
||||
inlines = [UserProfileInline]
|
||||
|
||||
staff_fieldsets = [
|
||||
('Général', {'fields': ['username', 'password', 'first_name',
|
||||
'last_name']}),
|
||||
('Permissions', {'fields': ['is_active']})
|
||||
("Général", {"fields": ["username", "password", "first_name", "last_name"]}),
|
||||
("Permissions", {"fields": ["is_active"]}),
|
||||
]
|
||||
|
||||
def get_fieldsets(self, request, user=None):
|
||||
|
@ -77,9 +92,11 @@ class UserProfileAdmin(UserAdmin):
|
|||
if created:
|
||||
# Si le groupe vient d'être créé :
|
||||
# On associe les bonnes permissions au groupe Chef
|
||||
perms = [('change_user', 'auth', 'user'),
|
||||
('change_event', 'calendrier', 'event'),
|
||||
('change_ernestouser', 'gestion', 'ernestouser')]
|
||||
perms = [
|
||||
("change_user", "auth", "user"),
|
||||
("change_event", "calendrier", "event"),
|
||||
("change_ernestouser", "gestion", "ernestouser"),
|
||||
]
|
||||
for nat_key in perms:
|
||||
perm = Permission.objects.get_by_natural_key(*nat_key)
|
||||
chef_group.permissions.add(perm)
|
||||
|
|
Loading…
Reference in a new issue