Skip to content

Instantly share code, notes, and snippets.

View ojii's full-sized avatar

Jonas Obrist ojii

View GitHub Profile
# using https://pypi.python.org/pypi/codequality/0.2-dev
codequality --ignore=cms/migrations/* --ignore=cms/static/cms/js/libs/* --ignore=cms/static/cms/js/jstree/* --ignore=cms/static/cms/js/plugins/jquery.ui.custom.js --ignore=cms/static/cms/js/plugins/jquery.ui.nestedsortable.js cms

Keybase proof

I hereby claim:

  • I am ojii on github.
  • I am ojii (https://keybase.io/ojii) on keybase.
  • I have a public key whose fingerprint is 8DBD 52C5 761A EF34 D7C4 B2C0 F8E8 E2D9 DAF3 CFFD

To claim this, I am signing this object:

@ojii
ojii / last_page_on_path.py
Created May 2, 2014 08:04
last page on path
def last_page_on_path(path):
"""
Given a path (eg /a/b/c/d/e/), find the "last" page on that path.
If we have a CMS tree of:
|-a
| |-b
| | |-c
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCrV6ltrDFKmGdgc1H8vKZTHuBO7H4cpQJleNuTvfG1I1hFD54EnkJbA1O5zzNmGVEOzlF2E/+mCQYm12MFtEf8HTomU7XivSWv207pxi8jR2JteGmKLkx2xN4MbSXjo48WLUXu9GcWaLbVeC4UBPY4R1ThEk9LQEIU79BwqsMtAP306tQhsGf1mZTeCuy53687o20Rdw5UxS4jgya+YQUaRKsFP9RTGORb/fX/AUVbEbe+SEQ8wxsKpn2bnvWSmc1KN3ShuB4J1sDO5QdsVYAoCv9hwwq9/jti5t2XfuNY53/xNvCCougGp5jL74wzVyi3707fr9Gor06Q8rAaIvOF jonas@jonas-ubuntu
In [1]: from simplegallery import models as sg
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/Users/stefanfoulis/Documents/Coding/Workspaces/Main/affichage/<ipython console> in <module>()
/Users/stefanfoulis/Documents/Coding/Workspaces/Main/django-simplegallery/simplegallery/models.py in <module>()
6 from cms.models import Page
7 from cms.models import CMSPlugin
----> 8 from cms.models.fields import PageField
--- toolbar.html 2010-04-13 20:24:13.000000000 +0200
+++ toolbar_fix.html 2010-04-13 20:24:34.000000000 +0200
@@ -901,7 +901,7 @@
{% if auth %}
{% if has_change_permission %}<li><a href="{% url admin:cms_page_change page.pk %}"><span class="cms_toolbar_icon_padeadmin">Icon</span>{% trans "Page Settings" %}</a></li>
<!--li><a href="#"><span class="cms_toolbar_icon_pageunpublish">Icon</span>Unpublish Page</a></li-->
- <li><a href="{% url pages-root %}{% url admin:cms_page_history page.pk %}"><span class="cms_toolbar_icon_history">{% trans "history" %}</span>{% trans "View History" %}</a></li>
+ <li><a href="{% url admin:cms_page_history page.pk %}"><span class="cms_toolbar_icon_history">{% trans "history" %}</span>{% trans "View History" %}</a></li>
{% endif %}
{% endif %}
diff --git a/cms/models/pluginmodel.py b/cms/models/pluginmodel.py
index 5f4317f..5f5d4b5 100644
--- a/cms/models/pluginmodel.py
+++ b/cms/models/pluginmodel.py
@@ -237,6 +237,14 @@ class CMSPlugin(MpttPublisher):
Handle copying of any relations attached to this plugin
"""
+ def has_change_permission(self, request):
+ if self.page:
diff --git a/cms/admin/placeholderadmin.py b/cms/admin/placeholderadmin.py
index b589111..aa7d415 100644
--- a/cms/admin/placeholderadmin.py
+++ b/cms/admin/placeholderadmin.py
@@ -124,7 +124,7 @@ class PlaceholderAdmin(ModelAdmin):
raise Http404
parent = get_object_or_404(CMSPlugin, pk=parent_id)
plugin = CMSPlugin(language=language, plugin_type=plugin_type,
- position=position, parent=parent)
+ position=position, parent=parent, placeholder=parent.placeholder)
diff --git a/cms/tests/menu.py b/cms/tests/menu.py
index 3b7724b..76a5ee7 100644
--- a/cms/tests/menu.py
+++ b/cms/tests/menu.py
@@ -34,6 +34,11 @@ class MenusTestCase(CMSTestCase):
self.page3 = self.create_page(parent_page=self.page2, published=True, in_navigation=True)
self.page4 = self.create_page(parent_page=None, published=True, in_navigation=True)
self.page5 = self.create_page(parent_page=self.page4, published=True, in_navigation=True)
+ self.page6 = self.create_page(parent_page=None, published=True, in_navigation=False)
+ self.page7 = self.create_page(parent_page=self.page6, published=True, in_navigation=True)
class BaseView(object):
"""
A base class to create class based views.
It will automatically check allowed methods if a list of allowed methods are
given. It also automatically tries to route to 'handle_`method`' methods if
they're available. So if for example you define a 'handle_post' method and
the request method is 'POST', this one will be called instead of 'handle'.
"""