def dispatch(self, request, *args, **kwargs): member = get_object_or_404(Member, pk=kwargs.get('pk', None)) if permissions.can_user_archive_member(request.user, member): return super(ArchiveMemberView, self).dispatch(request, *args, **kwargs) else: return HttpResponseForbidden('You do not have permission to archive members.')
def can_archive_member(user, member): return permissions.can_user_archive_member(user, member)