diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e0e2ff9..2046952 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -22,6 +22,7 @@ Version 1.5.2 - Unreleased * Added more explicit error messages for invalid items in Feature import form; * Made some minor improvements on Feature admin; * Updated PO and MO files for last Feature changes; +* Enabled "todo" extension module in documentation; Version 1.5.1 - 2024/09/30 diff --git a/cmsplugin_blocks/forms/feature.py b/cmsplugin_blocks/forms/feature.py index 6a54ee0..e50997e 100644 --- a/cmsplugin_blocks/forms/feature.py +++ b/cmsplugin_blocks/forms/feature.py @@ -59,7 +59,8 @@ def clean_json_file(self): """ Open file to validate it as JSON and return its content. - NOTE: This could have been done more robustly with Python library "schema". + .. Todo:: + This could have been done more robustly with Python library "schema". """ data = self.cleaned_data["json_file"] @@ -87,41 +88,52 @@ def clean_json_file(self): if not isinstance(payload["items"], list): raise ValidationError(_("Item 'items' must be a list")) + # Build registry of existing titles + existing_titles = {k: [] for k, v in Feature.SCOPE_CHOICES} + # Check for some errors from items error_lines = [] - existing_titles = {k: [] for k, v in Feature.SCOPE_CHOICES} for i, feature in enumerate(payload["items"], start=1): # Get missing field or empty values from loaded items if ( not feature.get("title", "") or not feature.get("value", "") or not feature.get("scope", "") or not feature.get("plugins", "") ): - error_lines.append(_("#{} is missing one or more required items").format(i)) + msg = _("#{} is missing one or more required items") + error_lines.append(msg.format(i)) + # Check we have a knowed scope elif feature["scope"] not in [k for k, v in Feature.SCOPE_CHOICES]: - error_lines.append(_("#{} define a scope choice that is not enabled").format(i)) + msg = _("#{} define a scope choice that is not enabled") + error_lines.append(msg.format(i)) + # Check we have only well known plugin names elif len([ item for item in feature["plugins"] if item not in settings.BLOCKS_KNOWED_FEATURES_PLUGINS ]) > 0: - error_lines.append(_("#{} define a plugin name that is not enabled").format(i)) + msg = _("#{} define a plugin name that is not enabled") + error_lines.append(msg.format(i)) + # Check for duplicate title per scope elif feature["title"] in existing_titles[feature["scope"]]: - error_lines.append(_("#{} define a title that already exists").format(i)) + msg = _("#{} define a title that already exists") + error_lines.append(msg.format(i)) + # Almost everything seems ok, finally use value validator before # storing item else: try: validate_css_classname(feature["value"]) except ValidationError: - error_lines.append(_("#{} has invalid CSS classname(s)").format(i)) + msg = _("#{} has invalid CSS classname(s)") + error_lines.append(msg.format(i)) # Everything is ok, store title as an existing one for its scope else: existing_titles[feature["scope"]].append(feature["title"]) - # Raise error in case of any missing or empty items + # Raise error in case of any error messages if error_lines: raise ValidationError( [_("Some dump items are invalid:")] + error_lines diff --git a/docs/conf.py b/docs/conf.py index 1053145..763b58a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -51,6 +51,7 @@ "sphinx.ext.autodoc", "sphinx.ext.viewcode", "sphinx.ext.napoleon", + "sphinx.ext.todo", ] # Add any paths that contain templates here, relative to this directory. diff --git a/frozen.txt b/frozen.txt index 19e335e..a109639 100644 --- a/frozen.txt +++ b/frozen.txt @@ -1,4 +1,4 @@ -# Frozen requirement versions for 'cmsplugin-blocks==1.5.2rc1' installation +# Frozen requirement versions for 'cmsplugin-blocks==1.5.2rc2' installation django==5.0.9 django-cms==3.11.8 djangocms-text-ckeditor==5.1.6 diff --git a/setup.cfg b/setup.cfg index e930695..3d1cfd0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,7 +3,7 @@ ;; [metadata] name = cmsplugin-blocks -version = 1.5.2-pre.1 +version = 1.5.2-pre.2 description = A set of DjangoCMS plugins for structured contents in CMS pages long_description = file:README.rst long_description_content_type = text/x-rst