Skip to content

Commit

Permalink
Merge 16d4cef into a000f0b
Browse files Browse the repository at this point in the history
  • Loading branch information
donce committed Aug 24, 2014
2 parents a000f0b + 16d4cef commit dd40501
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cms/management/commands/publisher_publish.py
Expand Up @@ -25,7 +25,7 @@ def publish_pages(self):

set_current_user(user) # set him as current user

qs = Page.objects.drafts().filter(title_set__published=True)
qs = Page.objects.drafts().filter(title_set__published=True).distinct()
pages_total, pages_published = qs.count(), 0

print(u"\nPublishing public drafts....\n")
Expand Down
32 changes: 32 additions & 0 deletions cms/tests/publisher.py
Expand Up @@ -158,6 +158,38 @@ def test_command_line_publishes_one_page(self):
non_draft = Page.objects.public()[0]
self.assertEqual(non_draft.reverse_id, 'a_test')

def test_command_line_publishes_multiple_languages(self):
"""
Publishing one page with multiple languages still counts
as one page. This test case checks whether it works
as expected.
"""
# we need to create a superuser (the db is empty)
get_user_model().objects.create_superuser('djangocms', 'cms@example.com', '123456')

# Now, let's create a page with 2 languages.
page = create_page("en title", "nav_playground.html", "en", published=True)
create_title("de", "de title", page)
page.publish("de")

pages_from_output = 0
published_from_output = 0

with StdoutOverride() as buffer:
# Now we don't expect it to raise, but we need to redirect IO
com = publisher_publish.Command()
com.handle_noargs()
lines = buffer.getvalue().split('\n') #NB: readlines() doesn't work

for line in lines:
if 'Total' in line:
pages_from_output = int(line.split(':')[1])
elif 'Published' in line:
published_from_output = int(line.split(':')[1])

self.assertEqual(pages_from_output, 1)
self.assertEqual(published_from_output, 1)

def tearDown(self):
plugin_pool.patched = False
plugin_pool.set_plugin_meta()
Expand Down

0 comments on commit dd40501

Please sign in to comment.