Beispiel #1
0
def document_listing(request, template, product_slug, topic_slug):
    """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)
    refine_slug = request.GET.get("refine")
    if refine_slug:
        refine = get_object_or_404(Topic, slug=refine_slug)
        topics = [topic, refine]
    else:
        refine = None
        topics = [topic]
    documents, fallback_documents = documents_for(locale=request.LANGUAGE_CODE, products=[product], topics=topics)

    return jingo.render(
        request,
        template,
        {
            "product": product,
            "topic": topic,
            "topics": topics_for(products=[product]),
            "refine": refine,
            "refine_topics": topics_for(products=[product], topics=[topic]),
            "documents": documents,
            "fallback_documents": fallback_documents,
            "search_params": {"product": product_slug},
        },
    )
Beispiel #2
0
def document_listing(request, template, product_slug, topic_slug):
    """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)
    refine_slug = request.GET.get('refine')
    if refine_slug:
        refine = get_object_or_404(Topic, slug=refine_slug)
        topics = [topic, refine]
    else:
        refine = None
        topics = [topic]
    documents, fallback_documents = documents_for(locale=request.LANGUAGE_CODE,
                                                  products=[product],
                                                  topics=topics)

    return render(
        request, template, {
            'product': product,
            'topic': topic,
            'topics': topics_for(products=[product]),
            'refine': refine,
            'refine_topics': topics_for(products=[product], topics=[topic]),
            'documents': documents,
            'fallback_documents': fallback_documents,
            'search_params': {
                'product': product_slug
            }
        })
Beispiel #3
0
    def test_topics_for_products(self):
        """Verify topics_for() returns topics for passed products."""
        desktop_topics = topics_for(products=[self.desktop])
        eq_(len(desktop_topics), 3)

        mobile_topics = topics_for(products=[self.mobile])
        eq_(len(mobile_topics), 2)

        desktop_mobile_topics = topics_for(
            products=[self.desktop, self.mobile])
        eq_(len(desktop_mobile_topics), 2)
Beispiel #4
0
    def test_topics_for_products(self):
        """Verify topics_for() returns products for passed products."""
        desktop_topics = topics_for(products=[self.desktop])
        eq_(len(desktop_topics), 3)

        mobile_topics = topics_for(products=[self.mobile])
        eq_(len(mobile_topics), 2)

        desktop_mobile_topics = topics_for(
            products=[self.desktop, self.mobile])
        eq_(len(desktop_mobile_topics), 2)
Beispiel #5
0
    def test_topics_for_products_and_topics(self):
        """Verify topics_for() returns topics for passed products."""
        desktop_bookmarks_topics = topics_for(
            products=[self.desktop], topics=[self.bookmarks])
        eq_(len(desktop_bookmarks_topics), 3)

        desktop_sync_topics = topics_for(
            products=[self.desktop], topics=[self.sync])
        eq_(len(desktop_sync_topics), 2)

        desktop_sync_general_topics = topics_for(
            products=[self.desktop], topics=[self.sync, self.general])
        eq_(len(desktop_sync_general_topics), 0)
Beispiel #6
0
    def test_topics_for_products_and_topics(self):
        """Verify topics_for() returns topics for passed products."""
        desktop_bookmarks_topics = topics_for(products=[self.desktop],
                                              topics=[self.bookmarks])
        eq_(len(desktop_bookmarks_topics), 3)

        desktop_sync_topics = topics_for(products=[self.desktop],
                                         topics=[self.sync])
        eq_(len(desktop_sync_topics), 2)

        desktop_sync_general_topics = topics_for(
            products=[self.desktop], topics=[self.sync, self.general])
        eq_(len(desktop_sync_general_topics), 0)
Beispiel #7
0
def product_landing(request, slug):
    """The product landing page."""
    if not show_ia(request):
        return HttpResponseRedirect(reverse('products'))

    product = get_object_or_404(Product, slug=slug)
    return jingo.render(request, 'products/product.html', {
        'product': product,
        'topics': topics_for(products=[product])})
Beispiel #8
0
def document_listing(request, product_slug, topic_slug):
    """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)
    refine_slug = request.GET.get('refine')
    if refine_slug:
        refine = get_object_or_404(Topic, slug=refine_slug)
        topics = [topic, refine]
    else:
        refine = None
        topics = [topic]
    documents, fallback_documents = documents_for(
        locale=request.locale, products=[product], topics=topics)

    return jingo.render(request, 'products/documents.html', {
        'product': product,
        'topic': topic,
        'topics': topics_for(products=[product]),
        'refine': refine,
        'refine_topics': topics_for(products=[product], topics=[topic]),
        'documents': documents,
        'fallback_documents': fallback_documents})
Beispiel #9
0
def document_listing(request, product_slug, topic_slug):
    """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)
    documents, fallback_documents = documents_for(
        locale=request.locale, products=[product], topics=[topic])

    return jingo.render(request, 'products/documents.html', {
        'product': product,
        'topic': topic,
        'topics': topics_for(products=[product]),
        'documents': documents,
        'fallback_documents': fallback_documents})
Beispiel #10
0
def document_listing(request, template, product_slug, topic_slug):
    """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)
    refine_slug = request.GET.get('refine')
    if refine_slug:
        refine = get_object_or_404(Topic, slug=refine_slug)
        topics = [topic, refine]
    else:
        refine = None
        topics = [topic]
    documents, fallback_documents = documents_for(
        locale=request.LANGUAGE_CODE, products=[product], topics=topics)

    return render(request, template, {
        'product': product,
        'topic': topic,
        'topics': topics_for(products=[product]),
        'refine': refine,
        'refine_topics': topics_for(products=[product], topics=[topic]),
        'documents': documents,
        'fallback_documents': fallback_documents,
        'search_params': {'product': product_slug}})
Beispiel #11
0
def document_listing(request, product_slug, topic_slug):
    """The document listing page for a product + topic."""
    if not show_new_sumo(request):
        return HttpResponseRedirect(reverse('products'))

    product = get_object_or_404(Product, slug=product_slug)
    topic = get_object_or_404(Topic, slug=topic_slug)
    documents = documents_for(
        locale=request.locale, products=[product], topics=[topic])
    return jingo.render(request, 'products/documents.html', {
        'product': product,
        'topic': topic,
        'topics': topics_for(products=[product]),
        'documents': documents})
Beispiel #12
0
def product_landing(request, slug):
    """The product landing page."""
    if not show_new_sumo(request):
        return HttpResponseRedirect(reverse('products'))

    product = get_object_or_404(Product, slug=slug)
    hot_docs = documents_for(
        locale=request.locale,
        topics=[Topic.objects.get(slug=HOT_TOPIC_SLUG)],
        products=[product])
    return jingo.render(request, 'products/product.html', {
        'product': product,
        'products': Product.objects.filter(visible=True),
        'topics': topics_for(products=[product]),
        'hot_docs': hot_docs})
Beispiel #13
0
def document_listing(request, template, product_slug, topic_slug):
    """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)
    documents, fallback_documents = documents_for(
        locale=request.LANGUAGE_CODE, products=[product], topics=[topic])

    subtopics = Topic.objects.filter(parent=topic)

    return render(request, template, {
        'product': product,
        'topic': topic,
        'topics': topics_for(products=[product]),
        'subtopics': subtopics,
        'documents': documents,
        'fallback_documents': fallback_documents,
        'search_params': {'product': product_slug}})
Beispiel #14
0
def product_landing(request, template, slug):
    """The product landing page."""
    product = get_object_or_404(Product, slug=slug)

    try:
        hot_docs, fallback_hot_docs = documents_for(
            locale=request.locale,
            topics=[Topic.objects.get(slug=HOT_TOPIC_SLUG)],
            products=[product])
    except Topic.DoesNotExist:
        # "hot" topic doesn't exist, move on.
        hot_docs = fallback_hot_docs = None

    return jingo.render(request, template, {
        'product': product,
        'products': Product.objects.filter(visible=True),
        'topics': topics_for(products=[product]),
        'hot_docs': hot_docs,
        'fallback_hot_docs': fallback_hot_docs})
Beispiel #15
0
def document_listing(request, template, product_slug, topic_slug):
    """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)
    documents, fallback_documents = documents_for(locale=request.LANGUAGE_CODE,
                                                  products=[product],
                                                  topics=[topic])

    subtopics = Topic.objects.filter(parent=topic)

    return render(
        request, template, {
            'product': product,
            'topic': topic,
            'topics': topics_for(products=[product]),
            'subtopics': subtopics,
            'documents': documents,
            'fallback_documents': fallback_documents,
            'search_params': {
                'product': product_slug
            }
        })
Beispiel #16
0
def product_landing(request, template, slug):
    """The product landing page."""
    product = get_object_or_404(Product, slug=slug)

    try:
        hot_docs, fallback_hot_docs = documents_for(
            locale=request.LANGUAGE_CODE,
            topics=[Topic.objects.get(slug=HOT_TOPIC_SLUG)],
            products=[product])
    except Topic.DoesNotExist:
        # "hot" topic doesn't exist, move on.
        hot_docs = fallback_hot_docs = None

    return render(
        request, template, {
            'product': product,
            'products': Product.objects.filter(visible=True),
            'topics': topics_for(products=[product]),
            'hot_docs': hot_docs,
            'fallback_hot_docs': fallback_hot_docs,
            'search_params': {
                'product': slug
            }
        })
Beispiel #17
0
def product_landing(request, template, slug):
    """The product landing page."""
    product = get_object_or_404(Product, slug=slug)

    try:
        hot_docs, fallback_hot_docs = documents_for(
            locale=request.LANGUAGE_CODE, topics=[Topic.objects.get(slug=HOT_TOPIC_SLUG)], products=[product]
        )
    except Topic.DoesNotExist:
        # "hot" topic doesn't exist, move on.
        hot_docs = fallback_hot_docs = None

    return jingo.render(
        request,
        template,
        {
            "product": product,
            "products": Product.objects.filter(visible=True),
            "topics": topics_for(products=[product]),
            "hot_docs": hot_docs,
            "fallback_hot_docs": fallback_hot_docs,
            "search_params": {"product": slug},
        },
    )