django-cms / djangocms-text

Text Plugin for django CMS
BSD 3-Clause "New" or "Revised" License
5 stars 3 forks source link

When installed_plugins is None causes an exception #12

Closed petergross closed 2 months ago

petergross commented 3 months ago

I'm trying to implement the djangocms_text package and have followed the instructions on the README.

However, it seems that it is expecting installed_plugins to be populated, however the calling Widget function doesn't pass any installed_plugins so it defaults to None.

Where this code runs (https://github.com/django-cms/djangocms-text/blob/ac822f98e64b7c3dbbd8c4f415150cfd40526f31/djangocms_text/widgets.py#L104C8-L104C46) it then causes an exception.

This happens when clicking on the Django CMS toolbar Create button only.

Suggest the following change:

def get_toolbar_setting(self, toolbar):
    toolbar_setting = get_editor_base_config()
    if self.installed_plugins is None:
        return toolbar_setting
    for plugin in self.installed_plugins:
        toolbar_setting[plugin["value"]] = {
            "title": plugin["name"],
            "icon": plugin["icon"],
        }
    return toolbar_setting
fsbraun commented 3 months ago

Fixed in version 0.1.3. Thanks for reporting this, @petergross !!