<commit_before>import json

from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.http import HttpResponse
from django.shortcuts import render
from django.views.decorators.http import require_GET

from jinja2 import escape
from waffle.decorators import waffle_flag

from sumo.urlresolvers import reverse

from users.helpers import ban_link

from wiki.models import Document, Revision
from wiki.helpers import format_comment

from . import (DEFAULT_LOCALE, LOCALES, ORDERS, TOPICS, LANGUAGES,
               LOCALIZATION_FLAGS, WAFFLE_FLAG, PAGE_SIZE)


@require_GET
@login_required
def fetch_localization_data(request):
    locale = request.GET.get('locale')
    topic = request.GET.get('topic')
    orderby = request.GET.get('orderby')
    localization_flags = request.GET.get('localization_flags')

    docs = Document.objects.exclude(locale=DEFAULT_LOCALE)

    if locale and locale in LANGUAGES:
        docs = docs.filter(locale=locale)

    if (localization_flags and
        localization_flags in LOCALIZATION_FLAGS):
        docs = docs.filter(current_revision__localization_tags__name=localization_flags)

    if topic and topic in TOPICS:
        docs = docs.filter(slug__icontains=topic)

    if orderby and orderby in ORDERS:
        docs = docs.order_by('-' + orderby)
    else:<commit_msg>Exclude redirect pages from l10n dashboard<commit_after>import json

from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.http import HttpResponse
from django.shortcuts import render
from django.views.decorators.http import require_GET

from jinja2 import escape
from waffle.decorators import waffle_flag

from sumo.urlresolvers import reverse

from users.helpers import ban_link

from wiki.models import Document, Revision
from wiki.helpers import format_comment

from . import (DEFAULT_LOCALE, LOCALES, ORDERS, TOPICS, LANGUAGES,
               LOCALIZATION_FLAGS, WAFFLE_FLAG, PAGE_SIZE)


@require_GET
@login_required
def fetch_localization_data(request):
    locale = request.GET.get('locale')
    topic = request.GET.get('topic')
    orderby = request.GET.get('orderby')
    localization_flags = request.GET.get('localization_flags')

    docs = Document.objects.exclude(locale=DEFAULT_LOCALE).exclude(is_redirect=True)

    if locale and locale in LANGUAGES:
        docs = docs.filter(locale=locale)

    if (localization_flags and
        localization_flags in LOCALIZATION_FLAGS):
        docs = docs.filter(current_revision__localization_tags__name=localization_flags)

    if topic and topic in TOPICS:
        docs = docs.filter(slug__icontains=topic)

    if orderby and orderby in ORDERS:
        docs = docs.order_by('-' + orderby)
    else:
{'fraction_non_alphanumeric': 0.07263574253865517, 'fraction_numerical': 0.001438331535418914, 'mean_word_length': 4.3810444874274665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3708775', 'n_tokens_mistral': 872, 'n_tokens_neox': 822, 'n_words': 214}