From fea0b8604d907c01bede2747183d765b945e5d16 Mon Sep 17 00:00:00 2001 From: Aroy-Art Date: Fri, 3 Jan 2025 22:42:33 +0100 Subject: [PATCH] Add admin only or read only permission for api --- archivist/apps/api/permissions.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/archivist/apps/api/permissions.py b/archivist/apps/api/permissions.py index 0ebdc6b..34961f9 100644 --- a/archivist/apps/api/permissions.py +++ b/archivist/apps/api/permissions.py @@ -13,3 +13,10 @@ class AdminOnly(permissions.BasePermission): def has_permission(self, request, view): return check_admin(request.user) + +class AdminOnlyOrReadOnly(permissions.BasePermission): + def has_permission(self, request, view): + if request.method in permissions.SAFE_METHODS: + return True + return check_admin(request.user) +