.
This commit is contained in:
+17
-1
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user