(self)
return decorator
Returns a view function decorator that checks to see if the domain
        or user in the request has the appropriate toggle enabled.
Returns a view function decorator that checks to see if the domain
        or user in the request has the appropriate toggle enabled.
Returns a view function decorator that checks to see if the domain or user in the request has the appropriate toggle enabled .
def required_decorator(self):
        """
        Returns a view function decorator that checks to see if the domain
        or user in the request has the appropriate toggle enabled.
        """

        def decorator(view_func):
            @wraps(view_func)
            def wrapped_view(request, *args, **kwargs):
                if self.enabled_for_request(request):
                    return view_func(request, *args, **kwargs)
                if request.user.is_superuser:
                    from corehq.apps.toggle_ui.views import ToggleEditView
                    toggle_url = reverse(ToggleEditView.urlname, args=[self.slug])
                    messages.warning(
                        request,
                        format_html(
                            'This <a href="{}">feature flag</a> should be enabled '
                            'to access this URL',
                            toggle_url
                        ),
                        fail_silently=True,  # workaround for tests: https://code.djangoproject.com/ticket/17971
                    )
                raise Http404()

            return wrapped_view

        return decorator
def required_decorator ( self ) : def decorator ( view_func ) : @ wraps ( view_func ) def wrapped_view ( request , * args , * * kwargs ) : if self . enabled_for_request ( request ) : return view_func ( request , * args , * * kwargs ) if request . user . is_superuser : from corehq . apps . toggle_ui . views import ToggleEditView toggle_url = reverse ( ToggleEditView . urlname , args = [ self . slug ] ) messages . warning ( request , format_html ( 'This <a href="{}">feature flag</a> should be enabled ' 'to access this URL' , toggle_url ) , fail_silently = True , # workaround for tests: https://code.djangoproject.com/ticket/17971 ) raise Http404 ( ) return wrapped_view return decorator