示例#1
0
def follow_banner_link(request, banner_instance_id):
    """
    Add a click to a banner instance and redirect the user to the Firefox
    download page.
    """
    try:
        banner_instance = FacebookBannerInstance.objects.select_related("banner").get(id=banner_instance_id)
    except FacebookBannerInstance.DoesNotExist:
        return django_redirect(settings.FACEBOOK_DOWNLOAD_URL)

    # Do not add a click if the request is from the Facebook bot.
    if not is_facebook_bot(request):
        add_click.delay(banner_instance_id)

    return django_redirect(banner_instance.banner.link)
示例#2
0
def follow_banner_link(request, banner_instance_id):
    """
    Add a click to a banner instance and redirect the user to the Firefox
    download page.
    """
    try:
        banner_instance = (
            FacebookBannerInstance.objects.select_related('banner').get(
                id=banner_instance_id))
    except FacebookBannerInstance.DoesNotExist:
        return django_redirect(settings.FACEBOOK_DOWNLOAD_URL)

    # Do not add a click if the request is from the Facebook bot.
    if not is_facebook_bot(request):
        add_click.delay(banner_instance_id)

    return django_redirect(banner_instance.banner.link)
示例#3
0
 def test_is_not_a_bot(self):
     request = self.factory.get('/', HTTP_USER_AGENT='not.facebook')
     eq_(is_facebook_bot(request), False)
示例#4
0
 def test_is_bot(self):
     request = self.factory.get('/', HTTP_USER_AGENT=FACEBOOK_USER_AGENT)
     eq_(is_facebook_bot(request), True)
示例#5
0
 def test_is_not_a_bot(self):
     request = self.factory.get('/', HTTP_USER_AGENT='not.facebook')
     eq_(is_facebook_bot(request), False)
示例#6
0
 def test_is_bot(self):
     request = self.factory.get('/', HTTP_USER_AGENT=FACEBOOK_USER_AGENT)
     eq_(is_facebook_bot(request), True)