[bug 640805] Stop showing unlocalizable articles on Most Visited Translations readout.

This commit is contained in:
Erik Rose 2011-03-10 15:29:31 -08:00
Родитель 79798de1a4
Коммит 29495f071d
2 изменённых файлов: 24 добавлений и 5 удалений

Просмотреть файл

@ -248,7 +248,7 @@ class MostVisitedTranslationsReadout(MostVisitedDefaultLanguageReadout):
'LEFT JOIN dashboards_wikidocumentvisits ON engdoc.id='
'dashboards_wikidocumentvisits.document_id '
'AND dashboards_wikidocumentvisits.period=%s '
'WHERE engdoc.locale=%s '
'WHERE engdoc.locale=%s AND engdoc.is_localizable '
'ORDER BY dashboards_wikidocumentvisits.visits DESC, '
'COALESCE(transdoc.title, engdoc.title) ASC' +
self._limit_clause(max),

Просмотреть файл

@ -1,9 +1,12 @@
from datetime import datetime
from functools import partial
from dashboards.readouts import UnreviewedReadout
from nose.tools import eq_
from dashboards.readouts import (UnreviewedReadout,
MostVisitedTranslationsReadout)
from sumo.tests import TestCase
from wiki.tests import revision, translated_revision
from wiki.tests import revision, translated_revision, document
NON_DEFAULT_LOCALE = 'de'
@ -21,14 +24,13 @@ class UnreviewedChangesTests(TestCase):
bits.
"""
fixtures = ['users.json']
@staticmethod
def titles():
"""Return the titles shown by the Unreviewed Changes readout."""
return [row['title'] for row in
UnreviewedReadout(MockRequest()).rows()]
UnreviewedReadout(MockRequest()).rows()]
def test_unrevieweds_after_current(self):
"""Show the unreviewed revisions with later creation dates than the
@ -53,3 +55,20 @@ class UnreviewedChangesTests(TestCase):
rejected = translated_revision(reviewed=datetime.now())
rejected.save()
assert rejected.document.title not in self.titles()
class MostVisitedTranslationsTests(TestCase):
fixtures = ['users.json']
@staticmethod
def rows():
"""Return first row shown by the Most Visited Translations readout."""
return MostVisitedTranslationsReadout(MockRequest()).rows()
def test_unlocalizable(self):
"""Unlocalizable docs shouldn't show up in the list."""
revision(
document=document(is_localizable=False, save=True),
is_approved=True,
save=True)
eq_([], self.rows())