From 80a97258cb61fee555b754125fe4a765eedf727d Mon Sep 17 00:00:00 2001 From: Jordan Date: Wed, 21 Jun 2023 06:33:07 -0700 Subject: [PATCH 1/6] fix recent django import error. --- .../contrib/bootstrap4_grid/models.py | 115 +++++++++++------- 1 file changed, 69 insertions(+), 46 deletions(-) diff --git a/djangocms_bootstrap4/contrib/bootstrap4_grid/models.py b/djangocms_bootstrap4/contrib/bootstrap4_grid/models.py index 0d11993..8cf51a2 100644 --- a/djangocms_bootstrap4/contrib/bootstrap4_grid/models.py +++ b/djangocms_bootstrap4/contrib/bootstrap4_grid/models.py @@ -2,17 +2,29 @@ from django.db import models from django.utils.translation import gettext_lazy as _ -from django.utils.translation import ungettext + +try: + from django.utils.translation import ungettext +except ImportError as exc: + from django.utils.translation import ngettext as ungettext from cms.models import CMSPlugin from djangocms_bootstrap4.constants import DEVICE_SIZES from djangocms_bootstrap4.fields import AttributesField, IntegerRangeField, TagTypeField -from djangocms_bootstrap4.helpers import get_choices_match, get_first_choice, mark_safe_lazy +from djangocms_bootstrap4.helpers import ( + get_choices_match, + get_first_choice, + mark_safe_lazy, +) from .constants import ( - GRID_COLUMN_ALIGNMENT_CHOICES, GRID_COLUMN_CHOICES, GRID_CONTAINER_CHOICES, GRID_ROW_HORIZONTAL_ALIGNMENT_CHOICES, - GRID_ROW_VERTICAL_ALIGNMENT_CHOICES, GRID_SIZE, + GRID_COLUMN_ALIGNMENT_CHOICES, + GRID_COLUMN_CHOICES, + GRID_CONTAINER_CHOICES, + GRID_ROW_HORIZONTAL_ALIGNMENT_CHOICES, + GRID_ROW_VERTICAL_ALIGNMENT_CHOICES, + GRID_SIZE, ) @@ -21,15 +33,18 @@ class Bootstrap4GridContainer(CMSPlugin): Layout > Grid: "Container" Plugin https://getbootstrap.com/docs/4.0/layout/grid/ """ + container_type = models.CharField( - verbose_name=_('Container type'), + verbose_name=_("Container type"), choices=GRID_CONTAINER_CHOICES, default=get_first_choice(GRID_CONTAINER_CHOICES), max_length=255, - help_text=mark_safe_lazy(_( - 'Defines if the grid should use fixed width (.container) ' - 'or fluid width (.container-fluid).' - )), + help_text=mark_safe_lazy( + _( + "Defines if the grid should use fixed width (.container) " + "or fluid width (.container-fluid)." + ) + ), ) tag_type = TagTypeField() attributes = AttributesField() @@ -39,7 +54,7 @@ def __str__(self): def get_short_description(self): choice = get_choices_match(GRID_CONTAINER_CHOICES, self.container_type) - return f'({choice})' + return f"({choice})" class Bootstrap4GridRow(CMSPlugin): @@ -47,30 +62,37 @@ class Bootstrap4GridRow(CMSPlugin): Layout > Grid: "Row" Plugin https://getbootstrap.com/docs/4.0/layout/grid/ """ + vertical_alignment = models.CharField( - verbose_name=_('Vertical alignment'), + verbose_name=_("Vertical alignment"), choices=GRID_ROW_VERTICAL_ALIGNMENT_CHOICES, blank=True, max_length=255, - help_text=mark_safe_lazy(_( - 'Read more in the documentation.') - .format(link='https://getbootstrap.com/docs/4.0/layout/grid/#vertical-alignment') + help_text=mark_safe_lazy( + _( + 'Read more in the documentation.' + ).format( + link="https://getbootstrap.com/docs/4.0/layout/grid/#vertical-alignment" + ) ), ) horizontal_alignment = models.CharField( - verbose_name=_('Horizontal alignment'), + verbose_name=_("Horizontal alignment"), choices=GRID_ROW_HORIZONTAL_ALIGNMENT_CHOICES, blank=True, max_length=255, - help_text=mark_safe_lazy(_( - 'Read more in the documentation.') - .format(link='https://getbootstrap.com/docs/4.0/layout/grid/#horizontal-alignment') + help_text=mark_safe_lazy( + _( + 'Read more in the documentation.' + ).format( + link="https://getbootstrap.com/docs/4.0/layout/grid/#horizontal-alignment" + ) ), ) gutters = models.BooleanField( - verbose_name=_('Remove gutters'), + verbose_name=_("Remove gutters"), default=False, - help_text=_('Removes the marginal gutters from the grid.'), + help_text=_("Removes the marginal gutters from the grid."), ) tag_type = TagTypeField() attributes = AttributesField() @@ -81,10 +103,8 @@ def __str__(self): def get_short_description(self): column_count = len(self.child_plugin_instances or []) column_count_str = ungettext( - '(1 column)', - '(%(count)i columns)', - column_count - ) % {'count': column_count} + "(1 column)", "(%(count)i columns)", column_count + ) % {"count": column_count} return column_count_str @@ -94,15 +114,16 @@ class Bootstrap4GridColumn(CMSPlugin): Layout > Grid: "Column" Plugin https://getbootstrap.com/docs/4.0/layout/grid/ """ + column_type = models.CharField( - verbose_name=_('Column type'), + verbose_name=_("Column type"), choices=GRID_COLUMN_CHOICES, default=GRID_COLUMN_CHOICES[0][0], blank=True, max_length=255, ) column_alignment = models.CharField( - verbose_name=_('Alignment'), + verbose_name=_("Alignment"), choices=GRID_COLUMN_ALIGNMENT_CHOICES, blank=True, max_length=255, @@ -114,33 +135,35 @@ def __str__(self): return str(self.pk) def get_short_description(self): - text = '' + text = "" classes = self.get_grid_values() if self.xs_col: - text += f'(col-{self.xs_col}) ' + text += f"(col-{self.xs_col}) " else: - text += '(auto) ' - if self.column_type != 'col': - text += f'.{self.column_type} ' + text += "(auto) " + if self.column_type != "col": + text += f".{self.column_type} " if classes: - text += '.{}'.format(' .'.join(self.get_grid_values())) + text += ".{}".format(" .".join(self.get_grid_values())) return text def get_grid_values(self): classes = [] for device in DEVICE_SIZES: - for element in ('col', 'order', 'offset', 'ml', 'mr'): - size = getattr(self, f'{device}_{element}') - if isinstance(size, int) and (element == 'col' or element == 'order' or element == 'offset'): - if device == 'xs': - classes.append(f'{element}-{int(size)}') + for element in ("col", "order", "offset", "ml", "mr"): + size = getattr(self, f"{device}_{element}") + if isinstance(size, int) and ( + element == "col" or element == "order" or element == "offset" + ): + if device == "xs": + classes.append(f"{element}-{int(size)}") else: - classes.append(f'{element}-{device}-{int(size)}') + classes.append(f"{element}-{device}-{int(size)}") elif size: - if device == 'xs': - classes.append('{}-{}'.format(element, 'auto')) + if device == "xs": + classes.append("{}-{}".format(element, "auto")) else: - classes.append('{}-{}-{}'.format(element, device, 'auto')) + classes.append("{}-{}-{}".format(element, device, "auto")) return classes @@ -162,26 +185,26 @@ def get_grid_values(self): for size in DEVICE_SIZES: # Grid size Bootstrap4GridColumn.add_to_class( - f'{size}_col', + f"{size}_col", IntegerRangeFieldPartial(), ) # Grid ordering Bootstrap4GridColumn.add_to_class( - f'{size}_order', + f"{size}_order", IntegerRangeFieldPartial(), ) # Grid offset Bootstrap4GridColumn.add_to_class( - f'{size}_offset', + f"{size}_offset", IntegerRangeFieldPartial(), ) # Grid margin left (ml) Bootstrap4GridColumn.add_to_class( - f'{size}_ml', + f"{size}_ml", BooleanFieldPartial(), ) # Grid margin right (ml) Bootstrap4GridColumn.add_to_class( - f'{size}_mr', + f"{size}_mr", BooleanFieldPartial(), ) From 2c095d31a51ed05c76e2ef528c7ed7c25f6ae94c Mon Sep 17 00:00:00 2001 From: Jordan Date: Fri, 21 Jul 2023 10:20:37 -0700 Subject: [PATCH 2/6] corrected ngettext. --- djangocms_bootstrap4/contrib/bootstrap4_grid/models.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/djangocms_bootstrap4/contrib/bootstrap4_grid/models.py b/djangocms_bootstrap4/contrib/bootstrap4_grid/models.py index 8cf51a2..5a1c58f 100644 --- a/djangocms_bootstrap4/contrib/bootstrap4_grid/models.py +++ b/djangocms_bootstrap4/contrib/bootstrap4_grid/models.py @@ -3,10 +3,7 @@ from django.db import models from django.utils.translation import gettext_lazy as _ -try: - from django.utils.translation import ungettext -except ImportError as exc: - from django.utils.translation import ngettext as ungettext +from django.utils.translation import ngettext as ngettext from cms.models import CMSPlugin @@ -102,7 +99,7 @@ def __str__(self): def get_short_description(self): column_count = len(self.child_plugin_instances or []) - column_count_str = ungettext( + column_count_str = ngettext( "(1 column)", "(%(count)i columns)", column_count ) % {"count": column_count} From 2fc7f14c2b7b53882faf6830289b5052f775965f Mon Sep 17 00:00:00 2001 From: Jordan Date: Fri, 21 Jul 2023 14:31:33 -0700 Subject: [PATCH 3/6] remove mppt. --- tests/settings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/settings.py b/tests/settings.py index d965d16..b4e4bc8 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -4,7 +4,6 @@ 'INSTALLED_APPS': [ 'easy_thumbnails', 'filer', - 'mptt', 'djangocms_text_ckeditor', 'djangocms_link', 'djangocms_picture', From f78a1e339595f47dc39de1f4325b49f6bcde477a Mon Sep 17 00:00:00 2001 From: Fabian Braun Date: Thu, 14 Sep 2023 20:45:08 +0200 Subject: [PATCH 4/6] Update djangocms_bootstrap4/contrib/bootstrap4_grid/models.py --- djangocms_bootstrap4/contrib/bootstrap4_grid/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangocms_bootstrap4/contrib/bootstrap4_grid/models.py b/djangocms_bootstrap4/contrib/bootstrap4_grid/models.py index 5a1c58f..98bcd0d 100644 --- a/djangocms_bootstrap4/contrib/bootstrap4_grid/models.py +++ b/djangocms_bootstrap4/contrib/bootstrap4_grid/models.py @@ -3,7 +3,7 @@ from django.db import models from django.utils.translation import gettext_lazy as _ -from django.utils.translation import ngettext as ngettext +from django.utils.translation import ngettext from cms.models import CMSPlugin From 57ff93277d33063b2822c386d4be82daecb5dc5f Mon Sep 17 00:00:00 2001 From: Fabian Braun Date: Thu, 14 Sep 2023 20:55:57 +0200 Subject: [PATCH 5/6] Update settings.py --- tests/settings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/settings.py b/tests/settings.py index b4e4bc8..d965d16 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -4,6 +4,7 @@ 'INSTALLED_APPS': [ 'easy_thumbnails', 'filer', + 'mptt', 'djangocms_text_ckeditor', 'djangocms_link', 'djangocms_picture', From ff85640a40617c86a7a11e8e213ea4bc02620ad8 Mon Sep 17 00:00:00 2001 From: Fabian Braun Date: Thu, 14 Sep 2023 20:57:07 +0200 Subject: [PATCH 6/6] Update base.txt --- tests/requirements/base.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/requirements/base.txt b/tests/requirements/base.txt index 66157f2..68fb1e6 100644 --- a/tests/requirements/base.txt +++ b/tests/requirements/base.txt @@ -7,3 +7,4 @@ isort flake8 pyflakes>=2.1 wheel +django-filer<3