Autoselect user in admin
This commit is contained in:
parent
21c1dd067a
commit
b41fe3525b
|
@ -85,6 +85,16 @@ class EmpruntAdmin(VersionAdmin):
|
||||||
permanencier_rendu_custom.short_description = _('given back to')
|
permanencier_rendu_custom.short_description = _('given back to')
|
||||||
permanencier_rendu_custom.allow_tags = True
|
permanencier_rendu_custom.allow_tags = True
|
||||||
|
|
||||||
|
def add_view(self, request, form_url='', extra_context=None):
|
||||||
|
"""
|
||||||
|
Autoselect keyholder registering a new borrowed item
|
||||||
|
"""
|
||||||
|
# Make GET data mutable
|
||||||
|
data = request.GET.copy()
|
||||||
|
data['permanencier_emprunt'] = request.user
|
||||||
|
request.GET = data
|
||||||
|
return super().add_view(request, form_url, extra_context)
|
||||||
|
|
||||||
|
|
||||||
class JeuAdmin(VersionAdmin):
|
class JeuAdmin(VersionAdmin):
|
||||||
list_display = ('name', 'proprietaire', 'duree', 'nombre_joueurs_min',
|
list_display = ('name', 'proprietaire', 'duree', 'nombre_joueurs_min',
|
||||||
|
|
|
@ -33,5 +33,15 @@ class GameSaveAdmin(admin.ModelAdmin):
|
||||||
return True
|
return True
|
||||||
return super().has_delete_permission(request, obj)
|
return super().has_delete_permission(request, obj)
|
||||||
|
|
||||||
|
def add_view(self, request, form_url='', extra_context=None):
|
||||||
|
"""
|
||||||
|
Autoselect game master when creating a new game
|
||||||
|
"""
|
||||||
|
# Make GET data mutable
|
||||||
|
data = request.GET.copy()
|
||||||
|
data['game_master'] = request.user
|
||||||
|
request.GET = data
|
||||||
|
return super().add_view(request, form_url, extra_context)
|
||||||
|
|
||||||
|
|
||||||
admin_site.register(GameSave, GameSaveAdmin)
|
admin_site.register(GameSave, GameSaveAdmin)
|
||||||
|
|
Loading…
Reference in New Issue