diff --git a/cmsplugin_cascade/app_settings.py b/cmsplugin_cascade/app_settings.py index 54464fca5..03b32b84b 100644 --- a/cmsplugin_cascade/app_settings.py +++ b/cmsplugin_cascade/app_settings.py @@ -121,6 +121,8 @@ def CMSPLUGIN_CASCADE(self): config.setdefault('allow_plugin_hiding', False) config.setdefault('cache_strides', True) + + config.setdefault('merge_extra_fields',True) config.setdefault('register_page_editor', True) diff --git a/cmsplugin_cascade/extra_fields/mixins.py b/cmsplugin_cascade/extra_fields/mixins.py index 973209d87..48b938f87 100644 --- a/cmsplugin_cascade/extra_fields/mixins.py +++ b/cmsplugin_cascade/extra_fields/mixins.py @@ -30,6 +30,21 @@ def get_form(self, request, obj=None, **kwargs): except ObjectDoesNotExist: extra_fields = app_settings.CMSPLUGIN_CASCADE['plugins_with_extra_fields'].get(clsname) + if hasattr(extra_fields, 'id') and app_settings.CMSPLUGIN_CASCADE['merge_extra_fields'] : + settings_extra_fields = app_settings.CMSPLUGIN_CASCADE['plugins_with_extra_fields'] + if clsname in settings_extra_fields.keys(): + for key_style, value_style in settings_extra_fields[clsname].inline_styles.items(): + extra_fields.inline_styles.update({key_style:extra_fields.inline_styles[key_style] + value_style}) + for key_css_classes, value_css_classes in settings_extra_fields[clsname].css_classes.items(): + if value_css_classes == '': + value_css_classes = extra_fields.css_classes[key_css_classes] + elif type(value_css_classes) == list: + list_extra_fields = extra_fields.css_classes[key_css_classes].replace(' ', '').split(",") + list_css_classes = list(dict.fromkeys(list_extra_fields + value_css_classes)) + value_css_classes = ','.join(list_css_classes) + extra_fields.css_classes.update({ key_css_classes:value_css_classes}) + extra_fields.save() + if isinstance(extra_fields, (PluginExtraFields, PluginExtraFieldsConfig)): form_fields = {} diff --git a/docs/source/customize-styles.rst b/docs/source/customize-styles.rst index 3495ea63e..2d01bcb71 100644 --- a/docs/source/customize-styles.rst +++ b/docs/source/customize-styles.rst @@ -110,6 +110,11 @@ styles shall be applied. .. |customize-styles| image:: /_static/customize-styles.png +If the plugin has the default configuration, for example: sets the upper, lower, upper, and lower margins. +The default settings above will be available in the plug-in editor because CMSPLUGIN_CASCADE variable. +**merge_extra_fields**: True are set in defaults. + + Allow ID -------- diff --git a/tests/requirements.txt b/tests/requirements.txt index 0504e95cd..8bec45c9a 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -7,4 +7,4 @@ pytest-django tox django-reversion factory-boy -pytest-factoryboy +pytest-factoryboy \ No newline at end of file diff --git a/tox.ini b/tox.ini index f88d5e6b5..6f51740e1 100644 --- a/tox.ini +++ b/tox.ini @@ -30,4 +30,4 @@ commands = rm -f .coverage deps = coverage==4.0.2 skipsdist = true -commands = coverage report +commands = coverage report \ No newline at end of file