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.
16 lines
557 B
16 lines
557 B
from django.http import HttpResponseForbidden
|
|
from django.contrib import messages
|
|
|
|
|
|
class CheckForUserMixin(object):
|
|
|
|
def dispatch(self, request, *args, **kwargs):
|
|
messages.info(request,str(request.user))
|
|
if request.user.is_authenticated():
|
|
pk = kwargs.get('pk')
|
|
if pk:
|
|
if request.user.pk != int(pk):
|
|
return HttpResponseForbidden('403 Forbidden')
|
|
else:
|
|
return HttpResponseForbidden('403 Forbidden')
|
|
return super().dispatch(request, *args, **kwargs)
|
|
|