def ownership_required(function=None):
    def decorator(request, *args, **kwargs):
        group = get_object_or_404(Group, slug=kwargs['slug'])
        if request.user.is_anonymous():
            return HttpResponseRedirect(reverse('django.contrib.auth.views.login'))
        if GroupMember.objects.is_owner(group, request.user):
            return function(request, *args, **kwargs)
        else:
            raise Http404
    return decorator
Decorator for views that require ownership status of a group.
dataset/ETHPy150Open nathanborror/django-basic-apps/basic/groups/decorators.py/ownership_required