Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #1555 and #1620: Page path rewriting when published page becomes the HOME page #1647

Merged
merged 6 commits into from
Apr 7, 2013

Conversation

kux
Copy link
Contributor

@kux kux commented Mar 6, 2013

Fix for #1555 and #1620 on the 2.3.x branch

  • when CMS_MODERATOR = True:
    if the draft page is unpublished, the public version is also unpublished
  • when determining the home page, ignore publication_date and publication_end_date
    this ensures that the home page path rewriting logic happens even if the page will only become available
    somewhere in the future
  • change the post_save_page signal handler so that it also updates the:
    ** paths(titles) of the currently saved page
    ** if the currently saved page becomes the new home page, then update the paths(titles) of the previous home page
    ** if the currently saved page used to be the home page, then update the paths(titles) of the new home page
  • add pre/post delete signal handlers that: if the currently deleted page was the home page
    then update the path of the new home page
  • Added unit tests for all the above functionality

This ensures that:

  • we will always have AT MOST one page with the '' (empty) path
  • the generated paths are consistent regardless of the publishing method used (tick the publish/unpublish checkbox in the page hierarchy, tick the 'is published' checkbox from the 'change page' view OR click 'publish' while doing frontend editing)

kux added 2 commits March 6, 2013 14:59
…g when published page becomes the HOME page

* when CMS_MODERATOR = True:
  if the draft page is unpublished, the public version is also unpublished
* when determining the home page, ignore publication_date and publication_end_date
  this ensures that the home page path rewriting logic happens even if the page will only become available
     somewhere in the future
* change the post_save_page signal handler so that it also updates the:
  ** paths(titles) of the currently saved page
  ** if the currently saved page becomes the new home page, then update the paths(titles) of the previous home page
  ** if the currently saved page used to be the home page, then update the paths(titles) of the new home page
* add pre/post delete signal handlers that: if the currently deleted page was the home page
  then update the path of the new home page
* Added unit tests for all the above functionality

This ensures that:
* we will always have AT MOST one page with the '' (empty) path
* no matter what publishing method is used (tick the publish/unpublish checkbox in the page hierarchy,
    tick the 'is published' checkbox from the 'change page' view OR click 'publish' while doing frontend editing)
    the generated paths are consistent
@kux
Copy link
Contributor Author

kux commented Mar 6, 2013

I will also try to provide a fix for these two bugs on the develop branch. However, since the publishing functionality changed quite a lot, the fix might need to be slightly different.

else:
if home_page.pk == instance.pk:
for title in Title.objects.filter(path=''):
if title not in instance.title_set.all():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not 100% sure, but doesn't this execute the query n times (n being the amount of titles with path='')?

Same goes for below. I think you should explicitly execute the instance.title_set.all() query by casting it to a list just after the if statement above.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 22faaa1 on pbs:issue_1555 into * on divio:support/2.3.x*.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants