Skip to content

Commit

Permalink
Squashed merge of quick/support-plugins-unadulterated-by-bootstrap--f…
Browse files Browse the repository at this point in the history
…or-main at commit eda34fa
  • Loading branch information
wesleyboar committed Jul 30, 2021
1 parent 265a800 commit 938db90
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
24 changes: 24 additions & 0 deletions taccsite_cms/contrib/bootstrap4_djangocms_link/cms_plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Reregister unregistered LinkPlugin without uninstalling Bootstrap4's
# FAQ: A Bootstrap link is undesirable but may be used by migrated legacy sites
# TODO: Drop try/except & load non-standard plugin set for migrated legacy sites
# FAQ: If we can import both plugins, then re-register LinkPlugin
# (because Bootstrap4Link unregistered LinkPlugin)
try:
from cms.plugin_pool import plugin_pool
from djangocms_link.cms_plugins import LinkPlugin
from djangocms_bootstrap4.contrib.bootstrap4_link.cms_plugins import Bootstrap4LinkPlugin

# Restore original fields
# SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/2.0.0/djangocms_bootstrap4/contrib/bootstrap4_link/cms_plugins.py#L26-L42
# SEE: https://github.com/django-cms/djangocms-link/blob/3.0.0/djangocms_link/cms_plugins.py#L20-L23
LinkPlugin.fieldsets[0][1]['fields'] = (
'name',
('external_link', 'internal_link'),
)

# SEE: https://github.com/django-cms/djangocms-link/issues/163
plugin_pool.register_plugin(LinkPlugin)
# CAVEAT: If import statement fails for reason other than Bootstrap presence,
# then that failure, and the failure of this plugin, is silent
except ImportError:
pass
15 changes: 15 additions & 0 deletions taccsite_cms/contrib/bootstrap4_djangocms_picture/cms_plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Reregister unregistered PicturePlugin without uninstalling Bootstrap4's
# FAQ: A Bootstrap picture has superfluous options that are not always desirable
# FAQ: If we can import both plugins, then re-register PicturePlugin
# (because Bootstrap4Picture unregistered PicturePlugin)
try:
from cms.plugin_pool import plugin_pool
from djangocms_picture.cms_plugins import PicturePlugin
from djangocms_bootstrap4.contrib.bootstrap4_picture.cms_plugins import Bootstrap4PicturePlugin

# SEE: https://github.com/django-cms/djangocms-bootstrap4/blob/master/djangocms_bootstrap4/contrib/bootstrap4_picture/cms_plugins.py#L54
plugin_pool.register_plugin(PicturePlugin)
# CAVEAT: If import statement fails for reason other than Bootstrap presence,
# then that failure, and the failure of this plugin, is silent
except ImportError:
pass
3 changes: 3 additions & 0 deletions taccsite_cms/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ def getsecrets():
# SEE: https://stackoverflow.com/a/37150997
'test_without_migrations',
'taccsite_cms',
# Restore djangocms plugins that bootstrap4 hides
'taccsite_cms.contrib.bootstrap4_djangocms_link',
'taccsite_cms.contrib.bootstrap4_djangocms_picture',
# TODO: Extract TACC CMS UI components into pip-installable plugins
# FAQ: The djangocms_bootstrap4 library can serve as an example
'taccsite_cms.contrib.taccsite_sample',
Expand Down

0 comments on commit 938db90

Please sign in to comment.