internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: django-cms/django-cms

Issue:
Placeholder plugin should not be available in frontend
...or I'm missing something? :)



Discussion:

Resolving patch:
diff --git a/cms/cms_plugins.py b/cms/cms_plugins.py
--- a/cms/cms_plugins.py
+++ b/cms/cms_plugins.py
@@ -4,8 +4,8 @@
 from cms.plugin_pool import plugin_pool
 from django.utils.translation import ugettext_lazy as _
 
-class PlaceholderPlugin(CMSPluginBase):
 
+class PlaceholderPlugin(CMSPluginBase):
     name = _("Placeholder")
     parent_classes = [0]  # so you will not be able to add it something
     #require_parent = True
diff --git a/cms/utils/placeholder.py b/cms/utils/placeholder.py
--- a/cms/utils/placeholder.py
+++ b/cms/utils/placeholder.py
@@ -27,13 +27,15 @@ def get_toolbar_plugin_struct(plugins_list, slot, page, parent=None):
         template = page.template
     main_list = []
     for plugin in plugins_list:
+        allowed_parents = plugin().get_parent_classes(slot, page)
         if parent:
-            allowed_parents = plugin().get_parent_classes(slot, page)
             ## skip to the next if this plugin is not allowed to be a child
             ## of the parent
             if allowed_parents and parent.__name__ not in allowed_parents:
                 continue
-
+        else:
+            if allowed_parents:
+                continue
         modules = get_placeholder_conf("plugin_modules", slot, template, default={})
         names = get_placeholder_conf("plugin_labels", slot, template, default={})
         main_list.append({'value': plugin.value,


Test patch:
diff --git a/cms/tests/plugins.py b/cms/tests/plugins.py
--- a/cms/tests/plugins.py
+++ b/cms/tests/plugins.py
@@ -1008,6 +1008,13 @@ def test_plugin_parent_classes(self):
                                                     parent=KidnapperPlugin)
         self.assertFalse(expected_struct in toolbar_struct)
 
+        toolbar_struct = get_toolbar_plugin_struct([ParentClassesPlugin, GenericParentPlugin],
+                                                    placeholder.slot,
+                                                    page)
+        expected_struct = {'module': u'Generic',
+                            'name': u'Generic Parent Plugin',
+                            'value': 'GenericParentPlugin'}
+        self.assertTrue(expected_struct in toolbar_struct)
         for plugin in [ParentClassesPlugin, GenericParentPlugin, KidnapperPlugin]:
             plugin_pool.unregister_plugin(plugin)
Repository: django-cms/django-cms

Issue:
consider removing  &raquo;  from breadcrumb.html template
Testing bootstrap 3.0 with django-cms 3.0 beta and noticed that there is a hard-coded &raquo; separator in the templates/menu/breadcrumb.html file.  Wouldn't it be better if the default behavior left the separator style to css?

Thanks,
Brian

Previous fix for Django Debug Toolbar prevents proper operation in newer releases
Probably as a fix for #1757, CSS was added to place the Django Debug Toolbar into a specific place.

It seems that in newer versions of DDT allow the UI tab to be moved into whatever place makes sense for the user.  The fix in django-cms code base prevents that from working.

Solution:
Delete the line: https://github.com/divio/django-cms/blob/develop/cms/static/cms/sass/cms.base.scss#L53

Which reads:

``` scss
#djDebug #djDebugToolbarHandle { top:35px !important; border-right:none !important; }
```

And instead users should upgrade DDT to a newer release.

There is still the issue that DDT wants to also appear in the sideframe.  Which is annoying and possibly worse, but it is useable with the above change.



Discussion:

Resolving patch:
diff --git a/cms/templatetags/cms_admin.py b/cms/templatetags/cms_admin.py
--- a/cms/templatetags/cms_admin.py
+++ b/cms/templatetags/cms_admin.py
@@ -93,6 +93,16 @@ def render_tag(self, context, page, language):
 
 register.tag(TreePublishRow)
 
+@register.filter
+def is_published(page, language):
+    if page.is_published(language) and page.publisher_public_id and page.publisher_public.is_published(language):
+        return True
+    else:
+        if language in page.languages and page.publisher_public_id and page.publisher_public.get_publisher_state(
+                    language) == PUBLISHER_STATE_PENDING:
+            return True
+        return False
+
 
 class ShowLazyAdminMenu(InclusionTag):
     name = 'show_lazy_admin_menu'


Test patch:
Repository: django-cms/django-cms

Issue:
deleting a language after having the user language set to this language raises 500



Discussion:

Resolving patch:
diff --git a/cms/toolbar/toolbar.py b/cms/toolbar/toolbar.py
--- a/cms/toolbar/toolbar.py
+++ b/cms/toolbar/toolbar.py
@@ -62,7 +62,12 @@ def __init__(self, request):
                 placeholder.save()
                 user_settings.clipboard = placeholder
                 user_settings.save()
-            self.toolbar_language = user_settings.language
+            if (settings.USE_I18N and user_settings.language in dict(settings.LANGUAGES)) or (
+                    not settings.USE_I18N and user_settings.language == settings.LANGUAGE_CODE):
+                self.toolbar_language = user_settings.language
+            else:
+                user_settings.language = self.language
+                user_settings.save()
             self.clipboard = user_settings.clipboard
         with force_language(self.language):
             try:


Test patch:
diff --git a/cms/tests/toolbar.py b/cms/tests/toolbar.py
--- a/cms/tests/toolbar.py
+++ b/cms/tests/toolbar.py
@@ -1,4 +1,5 @@
 from __future__ import with_statement
+from cms.models import UserSettings
 import re
 from django.template.defaultfilters import truncatewords
 import datetime
@@ -263,6 +264,20 @@ def test_user_settings(self):
             response = self.client.get('/en/admin/cms/usersettings/')
             self.assertEqual(response.status_code, 200)
 
+    def test_remove_lang(self):
+        page = create_page('test', 'nav_playground.html', 'en', published=True)
+        superuser = self.get_superuser()
+        with self.login_user_context(superuser):
+            response = self.client.get('/en/?edit')
+            self.assertEqual(response.status_code, 200)
+            setting = UserSettings.objects.get(user=superuser)
+            setting.language = 'it'
+            setting.save()
+            with SettingsOverride(LANGUAGES=(('en', 'english'),)):
+                response = self.client.get('/en/?edit')
+                self.assertEqual(response.status_code, 200)
+                self.assertNotContains(response, '/it/')
+
     def test_get_alphabetical_insert_position(self):
         page = create_page("toolbar-page", "nav_playground.html", "en",
                            published=True)
Repository: django-cms/django-cms

Issue:
sometimes page placeholders are not created.



Discussion:

Resolving patch:
diff --git a/cms/models/pagemodel.py b/cms/models/pagemodel.py
--- a/cms/models/pagemodel.py
+++ b/cms/models/pagemodel.py
@@ -318,6 +318,7 @@ def copy_page(self, target, site, position='first-child',
             page.lft = None
             page.tree_id = None
             page.publisher_public_id = None
+            page.is_home = False
             # only set reverse_id on standard copy
             if page.reverse_id in site_reverse_ids:
                 page.reverse_id = None
@@ -579,10 +580,12 @@ def publish(self, language):
             if page.publisher_public:
                 if page.publisher_public.parent.is_published(language):
                     from cms.models import Title
-
-                    public_title = Title.objects.get(page=page.publisher_public, language=language)
+                    try:
+                        public_title = Title.objects.get(page=page.publisher_public, language=language)
+                    except Title.DoesNotExist:
+                        public_title = None
                     draft_title = Title.objects.get(page=page, language=language)
-                    if not public_title.published:
+                    if public_title and not public_title.published:
                         public_title._publisher_keep_state = True
                         public_title.published = True
                         public_title.publisher_state = PUBLISHER_STATE_DEFAULT


Test patch:
Repository: django-cms/django-cms

Issue:
If you have a page but no title you can not publish the page. Should check if there is a title and if not display a message



Discussion:

Resolving patch:
diff --git a/cms/cms_toolbar.py b/cms/cms_toolbar.py
--- a/cms/cms_toolbar.py
+++ b/cms/cms_toolbar.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 from cms.api import get_page_draft
-from cms.constants import TEMPLATE_INHERITANCE_MAGIC
+from cms.constants import TEMPLATE_INHERITANCE_MAGIC, RIGHT
 from cms.exceptions import LanguageError
 from cms.models import Title
 from cms.toolbar.items import TemplateItem
@@ -101,7 +101,7 @@ def add_admin_menu(self):
             for site in sites_queryset:
                 sites_menu.add_link_item(site.name, url='http://%s' % site.domain,
                                          active=site.pk == self.current_site.pk)
-            # admin
+                # admin
         admin_menu.add_sideframe_item(_('Administration'), url=reverse('admin:index'))
         admin_menu.add_break(ADMINISTRATION_BREAK)
         # cms users
@@ -140,7 +140,7 @@ def populate(self):
             self.change_admin_menu()
             if self.page:
                 self.add_page_menu()
-            # history menu
+                # history menu
         if self.page and self.toolbar.edit_mode:
             self.add_history_menu()
             self.change_language_menu()
@@ -330,6 +330,14 @@ def add_page_menu(self):
         current_page_menu.add_modal_item(_('Delete page'), url=delete_url, close_on_url=self.toolbar.URL_CHANGE,
                                          on_close=on_delete_redirect_url, disabled=not_edit_mode)
 
+        if not self.title:
+            self.toolbar.add_button(
+                _("Page settings"),
+                "%s?language=%s" % (reverse('admin:cms_page_change', args=[self.page.pk]), self.toolbar.language),
+                side=self.toolbar.RIGHT,
+                extra_classes=["cms_btn-action"],
+            )
+
     def add_history_menu(self):
         # history menu
         history_menu = self.toolbar.get_or_create_menu('history', _('History'), position=2)


Test patch:
Repository: django-cms/django-cms

Issue:
'WSGIRequest' object has no attribute 'user'
404's will throw this error:

Internal Server Error: /xxx
Traceback (most recent call last):
  File "/virtualenvs/xxx/lib/python2.7/site-packages/django/core/handlers/base.py", line 201, in get_response
    response = middleware_method(request, response)
  File "/virtualenvs/xxx/src/django-cms/cms/middleware/toolbar.py", line 88, in process_response
    if request.user.is_staff:
AttributeError: 'WSGIRequest' object has no attribute 'user'

'WSGIRequest' object has no attribute 'user'
404's will throw this error:

Internal Server Error: /xxx
Traceback (most recent call last):
  File "/virtualenvs/xxx/lib/python2.7/site-packages/django/core/handlers/base.py", line 201, in get_response
    response = middleware_method(request, response)
  File "/virtualenvs/xxx/src/django-cms/cms/middleware/toolbar.py", line 88, in process_response
    if request.user.is_staff:
AttributeError: 'WSGIRequest' object has no attribute 'user'



Discussion:
I can not reproduce this error.... why is there no user object on the request?

I can not reproduce this error.... why is there no user object on the request?


Resolving patch:
diff --git a/cms/middleware/toolbar.py b/cms/middleware/toolbar.py
--- a/cms/middleware/toolbar.py
+++ b/cms/middleware/toolbar.py
@@ -85,7 +85,7 @@ def process_response(self, request, response):
                 break
         if found:
             add_never_cache_headers(response)
-        if request.user.is_staff:
+        if hasattr(request, 'user') and request.user.is_staff:
             count = LogEntry.objects.filter(user=request.user).count()
             if request.session.get('cms_log_entries', 0) < count:
                 request.session['cms_log_entries'] = count


Test patch:
Repository: django-cms/django-cms

Issue:
django-cms page not found exception blocks route display
If you have django-cms serving on the root path (after a number of other higher priority routes), and there is no page, then a 404 will just say PageNotFound.

It would be helpful if django-cms, when in DEBUG mode, retrieved django's list of routes and displayed them on this 404 page.



Discussion:
that would be awesome

The template and the logic that applies is the one from Django (in django/views/debug.py). This should thus be considered as a Djando-CMS feature to override the default 404 handler of Django.

BTW, browsing to http://localhost:8000/anything/that/does/not/exits makes a 500 status and error page when not in debug mode but this should be another issue I'll file somewhere else.

Otherwise I could provide a 404 page that shows the urls.py in DEBUG mode as suggested, from a Django-CMS rule as indicated at http://ilian.i-n-i.org/custom-404-not-found-page-with-django-cms/ and PR my solution.

At this point I notice that going to http://localhost:8000/nothing-at-this-path has not the same behaviour in Django CMS and in a plain Django app.

When settings.DEBUG, the page is provided by the view django.views.debug.technical_404_response. This function takes "request" and "exception" parameters.

When called within a plain stupid Django project the "exception" parameter is a django.core.urlresolvers.Resolver404 exception that carries all attributes from which rich debug information are printed out. These information are gathered into the exception object in a loop in a django.core.urlresolvers.RegexURLPattern.resolve method.

When called witin a django-cms this same django.views.debug.technical_404_response view "exception" parameter is a django.http.response.Http404 exception that does not carry those attributes - more particularly exception.args[0].['tried'] - that explains the tried URL patterns.

And for a curious reason, if the 404 URL contains in the path some non ASCII characters. It works as expected, means that the full list of patterns is displayed in the 404 page.


Resolving patch:
diff --git a/cms/views.py b/cms/views.py
--- a/cms/views.py
+++ b/cms/views.py
@@ -20,14 +20,23 @@
 from django.template.context import RequestContext
 from django.utils.http import urlquote
 from django.utils.timezone import get_current_timezone_name
+from django.utils.translation import get_language
 
 
 CMS_PAGE_CACHE_VERSION_KEY = 'CMS_PAGE_CACHE_VERSION'
 
+
 def _handle_no_page(request, slug):
     if not slug and settings.DEBUG:
         return TemplateResponse(request, "cms/welcome.html", RequestContext(request))
-    raise Http404('CMS: Page not found for "%s"' % slug)
+    try:
+        #add a $ to the end of the url (does not match on the cms anymore)
+        resolve('%s$' % request.path)
+    except Resolver404 as e:
+        # raise a django http 404 page
+        exc = Http404(dict(path=request.path, tried=e.args[0]['tried']))
+        raise exc
+    raise Http404('CMS Page not found: %s' % request.path)
 
 
 def details(request, slug):


Test patch:
Repository: django-cms/django-cms

Issue:
LanguageCookieMiddleware
cms.middleware.language.LanguageCookieMiddleware raises unicode/decode error on russian versions of chrome & chromium, firefox etc.



Discussion:
@werevolff could you post the whole traceback?

I just attempted (unsuccessfully) to reproduce this using Cyrillic-localised versions of Firefox and Chrome using a recent build of dcms (3.0beta) and a project with languages EN and BG.  Everything worked as expected.

In order to investigate further, it would be useful to know which version of django-cms and, as digi604 requested, a full traceback.

@werevolff can you help?

@mkoistinen did you experience the same issue?

No, I was just looking to see if this was something I could fix, since its labeled "blocker". I routinely work with Cyrillic, i18n projects, so, I thought I'd be well-suited to fix this, or at least troubleshoot. Unfortunately, I can't reproduce it.

I suspect this was something in 2.4.x or earlier, so, IMHO, without further information, I'd say we could remove the "blocker" label on this for a 3.0 release.

Strange. I turned over and there is no error. Sorry.

will close this ticket for now

same issue here with german umlaut in monthname of march, Cookie.py (python 2.6) cannot handle the expires-string 'Di, 03-M\xc3\xa4r-2015 15:32:07 GMT'
traceback:
File "<HIDDEN_VIRTUALENV_PROJECT_PATH>/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 213, in **call**
response_headers.append((str('Set-Cookie'), str(c.output(header=''))))
File "/usr/lib/python2.6/Cookie.py", line 464, in output
return "%s %s" % ( header, self.OutputString(attrs) )
File "/usr/lib/python2.6/Cookie.py", line 512, in OutputString
return _semispacejoin(result)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 16: ordinal not in range(128)

ahhh i think i know what the problem is


Resolving patch:
diff --git a/cms/middleware/language.py b/cms/middleware/language.py
--- a/cms/middleware/language.py
+++ b/cms/middleware/language.py
@@ -12,7 +12,6 @@ def process_response(self, request, response):
                         request.COOKIES[settings.LANGUAGE_COOKIE_NAME] == language:
             return response
         max_age = 365 * 24 * 60 * 60  # 10 years
-        expires = datetime.datetime.strftime(datetime.datetime.utcnow() + datetime.timedelta(seconds=max_age),
-                                             "%a, %d-%b-%Y %H:%M:%S GMT")
-        response.set_cookie(settings.LANGUAGE_COOKIE_NAME, language, expires=expires, max_age=max_age)
+        expires = datetime.datetime.utcnow() + datetime.timedelta(seconds=max_age)
+        response.set_cookie(settings.LANGUAGE_COOKIE_NAME, language, expires=expires)
         return response


Test patch:
Repository: django-cms/django-cms

Issue:
creating new pages gives 404
only if done in live modus over toolbar



Discussion:

Resolving patch:
diff --git a/cms/cms_toolbar.py b/cms/cms_toolbar.py
--- a/cms/cms_toolbar.py
+++ b/cms/cms_toolbar.py
@@ -133,7 +133,7 @@ def add_admin_menu(self):
         redirect_url = '/'
         if (page and
             (not page.is_published(self.current_lang) or page.login_required
-            or not page.has_view_permission(self.request, AnonymousUser()))):
+                or not page.has_view_permission(self.request, AnonymousUser()))):
             admin_menu.add_ajax_item(_('Logout'), action=reverse('admin:logout'),
                                      active=True, on_success=redirect_url)
         else:
@@ -292,14 +292,14 @@ def add_page_menu(self):
         add_page_menu = current_page_menu.get_or_create_menu('add_page', _("Add Page"))
         add_page_menu.add_sideframe_item(
             _("New Page"),
-            url="%s?language=%s" % (
+            url="%s?language=%s&edit=1" % (
                 reverse("admin:cms_page_add"),
                 self.toolbar.language
             )
         )
         add_page_menu.add_sideframe_item(
             _("New Sub Page"),
-            url="%s?target=%s&position=last-child&language=%s" % (
+            url="%s?target=%s&position=last-child&language=%s&edit=1" % (
                 reverse("admin:cms_page_add"),
                 self.page.pk,
                 self.toolbar.language,


Test patch:
Repository: django-cms/django-cms

Issue:
Template wrong after creating page type
Should be fullwidth in this example: http://cl.ly/image/0a0r241L192b



Discussion:

Resolving patch:
diff --git a/cms/admin/pageadmin.py b/cms/admin/pageadmin.py
--- a/cms/admin/pageadmin.py
+++ b/cms/admin/pageadmin.py
@@ -220,12 +220,8 @@ def save_model(self, request, obj, form, change):
             if not copy_target.has_view_permission(request):
                 raise PermissionDenied()
             obj = Page.objects.get(pk=obj.pk) #mptt reload
-            if not 'add_page_type' in request.GET:
-                site_id = obj.site_id
-                copy_target._copy_attributes(obj)
-                obj.site_id = site_id
-                obj.reverse_id = None
-                obj.save()
+            copy_target._copy_attributes(obj, clean=True)
+            obj.save()
             for lang in copy_target.languages.split(','):
                 copy_target._copy_contents(obj, lang)
         if not 'permission' in request.path:
@@ -236,6 +232,7 @@ def save_model(self, request, obj, form, change):
                 form,
                 language,
             )
+        # is it home? publish it right away
         if new and Page.objects.filter(site_id=obj.site_id).count() == 1:
             obj.publish(language)
 
diff --git a/cms/models/pagemodel.py b/cms/models/pagemodel.py
--- a/cms/models/pagemodel.py
+++ b/cms/models/pagemodel.py
@@ -257,19 +257,20 @@ def _copy_contents(self, target, language):
             if plugins:
                 copy_plugins_to(plugins, ph)
 
-    def _copy_attributes(self, target):
+    def _copy_attributes(self, target, clean=False):
         """
         Copy all page data to the target. This excludes parent and other values
         that are specific to an exact instance.
         :param target: The Page to copy the attributes to
         """
-        target.publication_date = self.publication_date
-        target.publication_end_date = self.publication_end_date
-        target.in_navigation = self.in_navigation
+        if not clean:
+            target.publication_date = self.publication_date
+            target.publication_end_date = self.publication_end_date
+            target.reverse_id = self.reverse_id
         target.login_required = self.login_required
-        target.limit_visibility_in_menu = self.limit_visibility_in_menu
+        target.in_navigation = self.in_navigation
         target.soft_root = self.soft_root
-        target.reverse_id = self.reverse_id
+        target.limit_visibility_in_menu = self.limit_visibility_in_menu
         target.navigation_extenders = self.navigation_extenders
         target.application_urls = self.application_urls
         target.application_namespace = self.application_namespace


Test patch:
Repository: django-cms/django-cms

Issue:
toolbar add page on same level



Discussion:

Resolving patch:
diff --git a/cms/cms_toolbar.py b/cms/cms_toolbar.py
--- a/cms/cms_toolbar.py
+++ b/cms/cms_toolbar.py
@@ -294,9 +294,10 @@ def add_page_menu(self):
         add_page_menu = current_page_menu.get_or_create_menu('add_page', _("Add Page"))
         add_page_menu.add_sideframe_item(
             _("New Page"),
-            url="%s?language=%s&edit=1" % (
+            url="%s?language=%s&edit=1&target=%s&position=last-child" % (
                 reverse("admin:cms_page_add"),
-                self.toolbar.language
+                self.toolbar.language,
+                self.page.parent_id or ''
             )
         )
         add_page_menu.add_sideframe_item(


Test patch: