示例#1
0
    def test_internet_explorer(self):
        """Test with User Agent of Internet Explorer"""

        # Check with default User Agent of IE 11
        user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko'
        eq_(get_browser(user_agent), 'Trident')
        # Check with Compatibility View situation user Agent of IE11
        user_agent = ('Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; '
                      'Trident/7.0;  rv:11.0) like Gecko')
        eq_(get_browser(user_agent), 'MSIE')
示例#2
0
def product_landing(request, template, slug):
    """The product landing page."""
    product = get_object_or_404(Product, slug=slug)

    if request.is_ajax():
        # Return a list of topics/subtopics for the product
        topic_list = list()
        for t in Topic.objects.filter(product=product, visible=True):
            topic_list.append({'id': t.id, 'title': t.title})
        return HttpResponse(json.dumps({'topics': topic_list}),
                            content_type='application/json')

    if slug == 'firefox':
        latest_version = product_details.json_data['firefox_versions']['LATEST_FIREFOX_VERSION']
    else:
        versions = product.versions.filter(default=True)
        if versions:
            latest_version = versions[0].min_version
        else:
            latest_version = 0

    user_agent = request.META.get('HTTP_USER_AGENT', '')
    browser = get_browser(user_agent)
    show_fx_download = (product.slug == 'thunderbird' and browser != 'Firefox')

    return render(request, template, {
        'product': product,
        'products': Product.objects.filter(visible=True),
        'topics': topics_for(product=product, parent=None),
        'search_params': {'product': slug},
        'latest_version': latest_version,
        'show_fx_download': show_fx_download
    })
示例#3
0
def document_listing(request, template, product_slug, topic_slug, subtopic_slug=None):
    """The document listing page for a product + topic."""
    product = get_object_or_404(Product, slug=product_slug)
    topic = get_object_or_404(Topic, slug=topic_slug, product=product, parent__isnull=True)

    doc_kw = {"locale": request.LANGUAGE_CODE, "products": [product]}

    if subtopic_slug is not None:
        subtopic = get_object_or_404(Topic, slug=subtopic_slug, product=product, parent=topic)
        doc_kw["topics"] = [subtopic]
    else:
        subtopic = None
        doc_kw["topics"] = [topic]

    documents, fallback_documents = documents_for(**doc_kw)

    user_agent = request.META.get("HTTP_USER_AGENT", "")
    browser = get_browser(user_agent)
    show_fx_download = product.slug == "thunderbird" and browser != "Firefox"

    return render(
        request,
        template,
        {
            "product": product,
            "topic": topic,
            "subtopic": subtopic,
            "topics": topics_for(product=product, parent=None),
            "subtopics": topics_for(product=product, parent=topic),
            "documents": documents,
            "fallback_documents": fallback_documents,
            "search_params": {"product": product_slug},
            "show_fx_download": show_fx_download,
        },
    )
示例#4
0
    def test_safari(self):
        """Test with User Agent of Safari"""

        user_agent = ('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14'
                      '(KHTML, like Gecko) Version/7.0.3 Safari/7046A194A')
        # Check Safari is returning
        eq_(get_browser(user_agent), 'Safari')
示例#5
0
    def test_chrome(self):
        """Test with User Agent of Chrome"""

        user_agent = ('Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) '
                      'Chrome/41.0.2228.0 Safari/537.36')
        # Check Chrome is returning
        eq_(get_browser(user_agent), 'Chrome')
示例#6
0
def document_listing(request, template, product_slug, topic_slug,
                     subtopic_slug=None):
    """The document listing page for a product + topic."""
    product = get_object_or_404(Product, slug=product_slug)
    topic = get_object_or_404(Topic, slug=topic_slug, product=product,
                              parent__isnull=True)

    doc_kw = {'locale': request.LANGUAGE_CODE, 'products': [product]}

    if subtopic_slug is not None:
        subtopic = get_object_or_404(Topic, slug=subtopic_slug,
                                     product=product, parent=topic)
        doc_kw['topics'] = [subtopic]
    else:
        subtopic = None
        doc_kw['topics'] = [topic]

    documents, fallback_documents = documents_for(**doc_kw)

    user_agent = request.META.get('HTTP_USER_AGENT', '')
    browser = get_browser(user_agent)
    show_fx_download = (product.slug == 'thunderbird' and browser != 'Firefox')

    return render(request, template, {
        'product': product,
        'topic': topic,
        'subtopic': subtopic,
        'topics': topics_for(product=product, parent=None),
        'subtopics': topics_for(product=product, parent=topic),
        'documents': documents,
        'fallback_documents': fallback_documents,
        'search_params': {'product': product_slug},
        'show_fx_download': show_fx_download})
示例#7
0
    def test_firefox(self):
        """Test with User Agent of Firefox"""

        user_agent = 'Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0'
        # Check Firefox is returning
        eq_(get_browser(user_agent), 'Firefox')