Skip to content

Commit

Permalink
Consistency: For ControlPanelFormWrapper and ``@@configuration_re…
Browse files Browse the repository at this point in the history
…gistry``, construct the base url to the ``@@overview-controlpanel`` from the nearest site.
  • Loading branch information
thet committed Mar 11, 2016
1 parent 8747e4b commit de6c4c6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
5 changes: 2 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ Incompatibilities:

New:

- Let the ``ControlPanelFormWrapper`` construct the base url to the ``@@overview-controlpanel`` from the context URL instead the portal URL.
For the ``@@configuration_registry``, construct the base url to the ``@@overview-controlpanel`` from the nearest site.
This gives more flexibility when calling controlpanels on contexts with local registries while in standard Plone installations the controlpanel is still bound to the portal url.
- For ``ControlPanelFormWrapper`` and ``@@configuration_registry``, construct the base url to the ``@@overview-controlpanel`` from the nearest site.
This gives more flexibility when calling controlpanels on sub sites with local registries while in standard Plone installations the controlpanel is still bound to the portal url.
[thet]

Fixes:
Expand Down
8 changes: 4 additions & 4 deletions plone/app/registry/browser/controlpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.statusmessages.interfaces import IStatusMessage

from zope.component.hooks import getSite
from zope.i18nmessageid import MessageFactory

_ = MessageFactory('plone')


Expand Down Expand Up @@ -70,7 +72,7 @@ def handleCancel(self, action):
_(u"Changes canceled."),
"info")
self.request.response.redirect(u"{0}/{1}".format(
self.context.absolute_url(),
getSite().absolute_url(),
self.control_panel_view
))

Expand All @@ -83,6 +85,4 @@ class ControlPanelFormWrapper(layout.FormWrapper):

@property
def control_panel_url(self):
return u"{0}/@@overview-controlpanel".format(
self.context.absolute_url()
)
return u"{0}/@@overview-controlpanel".format(getSite().absolute_url())
4 changes: 1 addition & 3 deletions plone/app/registry/browser/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ class RecordsControlPanel(BrowserView):

@property
def control_panel_url(self):
return u"{0}/@@overview-controlpanel".format(
getSite().absolute_url()
)
return u"{0}/@@overview-controlpanel".format(getSite().absolute_url())

def __call__(self):
form = self.request.form
Expand Down
10 changes: 2 additions & 8 deletions plone/app/registry/tests/test_controlpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,10 @@ def test_registry_base_controlpanel__control_panel_url(self):
"""Test, if control_panel_url property of the base controlpanel returns
the correct url.
"""
# Mock context
context = type('Dummy', (object,), {})
context.absolute_url = types.MethodType(
lambda self: 'http://nohost/noportal/nocontext',
context
)
view = ControlPanelFormWrapper(context, None)
view = ControlPanelFormWrapper(None, None)
self.assertEqual(
view.control_panel_url,
u'http://nohost/noportal/nocontext/@@overview-controlpanel'
u'http://nohost/plone/@@overview-controlpanel'
)


Expand Down

0 comments on commit de6c4c6

Please sign in to comment.