Esempio n. 1
0
def product_list(request):
    """The product picker page."""
    if not show_new_sumo(request):
        return old_products(request)

    products = Product.objects.filter(visible=True)
    return jingo.render(request, 'products/products.html', {
        'products': products})
Esempio n. 2
0
def post_preview_async(request):
    """Ajax preview of posts."""
    statsd.incr('forums.preview')
    post = Post(author=request.user, content=request.POST.get('content', ''))
    post.author_post_count = 1
    if show_new_sumo(request):
        template = 'forums/includes/post_preview-new.html'
    else:
        template = 'forums/includes/post_preview.html'

    return jingo.render(request, template, {'post_preview': post})
Esempio n. 3
0
def answer_preview_async(request):
    """Create an HTML fragment preview of the posted wiki syntax."""
    statsd.incr('questions.preview')
    answer = Answer(creator=request.user,
                    content=request.POST.get('content', ''))

    if show_new_sumo(request):
        template = 'questions/includes/answer_preview-new.html'
    else:
        template = 'questions/includes/answer_preview.html'

    return jingo.render(request, template, {'answer_preview': answer})
Esempio n. 4
0
def landing(request, template='wiki/landing.html'):
    """The KB landing page.

    Lists topics and products.
    """
    if not show_new_sumo(request):
        from landings.views import old_kb
        return old_kb(request)

    return jingo.render(request, template, {
        'products': Product.objects.filter(visible=True),
        'topics': Topic.objects.filter(visible=True)})
Esempio n. 5
0
def landing(request, template='wiki/landing.html'):
    """The KB landing page.

    Lists topics and products.
    """
    if not show_new_sumo(request):
        from landings.views import old_kb
        return old_kb(request)

    return jingo.render(
        request, template, {
            'products': Product.objects.filter(visible=True),
            'topics': Topic.objects.filter(visible=True)
        })
Esempio n. 6
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})
Esempio n. 7
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})
Esempio n. 8
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.
    """
    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)
Esempio n. 9
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.
    """
    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)
Esempio n. 10
0
def home(request):
    """The home page."""
    if not show_new_sumo(request):
        return old_home(request)

    products = Product.objects.filter(visible=True)
    topics = Topic.objects.filter(visible=True)
    moz_news = get_object_fallback(
        Document, MOZILLA_NEWS_DOC, request.locale)

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

    return jingo.render(request, 'landings/home.html', {
        'products': products,
        'topics': topics,
        'hot_docs': hot_docs,
        'moz_news': moz_news})
Esempio n. 11
0
def home(request):
    """The home page."""
    if not show_new_sumo(request):
        return old_home(request)

    products = Product.objects.filter(visible=True)
    topics = Topic.objects.filter(visible=True)
    moz_news = get_object_fallback(Document, MOZILLA_NEWS_DOC, request.locale)

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

    return jingo.render(
        request, 'landings/home.html', {
            'products': products,
            'topics': topics,
            'hot_docs': hot_docs,
            'moz_news': moz_news
        })