From 87ccc913f8c59b81b6916eddfc41b01290c8523d Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Mon, 31 Oct 2022 19:23:37 +0100 Subject: [PATCH] Allow users to change their own character --- src/character/admin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/character/admin.py b/src/character/admin.py index b496bbd..d750b66 100644 --- a/src/character/admin.py +++ b/src/character/admin.py @@ -173,6 +173,11 @@ class CharacterAdmin(admin.ModelAdmin): form = CharacterAdminForm + def has_change_permission(self, request, obj=None): + if obj is None: + return super().has_change_permission(request, obj) + return obj.player == request.user or request.user.is_superuser + @admin.register(models.Weapon) class WeaponAdmin(admin.ModelAdmin):