def dispatch(self, request, *args, **kwargs): member = get_object_or_404(Member, pk=kwargs.get('pk', None)) if permissions.can_user_edit_member(request.user, member): return super(EditProfileView, self).dispatch(request, *args, **kwargs) else: return HttpResponseForbidden('You do not have permission to edit this profile.')
def can_edit_member(user, member): return permissions.can_user_edit_member(user, member)