Commit b41fe352 authored by erdnaxe's avatar erdnaxe 🎇

Autoselect user in admin

parent 21c1dd06
Pipeline #1457 passed with stage
in 3 minutes and 29 seconds
......@@ -85,6 +85,16 @@ class EmpruntAdmin(VersionAdmin):
permanencier_rendu_custom.short_description = _('given back to')
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):
list_display = ('name', 'proprietaire', 'duree', 'nombre_joueurs_min',
......
......@@ -33,5 +33,15 @@ class GameSaveAdmin(admin.ModelAdmin):
return True
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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment