You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
526 B
18 lines
526 B
from django.core.exceptions import PermissionDenied
|
|
|
|
|
|
class CheckForUserMixin(object):
|
|
def dispatch(self, request, *args, **kwargs):
|
|
if request.user.is_authenticated():
|
|
pk = kwargs.get('pk')
|
|
if pk:
|
|
if request.user.pk != int(pk):
|
|
raise PermissionDenied
|
|
else:
|
|
raise PermissionDenied
|
|
return super().dispatch(request, *args, **kwargs)
|
|
|
|
|
|
class OwnershipMixin(object):
|
|
def dispatch(self, request, *args, **kwargs):
|
|
pass
|
|
|