def dispatch(self, request, *args, **kwargs): page = get_object_or_404(Page, pk=kwargs.get('pk', None)) if permissions.can_user_delete_page(request.user, page): return super(DeletePageView, self).dispatch(request, *args, **kwargs) else: return HttpResponseForbidden('You do not have permission to delete projects.')
def can_delete_page(user, page): return permissions.can_user_delete_page(user, page)