Repository: django-cms/django-cms

Issue:
"window.parent.CMS.API.Helpers.reloadBrowser();" not found
I'm using the tip of the develop branch, and having some problems when saving plugins:

When I save a plugin, it doesn't reload the plugin editor. It looks like it's bailing on this javascript:

"window.parent.CMS.API.Helpers.reloadBrowser()" 

The url causing the problem is formed like this:

/admin/cms/page/N/edit-plugin/Y/

From what I can tell, it's not loading any javascript files beyond jquery.min.js. 

The problem happens in both Firefox and Chrome. 



Discussion:

Resolving patch:
diff --git a/cms/models/placeholdermodel.py b/cms/models/placeholdermodel.py
--- a/cms/models/placeholdermodel.py
+++ b/cms/models/placeholdermodel.py
@@ -1,12 +1,13 @@
 # -*- coding: utf-8 -*-
-import operator
-
+from cms.utils.helpers import reversion_register
+from cms.utils.placeholder import PlaceholderNoAction
+from django.core.urlresolvers import reverse
 from django.db import models
 from django.forms.widgets import Media
 from django.utils.translation import ugettext_lazy as _
+import operator
+
 
-from cms.utils.helpers import reversion_register
-from cms.utils.placeholder import PlaceholderNoAction
 
 class Placeholder(models.Model):
     slot = models.CharField(_("slot"), max_length=50, db_index=True, editable=False)
@@ -17,6 +18,21 @@ class Meta:
 
     def __unicode__(self):
         return self.slot
+    
+    def get_add_url(self):
+        return self._get_url('add_plugin')
+    
+    def get_changelist_url(self):
+        return self._get_url('changelist')
+    
+    def _get_url(self, key):
+        model = self._get_attached_model()
+        if not model:
+            return reverse('admin:cms_page_%s' % key)
+        else:
+            app_label = model._meta.app_label
+            model_name = model.__name__.lower()
+            return reverse('admin:%s_%s_%s' % (app_label, model_name, key))
         
     def _get_permission(self, request, key):
         """


Test patch:
diff --git a/cms/tests/rendering.py b/cms/tests/rendering.py
--- a/cms/tests/rendering.py
+++ b/cms/tests/rendering.py
@@ -13,7 +13,7 @@
 from django.forms.widgets import Media
 from django.http import Http404, HttpResponseRedirect
 from django.template import Template, RequestContext
-from django.template.context import Context
+from sekizai.context import SekizaiContext
 
 TEMPLATE_NAME = 'tests/rendering/base.html'
 
@@ -283,20 +283,20 @@ def test_render_placeholder_toolbar(self):
         placeholder = Placeholder()
         placeholder.slot = 'test'
         placeholder.pk = placeholder.id = 99
-        context = Context()
+        context = SekizaiContext()
         context['request'] = AttributeObject(
-                REQUEST={'language': 'en'},
-                GET=[],
-                session={},
-                path='/',
-                user=self.test_user,
-                current_page=None,
-                method='GET',
-            )
+            REQUEST={'language': 'en'},
+            GET=[],
+            session={},
+            path='/',
+            user=self.test_user,
+            current_page=None,
+            method='GET',
+        )
         classes = [
-            "cms_placeholder::en::::99::",
+            "cms_placeholder-bar-%s" % placeholder.pk,
             "cms_placeholder_slot::test",
         ]
         output = render_placeholder_toolbar(placeholder, context, '', 'test')
         for cls in classes:
-            self.assertTrue(cls in output)
+            self.assertTrue(cls in output, '%r is not in %r' % (cls, output))
diff --git a/tests/project/placeholderapp/views.py b/tests/project/placeholderapp/views.py
new file mode 100644
--- /dev/null
+++ b/tests/project/placeholderapp/views.py
@@ -0,0 +1,9 @@
+from django.shortcuts import render_to_response
+from django.template.context import RequestContext
+from project.placeholderapp.models import Example1
+
+
+def example_view(request):
+    context = RequestContext(request)
+    context['examples'] = Example1.objects.all()
+    return render_to_response('placeholderapp.html', context)
diff --git a/tests/project/templates/base.html b/tests/project/templates/base.html
--- a/tests/project/templates/base.html
+++ b/tests/project/templates/base.html
@@ -8,6 +8,7 @@
 	<link href="{{ MEDIA_URL }}css/style.css" media="all" rel="stylesheet" type="text/css" />
 	<link href="{{ MEDIA_URL }}css/print.css" media="print"	rel="stylesheet" type="text/css" />
     {% render_block "css" %}
+	{% render_block "js" %}
 </head>
 <body id="{% block tpl_id %}none{% endblock %}" class="{{ LANGUAGE_CODE }}">
 {% cms_toolbar %}
@@ -38,6 +39,5 @@
 			  {% block content %}{% endblock content %}
 		</div>
 	</div>
-{% render_block "js" %}
 </body>
 </html> 
\ No newline at end of file
diff --git a/tests/project/templates/placeholderapp.html b/tests/project/templates/placeholderapp.html
new file mode 100644
--- /dev/null
+++ b/tests/project/templates/placeholderapp.html
@@ -0,0 +1,9 @@
+{% extends "base.html" %}
+{% load placeholder_tags %}
+{% block content %}
+{% for example in examples %}
+    <div>{% render_placeholder example.placeholder %}</div>
+{% empty %}
+    <div>No examples found</div>
+{% endfor %}
+{% endblock content %}
\ No newline at end of file
diff --git a/tests/project/urls.py b/tests/project/urls.py
--- a/tests/project/urls.py
+++ b/tests/project/urls.py
@@ -7,6 +7,7 @@
 
 urlpatterns = patterns('',
     url(r'^admin/', include(admin.site.urls)),
+    url(r'^example/$', 'project.placeholderapp.views.example_view'),
     url(r'^jsi18n/(?P<packages>\S+?)/$', 'django.views.i18n.javascript_catalog'),
     url(r'^media/cms/(?P<path>.*)$', 'django.views.static.serve',
         {'document_root': settings.CMS_MEDIA_ROOT, 'show_indexes': True}),