Repository: django-cms/django-cms

Issue:
language_fallback in placeholder conf can make plugins disappear (edit and live mode)
when having a placeholder with "language_fallback", no more plugins at all are shown in draft mode (neither in "edit" nor in "structure", and neither for plugins with no fallback). simply removing the fallback (as below) makes things work again. Then I found out, that I had not defined CMS_LANGUAGES and so following, no fallbacks in there...~~adding fallbacks in CMS_LANGUAGES solves the problem~~ EDIT: The problem is a tricky one, see comments.

placeholder conf

```
CMS_PLACEHOLDER_CONF = {
    'header_left': {
        'plugins': ['ImagePlugin', ],
        'extra_context': {"size": "698x520"},
        'name': ugettext("Headerbild"),
        #'language_fallback': True,
    },
    'header_right': {
        'plugins': ['ImagePlugin', ],
        'extra_context': {"size": "266x520"},
        'name': ugettext("Header Rechts"),
        #'language_fallback': True,
    },
    'content': {
        "plugins": ['MultiLineTitlePlugin','TextPlugin', 'AccordionPlugin'],
        'text_only_plugins': ["LinkPlugin",],
        "extra_context": {"width":280},
        'name': ugettext("Inhalt"),
    },
}
```

language conf

```
LANGUAGE_CODE = 'de'
LANGUAGES = (
    ('de', ugettext(u"Deutsch")),
    ('fr', ugettext(u"Francais")),
    ('en', ugettext(u"English")),
)
```



Discussion:
cms version?

sorry,. 3.0c2

not with the installer...first installed 3.0c1, 2 weeks ago. like this:

pip install -e  .....  3.0c1
cd`ed to src/ folder
git pull origin master
git checkout tags/3.0c2
and migrate


Resolving patch:
diff --git a/cms/utils/plugins.py b/cms/utils/plugins.py
--- a/cms/utils/plugins.py
+++ b/cms/utils/plugins.py
@@ -217,6 +217,8 @@ def assign_plugins(request, placeholders, template, lang=None, no_fallback=False
             if found:
                 continue
             elif placeholder and get_placeholder_conf("language_fallback", placeholder.slot, template, False):
+                if hasattr(request, 'toolbar') and request.toolbar.edit_mode:
+                    continue
                 fallbacks = get_fallback_languages(lang)
                 for fallback_language in fallbacks:
                     assign_plugins(request, [placeholder], template, fallback_language, no_fallback=True)


Test patch:
diff --git a/cms/tests/placeholder.py b/cms/tests/placeholder.py
--- a/cms/tests/placeholder.py
+++ b/cms/tests/placeholder.py
@@ -1,6 +1,8 @@
 # -*- coding: utf-8 -*-
 from __future__ import with_statement
 import itertools
+from cms.toolbar.toolbar import CMSToolbar
+from sekizai.context import SekizaiContext
 import warnings
 
 from django.conf import settings
@@ -348,7 +350,7 @@ def test_plugins_language_fallback(self):
         placeholder_de = title_de.page.placeholders.get(slot='col_left')
         add_plugin(placeholder_en, TextPlugin, 'en', body='en body')
 
-        class NoPushPopContext(Context):
+        class NoPushPopContext(SekizaiContext):
             def push(self):
                 pass
 
@@ -380,7 +382,16 @@ def push(self):
             cache.clear()
             content_de = render_placeholder(placeholder_de, context_de)
             self.assertRegexpMatches(content_de, "^en body$")
-
+            context_de2 = NoPushPopContext()
+            request = self.get_request(language="de", page=page_en)
+            request.user = self.get_superuser()
+            request.toolbar = CMSToolbar(request)
+            request.toolbar.edit_mode = True
+            context_de2['request'] = request
+            del(placeholder_de._plugins_cache)
+            cache.clear()
+            content_de2 = render_placeholder(placeholder_de, context_de2)
+            self.assertFalse("en body" in content_de2)
             # remove the cached plugins instances
             del(placeholder_de._plugins_cache)
             cache.clear()