Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge extra fields #379

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions cmsplugin_cascade/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
15 changes: 15 additions & 0 deletions cmsplugin_cascade/extra_fields/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand Down
5 changes: 5 additions & 0 deletions docs/source/customize-styles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------

Expand Down
2 changes: 1 addition & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ pytest-django
tox
django-reversion
factory-boy
pytest-factoryboy
pytest-factoryboy
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ commands = rm -f .coverage
deps =
coverage==4.0.2
skipsdist = true
commands = coverage report
commands = coverage report