Beispiel #1
0
    def test_not_counting_outdated(self):
        """Out-of-date translations shouldn't count as "done".

        "Out-of-date" can mean either moderately or majorly out of date. The
        only thing we don't care about is typo-level outdatedness.

        """
        t = translated_revision(is_approved=True, save=True)
        overview = overview_rows('de')
        eq_(1, overview['most-visited']['numerator'])
        eq_(1, overview['all']['numerator'])

        # Update the parent with a typo-level revision:
        revision(document=t.document.parent,
                 significance=TYPO_SIGNIFICANCE,
                 is_approved=True,
                 is_ready_for_localization=True,
                 save=True)
        # Assert it still shows up in the numerators:
        overview = overview_rows('de')
        eq_(1, overview['most-visited']['numerator'])
        eq_(1, overview['all']['numerator'])

        # Update the parent with a medium-level revision:
        revision(document=t.document.parent,
                 significance=MEDIUM_SIGNIFICANCE,
                 is_approved=True,
                 is_ready_for_localization=True,
                 save=True)
        # Assert it no longer shows up in the numerators:
        overview = overview_rows('de')
        eq_(0, overview['all']['numerator'])
        eq_(0, overview['most-visited']['numerator'])
Beispiel #2
0
    def test_not_counting_outdated(self):
        """Out-of-date translations shouldn't count as "done".

        "Out-of-date" can mean either moderately or majorly out of date. The
        only thing we don't care about is typo-level outdatedness.

        """
        t = translated_revision(is_approved=True, save=True)
        overview = overview_rows('de')
        eq_(1, overview['most-visited']['numerator'])
        eq_(1, overview['all']['numerator'])

        # Update the parent with a typo-level revision:
        revision(document=t.document.parent,
                 significance=TYPO_SIGNIFICANCE,
                 is_approved=True,
                 is_ready_for_localization=True,
                 save=True)
        # Assert it still shows up in the numerators:
        overview = overview_rows('de')
        eq_(1, overview['most-visited']['numerator'])
        eq_(1, overview['all']['numerator'])

        # Update the parent with a medium-level revision:
        revision(document=t.document.parent,
                 significance=MEDIUM_SIGNIFICANCE,
                 is_approved=True,
                 is_ready_for_localization=True,
                 save=True)
        # Assert it no longer shows up in the numerators:
        overview = overview_rows('de')
        eq_(0, overview['all']['numerator'])
        eq_(0, overview['most-visited']['numerator'])
Beispiel #3
0
    def test_by_product(self):
        """Test the product filtering of the overview."""
        p = product(title="Firefox", slug="firefox", save=True)
        t = translated_revision(is_approved=True, save=True)

        eq_(0, overview_rows("de", product=p)["all"]["numerator"])
        eq_(0, overview_rows("de", product=p)["all"]["denominator"])

        t.document.parent.products.add(p)

        eq_(1, overview_rows("de", product=p)["all"]["numerator"])
        eq_(1, overview_rows("de", product=p)["all"]["denominator"])
Beispiel #4
0
    def test_by_product(self):
        """Test the product filtering of the overview."""
        p = product(title='Firefox', slug='firefox', save=True)
        t = translated_revision(is_approved=True, save=True)

        eq_(0, overview_rows('de', product=p)['all']['numerator'])
        eq_(0, overview_rows('de', product=p)['all']['denominator'])

        t.document.parent.products.add(p)

        eq_(1, overview_rows('de', product=p)['all']['numerator'])
        eq_(1, overview_rows('de', product=p)['all']['denominator'])
Beispiel #5
0
    def test_by_product(self):
        """Test the product filtering of the overview."""
        p = product(title='Firefox', slug='firefox', save=True)
        t = translated_revision(is_approved=True, save=True)

        eq_(0, overview_rows('de', product=p)['all']['numerator'])
        eq_(0, overview_rows('de', product=p)['all']['denominator'])

        t.document.parent.products.add(p)

        eq_(1, overview_rows('de', product=p)['all']['numerator'])
        eq_(1, overview_rows('de', product=p)['all']['denominator'])
Beispiel #6
0
    def test_all_articles_doesnt_have_30_40_50(self):
        """Make sure All Articles doesn't have 30, 40, and 50 articles"""
        t = translated_revision(is_approved=True, save=True)
        # It shows up in All when it's a normal doc:
        eq_(1, overview_rows('de')['all']['numerator'])
        eq_(1, overview_rows('de')['all']['denominator'])

        # ...but not when it's a navigation article:
        t.document.parent.title = t.document.title = 'thing'
        t.document.parent.category = t.document.category = 50
        t.document.parent.save()
        t.document.save()
        eq_(0, overview_rows('de')['all']['numerator'])
        eq_(0, overview_rows('de')['all']['denominator'])

        # ...or administration:
        t.document.parent.category = t.document.category = 40
        t.document.parent.save()
        t.document.save()
        eq_(0, overview_rows('de')['all']['numerator'])
        eq_(0, overview_rows('de')['all']['denominator'])

        # ...or how to contribute:
        t.document.parent.category = t.document.category = 30
        t.document.parent.save()
        t.document.save()
        eq_(0, overview_rows('de')['all']['numerator'])
        eq_(0, overview_rows('de')['all']['denominator'])
Beispiel #7
0
    def test_all_articles_doesnt_have_30_40_50(self):
        """Make sure All Articles doesn't have 30, 40, and 50 articles"""
        t = translated_revision(is_approved=True, save=True)
        # It shows up in All when it's a normal doc:
        eq_(1, overview_rows('de')['all']['numerator'])
        eq_(1, overview_rows('de')['all']['denominator'])

        # ...but not when it's a navigation article:
        t.document.parent.title = t.document.title = 'thing'
        t.document.parent.category = t.document.category = 50
        t.document.parent.save()
        t.document.save()
        eq_(0, overview_rows('de')['all']['numerator'])
        eq_(0, overview_rows('de')['all']['denominator'])

        # ...or administration:
        t.document.parent.category = t.document.category = 40
        t.document.parent.save()
        t.document.save()
        eq_(0, overview_rows('de')['all']['numerator'])
        eq_(0, overview_rows('de')['all']['denominator'])

        # ...or how to contribute:
        t.document.parent.category = t.document.category = 30
        t.document.parent.save()
        t.document.save()
        eq_(0, overview_rows('de')['all']['numerator'])
        eq_(0, overview_rows('de')['all']['denominator'])
Beispiel #8
0
    def test_templates_and_docs_disjunct(self):
        """Make sure templates aren't included in the All Articles count."""
        t = translated_revision(is_approved=True, save=True)
        # It shows up in All when it's a normal doc:
        eq_(1, overview_rows('de')['all']['numerator'])
        eq_(1, overview_rows('de')['all']['denominator'])

        t.document.parent.title = t.document.title = 'Template:thing'
        t.document.parent.is_template = t.document.is_template = True
        t.document.parent.save()
        t.document.save()
        # ...but not when it's a template:
        eq_(0, overview_rows('de')['all']['numerator'])
        eq_(0, overview_rows('de')['all']['denominator'])
Beispiel #9
0
    def test_templates_and_docs_disjunct(self):
        """Make sure templates aren't included in the All Articles count."""
        t = translated_revision(is_approved=True, save=True)
        # It shows up in All when it's a normal doc:
        eq_(1, overview_rows('de')['all']['numerator'])
        eq_(1, overview_rows('de')['all']['denominator'])

        t.document.parent.title = t.document.title = 'Template:thing'
        t.document.parent.is_template = t.document.is_template = True
        t.document.parent.save()
        t.document.save()
        # ...but not when it's a template:
        eq_(0, overview_rows('de')['all']['numerator'])
        eq_(0, overview_rows('de')['all']['denominator'])
Beispiel #10
0
    def test_counting_unready_navigation(self):
        """Navigation articles without ready-for-l10n rev don't count"""
        # Make a navigation doc with an approved but not-ready-for-l10n rev:
        r = revision(
            document=document(title="smoo", category=50, is_localizable=True, is_template=False, save=True),
            is_ready_for_localization=False,
            is_approved=True,
            save=True,
        )

        # It shouldn't show up in the total:
        eq_(0, overview_rows("de")["navigation"]["denominator"])

        r.is_ready_for_localization = True
        r.save()
        eq_(1, overview_rows("de")["navigation"]["denominator"])
Beispiel #11
0
    def test_counting_unready_templates(self):
        """Templates without a ready-for-l10n rev shouldn't count in total."""
        # Make a template with an approved but not-ready-for-l10n rev:
        r = revision(
            document=document(title="Template:smoo", is_localizable=True, is_template=True, save=True),
            is_ready_for_localization=False,
            is_approved=True,
            save=True,
        )

        # It shouldn't show up in the total:
        eq_(0, overview_rows("de")["templates"]["denominator"])

        r.is_ready_for_localization = True
        r.save()
        eq_(1, overview_rows("de")["templates"]["denominator"])
Beispiel #12
0
    def test_redirects_are_ignored(self):
        """Verify that redirects aren't counted in the overview."""
        t = translated_revision(is_approved=True, save=True)

        eq_(1, overview_rows("de")["all"]["numerator"])

        # A redirect shouldn't affect any of the tests.
        revision(
            document=document(title="A redirect", is_localizable=True, is_template=True, save=True),
            is_ready_for_localization=True,
            is_approved=True,
            content="REDIRECT [[An article]]",
            save=True,
        )

        eq_(1, overview_rows("de")["all"]["numerator"])
Beispiel #13
0
    def test_counting_unready_docs(self):
        """Docs without a ready-for-l10n rev shouldn't count in total."""
        # Make a doc with an approved but not-ready-for-l10n rev:
        r = revision(document=document(title='smoo',
                                       is_localizable=True,
                                       save=True),
                     is_ready_for_localization=False,
                     is_approved=True,
                     save=True)

        # It shouldn't show up in the total:
        eq_(0, overview_rows('de')['all']['denominator'])

        r.is_ready_for_localization = True
        r.save()
        eq_(1, overview_rows('de')['all']['denominator'])
Beispiel #14
0
 def test_not_counting_untranslated(self):
     """Translations with no approved revisions shouldn't count as done.
     """
     t = translated_revision(is_approved=False, save=True)
     overview = overview_rows("de")
     eq_(0, overview["most-visited"]["numerator"])
     eq_(0, overview["all"]["numerator"])
Beispiel #15
0
    def test_counting_unready_docs(self):
        """Docs without a ready-for-l10n rev shouldn't count in total."""
        # Make a doc with an approved but not-ready-for-l10n rev:
        r = revision(document=document(title='smoo',
                                       is_localizable=True,
                                       save=True),
                     is_ready_for_localization=False,
                     is_approved=True,
                     save=True)

        # It shouldn't show up in the total:
        eq_(0, overview_rows('de')['all']['denominator'])

        r.is_ready_for_localization = True
        r.save()
        eq_(1, overview_rows('de')['all']['denominator'])
Beispiel #16
0
    def test_redirects_are_ignored(self):
        """Verify that redirects aren't counted in the overview."""
        t = translated_revision(is_approved=True, save=True)

        eq_(1, overview_rows('de')['all']['numerator'])

        # A redirect shouldn't affect any of the tests.
        revision(document=document(title='A redirect',
                                   is_localizable=True,
                                   is_template=True,
                                   save=True),
                 is_ready_for_localization=True,
                 is_approved=True,
                 content='REDIRECT [[An article]]',
                 save=True)

        eq_(1, overview_rows('de')['all']['numerator'])
Beispiel #17
0
    def test_counting_unready_navigation(self):
        """Navigation articles without ready-for-l10n rev shouldn't count in
        total.

        """
        # Make a navigation doc with an approved but not-ready-for-l10n rev:
        r = revision(document=document(title='smoo',
                                       category=50,
                                       is_localizable=True,
                                       is_template=False,
                                       save=True),
                     is_ready_for_localization=False,
                     is_approved=True,
                     save=True)

        # It shouldn't show up in the total:
        eq_(0, overview_rows('de')['navigation']['denominator'])

        r.is_ready_for_localization = True
        r.save()
        eq_(1, overview_rows('de')['navigation']['denominator'])
Beispiel #18
0
    def test_counting_unready_parents(self):
        """Translations whose parents have no ready-to-localize revisions
        should not count in the numerator.

        By dint of factoring, this also tests that templates whose parents....

        """
        parent_rev = revision(
            document=document(is_localizable=True, save=True),
            is_approved=True,
            is_ready_for_localization=False,
            save=True,
        )
        translation = document(parent=parent_rev.document, locale="de", is_localizable=False, save=True)
        revision(document=translation, is_approved=True, based_on=parent_rev, save=True)
        eq_(0, overview_rows("de")["all"]["numerator"])
Beispiel #19
0
def localization(request):
    """Render aggregate data about articles in a non-default locale."""
    if request.locale == settings.WIKI_DEFAULT_LANGUAGE:
        return HttpResponseRedirect(reverse('dashboards.contributors'))
    locales = Locale.objects.filter(locale=request.locale)
    if locales:
        permission = user_can_announce(request.user, locales[0])
    else:
        permission = False

    data = {
      'overview_rows': overview_rows(request.locale),
      'user_can_announce': permission
    }
    return render_readouts(request, L10N_READOUTS, 'localization.html',
                           extra_data=data)
Beispiel #20
0
    def test_counting_unready_parents(self):
        """Translations whose parents have no ready-to-localize revisions
        should not count in the numerator.

        By dint of factoring, this also tests that templates whose parents....

        """
        parent_rev = revision(document=document(is_localizable=True,
                                                save=True),
                              is_approved=True,
                              is_ready_for_localization=False,
                              save=True)
        translation = document(parent=parent_rev.document,
                               locale='de',
                               is_localizable=False,
                               save=True)
        revision(document=translation,
                 is_approved=True,
                 based_on=parent_rev,
                 save=True)
        eq_(0, overview_rows('de')['all']['numerator'])
Beispiel #21
0
def localization(request):
    """Render aggregate data about articles in a non-default locale."""
    if request.LANGUAGE_CODE == settings.WIKI_DEFAULT_LANGUAGE:
        return HttpResponseRedirect(reverse('dashboards.contributors'))
    locales = Locale.objects.filter(locale=request.LANGUAGE_CODE)
    if locales:
        permission = user_can_announce(request.user, locales[0])
    else:
        permission = False

    product = _get_product(request)

    data = {
        'overview_rows': overview_rows(request.LANGUAGE_CODE, product=product),
        'user_can_announce': permission
    }
    return render_readouts(request,
                           L10N_READOUTS,
                           'localization.html',
                           extra_data=data,
                           product=product)
Beispiel #22
0
 def test_not_counting_untranslated(self):
     """Translations with no approved revisions shouldn't count as done."""
     t = translated_revision(is_approved=False, save=True)
     overview = overview_rows('de')
     eq_(0, overview['most-visited']['numerator'])
     eq_(0, overview['all']['numerator'])
Beispiel #23
0
 def test_not_counting_untranslated(self):
     """Translations with no approved revisions shouldn't count as done."""
     t = translated_revision(is_approved=False, save=True)
     overview = overview_rows('de')
     eq_(0, overview['most-visited']['numerator'])
     eq_(0, overview['all']['numerator'])