Exemple #1
0
    def __call__(self, request):
        url = resolve(request.path_info)
        request._namespace = url.namespace
        if url.namespace != 'presale':
            return self.get_response(request)

        if 'organizer' in url.kwargs or 'event' in url.kwargs or getattr(
                request, 'event_domain', False):
            redirect = _detect_event(
                request,
                require_live=url.url_name != 'event.widget.productlist')
            if redirect:
                return redirect

        with scope(organizer=getattr(request, 'organizer', None)):
            response = self.get_response(request)

            if hasattr(request, '_namespace'
                       ) and request._namespace == 'presale' and hasattr(
                           request, 'event'):
                for receiver, r in process_response.send(request.event,
                                                         request=request,
                                                         response=response):
                    response = r

            if isinstance(response, TemplateResponse):
                response = response.render()

        return response
Exemple #2
0
    def __call__(self, request):
        url = resolve(request.path_info)
        request._namespace = url.namespace

        if not hasattr(request, 'sales_channel'):
            # The environ lookup is only relevant during unit testing
            request.sales_channel = request.environ.get(
                'PRETIX_SALES_CHANNEL', WebshopSalesChannel())

        if url.namespace != 'presale':
            return self.get_response(request)

        if 'organizer' in url.kwargs or 'event' in url.kwargs or getattr(
                request, 'event_domain', False):
            redirect = _detect_event(request,
                                     require_live=url.url_name
                                     not in self.NO_REQUIRE_LIVE_URLS)
            if redirect:
                return redirect

        with scope(organizer=getattr(request, 'organizer', None)):
            response = self.get_response(request)

            if hasattr(request, '_namespace'
                       ) and request._namespace == 'presale' and hasattr(
                           request, 'event'):
                for receiver, r in process_response.send(request.event,
                                                         request=request,
                                                         response=response):
                    response = r

            if isinstance(response, TemplateResponse):
                response = response.render()

        return response
Exemple #3
0
 def wrap(request, *args, **kwargs):
     ret = _detect_event(request)
     if ret:
         return ret
     else:
         response = func(request=request, *args, **kwargs)
         for receiver, r in process_response.send(request.event, request=request, response=response):
             response = r
         return response
Exemple #4
0
 def wrap(request, *args, **kwargs):
     ret = _detect_event(request, require_live=require_live, require_plugin=require_plugin)
     if ret:
         return ret
     else:
         response = func(request=request, *args, **kwargs)
         for receiver, r in process_response.send(request.event, request=request, response=response):
             response = r
         return response
Exemple #5
0
 def process_response(self, request, response):
     if hasattr(
             request,
             '_namespace') and request._namespace == 'presale' and hasattr(
                 request, 'event'):
         for receiver, r in process_response.send(request.event,
                                                  request=request,
                                                  response=response):
             response = r
     return response
Exemple #6
0
        def wrap(request, *args, **kwargs):
            ret = _detect_event(request,
                                require_live=require_live,
                                require_plugin=require_plugin)
            if ret:
                return ret
            else:
                with scope(organizer=getattr(request, 'organizer', None)):
                    response = func(request=request, *args, **kwargs)
                    for receiver, r in process_response.send(
                            request.event, request=request, response=response):
                        response = r

                    if isinstance(response, TemplateResponse):
                        response = response.render()

                    return response
Exemple #7
0
 def process_response(self, request, response):
     if hasattr(request, 'event'):
         for receiver, r in process_response.send(request.event, request=request, response=response):
             response = r
     return response
Exemple #8
0
 def process_response(self, request, response):
     if hasattr(request, '_namespace') and request._namespace == 'presale' and hasattr(request, 'event'):
         for receiver, r in process_response.send(request.event, request=request, response=response):
             response = r
     return response