示例#1
0
 def process_request(self, request):
     if settings.GET_PARAMETER in request.GET:
         referrer = None
         referrer_name = request.GET[settings.GET_PARAMETER]
         try:
             referrer = Referrer.objects.get(name=referrer_name)
         except Referrer.DoesNotExist:
             if settings.AUTO_CREATE:
                 referrer = Referrer(name=referrer_name)
                 referrer.save()
             if settings.AUTO_ASSOCIATE:
                 referrer.match_campaign()
         finally:
             if not referrer is None:
                 request.session[settings.SESSION_KEY] = referrer
示例#2
0
    def referrers_post_detail(self, post, days=3, _callback=None, **kwargs):
        url = post.url if hasattr(post, 'url') else post
        dates = self._format_date_args(**kwargs)
        options = {'days': days, 'url': url}

        handler = self._build_callback(
            lambda res: [Referrer.new_from_json_dict(x) for x in res['data']],
            _callback)
        res = self.conn._request_endpoint('/referrers/post/detail',
                                          dict(options.items() + dates.items()),
                                          _callback=handler if _callback else None)
        return handler(res) if not _callback else None
示例#3
0
    def referrers_post_detail(self, post, days=3, _callback=None, **kwargs):
        url = post.url if hasattr(post, 'url') else post
        dates = self._format_date_args(**kwargs)
        options = {'days': days, 'url': url}

        handler = self._build_callback(
            lambda res: [Referrer.new_from_json_dict(x) for x in res['data']],
            _callback)
        res = self.conn._request_endpoint(
            '/referrers/post/detail',
            dict(options.items() + dates.items()),
            _callback=handler if _callback else None)
        return handler(res) if not _callback else None
 def process_request(self, request):
     if settings.GET_PARAMETER in request.GET:
         referrer = None
         referrer_name = request.GET.get(settings.GET_PARAMETER, '').lower()
         try:
             referrer = Referrer.objects.get(name=referrer_name)
         except Referrer.DoesNotExist:
             if settings.AUTO_CREATE:
                 referrer = Referrer(name=referrer_name)
                 referrer.save()
             if referrer is not None and settings.AUTO_ASSOCIATE:
                 referrer.match_campaign()
         finally:
             if not referrer is None:
                 request.session[settings.SESSION_KEY] = referrer.pk
示例#5
0
 def inner(res):
     for r in res['data']:
         r['ref_type'] = ref_type
     return [Referrer.new_from_json_dict(x) for x in res['data']]
示例#6
0
 def inner(res):
     for r in res['data']:
         r['ref_type'] = ref_type
     return [Referrer.new_from_json_dict(x) for x in res['data']]