This commit is contained in:
Ross
2021-07-30 21:57:45 +01:00
parent 6387fbdecb
commit bd90ff571d
2 changed files with 17 additions and 6 deletions
+12 -1
View File
@@ -1,5 +1,16 @@
from django.core.exceptions import PermissionDenied
from .models import Long
from .models import Long, LongSeries
def user_is_author_or_long_series_checker(function):
def wrap(request, *args, **kwargs):
series = LongSeries.objects.get(pk=kwargs['pk'])
if request.user in series.get_author_objects() or request.user.groups.filter(name='long_checker').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_author_or_long_checker(function):
def wrap(request, *args, **kwargs):