Major bug in 2.1.0 rc1 when using localized pages. #632

Closed
RuuPiE opened this Issue Dec 30, 2010 · 5 comments

Comments

Projects
None yet
2 participants

RuuPiE commented Dec 30, 2010

This bug is introduced since 2.1.0rc1 release. (2.1.0beta3 worked)

** Steps to repoduce (using example app) **

  • create new page
  • add text plugins for each language
  • publish the page

** Expected behavior: **

When viewing the published site we expect to see the localized text when switching language (en/fr/de)

** Actual behavior: **

All the translations are viewed on one single page. The other language pages don't show any text at all.

** Cause: **

cms/models/pagemodel.py:262

            if plugins:
                language = plugins[0].language
                copy_plugins_to(plugins, ph, language)

forces the copied plugin to have the language of the first plugin found, instead of using the src plugin's language.

** Fix: **
cms/models/pagemodel.py:262
if plugins:
copy_plugins_to(plugins, ph)

cms/utils/copy_plugins.py: *** fixed version! ***
def copy_plugins_to(plugin_list, to_placeholder, to_language = None):
"""
Copies a list of plugins to a placeholder to a language.
"""
ptree = []
plugins_ziplist = []
use_src_language = not to_language
for old_plugin in plugin_list:
if use_src_language: to_language = old_plugin.language
# do the simple copying
new_plugin = old_plugin.copy_plugin(to_placeholder, to_language, ptree)
plugins_ziplist.append((new_plugin, old_plugin))
# this magic is needed for advanced plugins like Text Plugins that can have
# nested plugins and need to update their content based on the new plugins.
for new_plugin, old_plugin in plugins_ziplist:
new_instance = new_plugin.get_plugin_instance()[0]
if new_instance:
new_instance.post_copy(old_plugin, plugins_ziplist)

The bug is fixed in my local git clone. Will try to commit it if possible. Since I don't have experience with git this will be my first 'push', so hopefully it will go well.

For all people using localized pages this will be a show-stopping bug, with no workaround possible except hardcoding in database or django-cms core.
Hopefully my bugfix will be included in rc2 ;)

Keep up doing the great work! Django-cms will be the no1 python cms soon ;)

Cheers

Ruben Alberda
Synpro Development

Collaborator

ojii commented Dec 30, 2010

Hi, if you get this fairly soon, could you please come on irc (#django-cms@irc.freenode.net) to discuss this (and so I can help you with git).

Jonas

RuuPiE commented Dec 30, 2010

I committed the changes locally but dont know how to push to github

Can anyone explain me how the contribute workflow works.. ? :)

RuuPiE commented Dec 30, 2010

Thanks Jonas,.. will try to fire up my ages old BitchX ;)

Collaborator

ojii commented Dec 30, 2010

Closed by b531698 (copy_plugin_to copying all plugins to a single language instead of the language of the src plugin)

Collaborator

ojii commented Dec 30, 2010

Okay I was able to reproduce this issue using a unittest.

Thanks a lot to report this very critical bug.

Also I would like to thank you for this absolutely brilliant bug report!

Too bad you didn't get your git to work out, so I applied the patch manually.

For the future:

  • Create a fork of the django-cms on github using the 'Fork' button.
  • Set up your local repository as described in your new fork
  • Commit the changes locally
  • Push to github (probably something like git push origin master)
  • Send a pull request

This issue was fixed in b531698

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment