def test_products_for_topics(self): """Verify products_for() returns products for passed topics.""" general_prods = products_for(topics=[self.general]) eq_(len(general_prods), 1) eq_(general_prods[0].slug, self.desktop.slug) bookmarks_prods = products_for(topics=[self.bookmarks]) eq_(len(bookmarks_prods), 2) bookmarks_sync_prods = products_for(topics=[self.bookmarks, self.sync]) eq_(len(bookmarks_sync_prods), 2) bookmarks_general_prods = products_for( topics=[self.bookmarks, self.general]) eq_(len(bookmarks_general_prods), 1) eq_(self.desktop.slug, bookmarks_general_prods[0].slug) sync_general_prods = products_for(topics=[self.sync, self.general]) eq_(len(sync_general_prods), 0)
def topic_landing(request, slug): """The topic landing page. If `selectproduct=1` query param is passed, shows the product picker. Else, shows the list of articles. """ topic = get_object_or_404(Topic, slug=slug) topics = Topic.objects.filter(visible=True) data = dict(topic=topic, topics=topics) if request.GET.get("selectproduct") == "1": data.update(products=products_for(topics=[topic])) else: docs, fallback = documents = documents_for(locale=request.locale, topics=[topic]) data.update(documents=docs, fallback_documents=fallback) return jingo.render(request, "topics/topic.html", data)
def topic_landing(request, slug): """The topic landing page. If `selectproduct=1` query param is passed, shows the product picker. Else, shows the list of articles. """ topic = get_object_or_404(Topic, slug=slug) topics = Topic.objects.filter(visible=True) data = dict(topic=topic, topics=topics) if request.GET.get('selectproduct') == '1': data.update(products=products_for(topics=[topic])) else: docs, fallback = documents_for( locale=request.LANGUAGE_CODE, topics=[topic]) data.update(documents=docs, fallback_documents=fallback) return render(request, 'topics/topic.html', data)
def topic_landing(request, slug): """The topic landing page. If `selectproduct=1` query param is passed, shows the product picker. Else, shows the list of articles. """ if not show_new_sumo(request): # User should only be able to get here in new IA. # Redirect to home page return HttpResponseRedirect(reverse("home")) topic = get_object_or_404(Topic, slug=slug) data = dict(topic=topic) if request.GET.get("selectproduct") == "1": data.update(products=products_for(topics=[topic])) else: data.update(documents=documents_for(locale=request.locale, topics=[topic])) return jingo.render(request, "topics/topic.html", data)
def topic_landing(request, slug): """The topic landing page. If `selectproduct=1` query param is passed, shows the product picker. Else, shows the list of articles. """ if not show_new_sumo(request): # User should only be able to get here in new IA. # Redirect to home page return HttpResponseRedirect(reverse('home')) topic = get_object_or_404(Topic, slug=slug) data = dict(topic=topic) if request.GET.get('selectproduct') == '1': data.update(products=products_for(topics=[topic])) else: data.update(documents=documents_for( locale=request.locale, topics=[topic])) return jingo.render(request, 'topics/topic.html', data)