mishbahr / djangocms-gmaps

The easiest way to embed Google Maps for your django-cms powered site. This is a great way to display the location of your business or event.
https://pypi.python.org/pypi/djangocms-gmaps/
BSD 3-Clause "New" or "Revised" License
22 stars 9 forks source link

Cannot edit Location plugin after adding it as a child plugin to map #8

Open heykarimoff opened 7 years ago

heykarimoff commented 7 years ago

Edit button is not being clicked. I add several Location plugins to Map however These child plugins cannot be modified in structure mode. screen shot 2016-11-06 at 13 16 33

heykarimoff commented 7 years ago

CMS._plugins.push(['cms-plugin-473', {"page_language": "en", "plugin_restriction": ["LocationPlugin"], "plugin_order": "", "placeholder_id": "48", "plugin_parent_restriction": [], "type": "plugin", "plugin_language": "en", "plugin_type": "MapPlugin", "onClose": false, "urls": {"add_plugin": "/admin/cms/page/add-plugin/", "copy_plugin": "/admin/cms/page/copy-plugins/", "edit_plugin": "/admin/cms/page/edit-plugin/473/", "delete_plugin": "/admin/cms/page/delete-plugin/473/", "move_plugin": "/admin/cms/page/move-plugin/"}, "addPluginHelpTitle": "Add plugin to Google Map", "plugin_name": "Google Map", "plugin_parent": "", "plugin_id": "473"}]); CMS._plugins.push(['cms-placeholder-48', {"page_language": "en", "plugin_restriction": ["MapPlugin", "AliasPlugin", "FormPlugin", "ProgramPlugin", "ResourcePlugin", "SocialPlugin", "TextPlugin", "TitleParagraphPlugin", "PlaceholderPlugin", "AliasPlugin"], "addPluginHelpTitle": "Add plugin to placeholder \"Map\"", "urls": {"add_plugin": "/admin/cms/page/add-plugin/", "copy_plugin": "/admin/cms/page/copy-plugins/"}, "placeholder_id": "48", "type": "placeholder", "name": "Map", "plugin_language": "en"}]);

I guess child plugin do not have edit url

mishbahr commented 7 years ago

Hey @MrBrownWins, what version of django/django-cms/python are you using?

Does this happen w/ other nested cms plugins? Can't think why this would happen..

Try https://github.com/divio/djangocms-googlemap ...see if its the same issue.

Have you modified the template?

heykarimoff commented 7 years ago

@mishbahr Thank you for quick response, I am using django==1.9.10/django-cms==3.4.1/python==3.5.1/. However I haven't check other cms plugins? I am still investigating. right now. I haven't modified or overridden the default template.

istals commented 7 years ago

I'm also having this issue: My project component versions is: Python - 2.7.12 Django - 1.8.17 Django-cms - 3.4.1 Djangocms-gmaps - 0.1.5.0

I tried djangocms-googlemap plugin and there is no issues with child plugins

lmanzurv commented 7 years ago

This happens because the LocationPlugin is set to render = False. It needs to be render = True and have a render_template, otherwise it is not editable from the edit mode

marcosguedes commented 7 years ago

@lmanzurv nice tip! I've overridden LocationPlugin temporarily to patch this issue

from cms.plugin_pool import plugin_pool
from djangocms_gmaps.cms_plugins import LocationPlugin as OriginalLocationPlugin

class LocationPlugin(OriginalLocationPlugin):
    render_plugin = True
    render_template = 'djangocms_gmaps/dummy_location_template.html'

plugin_pool.unregister_plugin(LocationPlugin)
plugin_pool.register_plugin(LocationPlugin)
marcosguedes commented 6 years ago

@lmanzurv I've created a pull request based on your solution. I hope @mishbahr can take a look at this soon and update it on PyPI

lmanzurv commented 6 years ago

@marcosguedes Awesome! Just to note, any plugin in Django CMS will have the same issue if set to render = False. So any time you need a plugin to be editable from the structure view, it has to have render = True and a template, even if it's just an empty html file 😉

marcosguedes commented 6 years ago

Yes, this was a valuable lesson for me. The only gripe I have is that creating an empty template to fix this seems a bit inelegant. I wonder if we can create one inside cms_plugins.py...

mishbahr commented 6 years ago

Have this issue been reported to @divio or is there a ticket on https://github.com/divio/django-cms/ for this issue?

marcosguedes commented 6 years ago

@mishbahr not to my knowledge. A brief search haven't turned up anything.

I'm reluctant to open one because this is subverting the underlying logic of nested plugins and I don't know the full consequences of editing an unrendered plugin.

I'll open one as soon as I can gather my thoughts on the subject.