Beispiel #1
0
def locale_discussions(request):
    locale_name = LOCALES[request.LANGUAGE_CODE].native
    threads = Thread.objects.filter(document__locale=request.LANGUAGE_CODE,
                                    document__allow_discussion=True)
    try:
        sort = int(request.GET.get("sort", 5))
    except ValueError:
        sort = 5

    try:
        desc = int(request.GET.get("desc", 1))
    except ValueError:
        desc = 1
    desc_toggle = 0 if desc else 1

    threads_ = sort_threads(threads, sort, desc)
    threads_ = paginate(request, threads_, per_page=kbforums.THREADS_PER_PAGE)
    is_watching_locale = request.user.is_authenticated and NewThreadInLocaleEvent.is_notifying(
        request.user, locale=request.LANGUAGE_CODE)
    return render(
        request,
        "kbforums/discussions.html",
        {
            "locale_name": locale_name,
            "threads": threads_,
            "desc_toggle": desc_toggle,
            "is_watching_locale": is_watching_locale,
        },
    )
Beispiel #2
0
def locale_discussions(request):
    locale_name = LOCALES[request.LANGUAGE_CODE].native
    threads = Thread.objects.filter(document__locale=request.LANGUAGE_CODE,
                                    document__allow_discussion=True)
    try:
        sort = int(request.GET.get('sort', 0))
    except ValueError:
        sort = 0

    try:
        desc = int(request.GET.get('desc', 0))
    except ValueError:
        desc = 0
    desc_toggle = 0 if desc else 1

    threads_ = sort_threads(threads, sort, desc)

    # Ignore sticky-ness:
    threads_ = threads_.order_by('-last_post__created')
    threads_ = paginate(request, threads_, per_page=kbforums.THREADS_PER_PAGE)
    is_watching_locale = (request.user.is_authenticated()
                          and NewThreadInLocaleEvent.is_notifying(
                              request.user, locale=request.LANGUAGE_CODE))
    return render(
        request, 'kbforums/discussions.html', {
            'locale_name': locale_name,
            'threads': threads_,
            'desc_toggle': desc_toggle,
            'is_watching_locale': is_watching_locale
        })
Beispiel #3
0
def locale_discussions(request):
    locale_name = LOCALES[request.LANGUAGE_CODE].native
    threads = Thread.objects.filter(document__locale=request.LANGUAGE_CODE,
                                    document__allow_discussion=True)
    try:
        sort = int(request.GET.get('sort', 0))
    except ValueError:
        sort = 0

    try:
        desc = int(request.GET.get('desc', 0))
    except ValueError:
        desc = 0
    desc_toggle = 0 if desc else 1

    threads_ = sort_threads(threads, sort, desc)

    # Ignore sticky-ness:
    threads_ = threads_.order_by('-last_post__created')
    threads_ = paginate(request, threads_,
                        per_page=kbforums.THREADS_PER_PAGE)
    is_watching_locale = (request.user.is_authenticated() and
                          NewThreadInLocaleEvent.is_notifying(
                              request.user, locale=request.LANGUAGE_CODE))
    return render(request, 'kbforums/discussions.html', {
        'locale_name': locale_name, 'threads': threads_,
        'desc_toggle': desc_toggle,
        'is_watching_locale': is_watching_locale})