Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
fix bug 763307 - Remove templates and redirects from lists
Browse files Browse the repository at this point in the history
  • Loading branch information
darkwing committed Dec 21, 2012
1 parent 626f782 commit de71cd2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 3 additions & 1 deletion apps/wiki/models.py
Expand Up @@ -379,7 +379,9 @@ def allows_add_by(self, user, slug):

def filter_for_list(self, locale=None, category=None, tag=None,
tag_name=None):
docs = self.order_by('title')
docs = (self.filter(is_template=False, is_redirect=False).
exclude(slug__startswith='User:').
exclude(slug__startswith='Talk:').order_by('title'))
if locale:
docs = docs.filter(locale=locale)
if category:
Expand Down
17 changes: 15 additions & 2 deletions apps/wiki/tests/test_views.py
Expand Up @@ -2260,13 +2260,11 @@ def test_document_redirects(self):
invalidDocuments = (
{'title': 'Something Redirect 8', 'html': 'REDIRECT <a class="redirect" href="/blah">Something Redirect</a>', 'is_redirect': 1},
)

validDocuments = (
{'title': 'e 6', 'html': '<p>Blah text Redirect'},
{'title': 'e 7', 'html': 'AppleTalk'},
{'title': 'Response.Redirect'},
)

allDocuments = invalidDocuments + validDocuments

for doc in allDocuments:
Expand Down Expand Up @@ -2296,6 +2294,21 @@ def test_document_redirects(self):
break
eq_(True, found)

def test_list_no_redirects(self):
invalidDocuments = (
{'title': 'Something Redirect 8', 'slug': 'xx',
'html': 'REDIRECT <a class="redirect" href="http://davidwalsh.name">yo</a>'},
{'title': 'My Template', 'slug': 'Template:Something', 'html': 'blah'},
)
validDocuments = ({ 'title': 'A Doc', 'slug': 'blah', 'html': 'Blah blah blah'},)
allDocuments = invalidDocuments + validDocuments

for doc in allDocuments:
d = document(save=True, slug=doc['slug'], title=doc['title'], html=doc['html'])

resp = self.client.get(reverse('wiki.all_documents', locale='en-US'))
eq_(len(validDocuments), len(pq(resp.content).find('.documents li')))


class CodeSampleViewTests(TestCaseBase):
fixtures = ['test_users.json']
Expand Down

0 comments on commit de71cd2

Please sign in to comment.