This commit is contained in:
Ross
2022-04-02 23:07:04 +01:00
parent 58ae0692e0
commit 7930443029
2 changed files with 22 additions and 5 deletions
+17 -1
View File
@@ -1,5 +1,5 @@
from django.core.exceptions import PermissionDenied
from .models import Case, Series
from .models import Case, CaseCollection, Series
def user_is_author_or_atlas_series_checker_or_atlas_marker(function):
@@ -71,6 +71,22 @@ def user_is_author_or_atlas_editor(function):
wrap.__name__ = function.__name__
return wrap
def user_is_collection_author_or_atlas_editor(function):
def wrap(request, *args, **kwargs):
atlas = CaseCollection.objects.get(pk=kwargs["pk"])
if (
request.user in atlas.author.all()
or request.user.groups.filter(name="atlas_editor").exists()
or request.user.is_superuser
):
return function(request, *args, **kwargs)
else:
raise PermissionDenied
wrap.__doc__ = function.__doc__
wrap.__name__ = function.__name__
return wrap
def user_is_atlas_editor(function):
def wrap(request, *args, **kwargs):