Skip to content

Commit b17bad6

Browse files
src-r-rJordanfsbraun
authored
fix: django import error (#162)
* fix recent django import error. * corrected ngettext. * remove mppt. * Update djangocms_bootstrap4/contrib/bootstrap4_grid/models.py * Update settings.py * Update base.txt --------- Co-authored-by: Jordan <srcrr-gitlab@ipriva.com> Co-authored-by: Fabian Braun <fsbraun@gmx.de>
1 parent 1726033 commit b17bad6

File tree

2 files changed

+68
-47
lines changed

2 files changed

+68
-47
lines changed

djangocms_bootstrap4/contrib/bootstrap4_grid/models.py

Lines changed: 67 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,26 @@
22

33
from django.db import models
44
from django.utils.translation import gettext_lazy as _
5-
from django.utils.translation import ungettext
5+
6+
from django.utils.translation import ngettext
67

78
from cms.models import CMSPlugin
89

910
from djangocms_bootstrap4.constants import DEVICE_SIZES
1011
from djangocms_bootstrap4.fields import AttributesField, IntegerRangeField, TagTypeField
11-
from djangocms_bootstrap4.helpers import get_choices_match, get_first_choice, mark_safe_lazy
12+
from djangocms_bootstrap4.helpers import (
13+
get_choices_match,
14+
get_first_choice,
15+
mark_safe_lazy,
16+
)
1217

1318
from .constants import (
14-
GRID_COLUMN_ALIGNMENT_CHOICES, GRID_COLUMN_CHOICES, GRID_CONTAINER_CHOICES, GRID_ROW_HORIZONTAL_ALIGNMENT_CHOICES,
15-
GRID_ROW_VERTICAL_ALIGNMENT_CHOICES, GRID_SIZE,
19+
GRID_COLUMN_ALIGNMENT_CHOICES,
20+
GRID_COLUMN_CHOICES,
21+
GRID_CONTAINER_CHOICES,
22+
GRID_ROW_HORIZONTAL_ALIGNMENT_CHOICES,
23+
GRID_ROW_VERTICAL_ALIGNMENT_CHOICES,
24+
GRID_SIZE,
1625
)
1726

1827

@@ -21,15 +30,18 @@ class Bootstrap4GridContainer(CMSPlugin):
2130
Layout > Grid: "Container" Plugin
2231
https://getbootstrap.com/docs/4.0/layout/grid/
2332
"""
33+
2434
container_type = models.CharField(
25-
verbose_name=_('Container type'),
35+
verbose_name=_("Container type"),
2636
choices=GRID_CONTAINER_CHOICES,
2737
default=get_first_choice(GRID_CONTAINER_CHOICES),
2838
max_length=255,
29-
help_text=mark_safe_lazy(_(
30-
'Defines if the grid should use fixed width (<code>.container</code>) '
31-
'or fluid width (<code>.container-fluid</code>).'
32-
)),
39+
help_text=mark_safe_lazy(
40+
_(
41+
"Defines if the grid should use fixed width (<code>.container</code>) "
42+
"or fluid width (<code>.container-fluid</code>)."
43+
)
44+
),
3345
)
3446
tag_type = TagTypeField()
3547
attributes = AttributesField()
@@ -39,38 +51,45 @@ def __str__(self):
3951

4052
def get_short_description(self):
4153
choice = get_choices_match(GRID_CONTAINER_CHOICES, self.container_type)
42-
return f'({choice})'
54+
return f"({choice})"
4355

4456

4557
class Bootstrap4GridRow(CMSPlugin):
4658
"""
4759
Layout > Grid: "Row" Plugin
4860
https://getbootstrap.com/docs/4.0/layout/grid/
4961
"""
62+
5063
vertical_alignment = models.CharField(
51-
verbose_name=_('Vertical alignment'),
64+
verbose_name=_("Vertical alignment"),
5265
choices=GRID_ROW_VERTICAL_ALIGNMENT_CHOICES,
5366
blank=True,
5467
max_length=255,
55-
help_text=mark_safe_lazy(_(
56-
'Read more in the <a href="{link}" target="_blank">documentation</a>.')
57-
.format(link='https://getbootstrap.com/docs/4.0/layout/grid/#vertical-alignment')
68+
help_text=mark_safe_lazy(
69+
_(
70+
'Read more in the <a href="{link}" target="_blank">documentation</a>.'
71+
).format(
72+
link="https://getbootstrap.com/docs/4.0/layout/grid/#vertical-alignment"
73+
)
5874
),
5975
)
6076
horizontal_alignment = models.CharField(
61-
verbose_name=_('Horizontal alignment'),
77+
verbose_name=_("Horizontal alignment"),
6278
choices=GRID_ROW_HORIZONTAL_ALIGNMENT_CHOICES,
6379
blank=True,
6480
max_length=255,
65-
help_text=mark_safe_lazy(_(
66-
'Read more in the <a href="{link}" target="_blank">documentation</a>.')
67-
.format(link='https://getbootstrap.com/docs/4.0/layout/grid/#horizontal-alignment')
81+
help_text=mark_safe_lazy(
82+
_(
83+
'Read more in the <a href="{link}" target="_blank">documentation</a>.'
84+
).format(
85+
link="https://getbootstrap.com/docs/4.0/layout/grid/#horizontal-alignment"
86+
)
6887
),
6988
)
7089
gutters = models.BooleanField(
71-
verbose_name=_('Remove gutters'),
90+
verbose_name=_("Remove gutters"),
7291
default=False,
73-
help_text=_('Removes the marginal gutters from the grid.'),
92+
help_text=_("Removes the marginal gutters from the grid."),
7493
)
7594
tag_type = TagTypeField()
7695
attributes = AttributesField()
@@ -80,11 +99,9 @@ def __str__(self):
8099

81100
def get_short_description(self):
82101
column_count = len(self.child_plugin_instances or [])
83-
column_count_str = ungettext(
84-
'(1 column)',
85-
'(%(count)i columns)',
86-
column_count
87-
) % {'count': column_count}
102+
column_count_str = ngettext(
103+
"(1 column)", "(%(count)i columns)", column_count
104+
) % {"count": column_count}
88105

89106
return column_count_str
90107

@@ -94,15 +111,16 @@ class Bootstrap4GridColumn(CMSPlugin):
94111
Layout > Grid: "Column" Plugin
95112
https://getbootstrap.com/docs/4.0/layout/grid/
96113
"""
114+
97115
column_type = models.CharField(
98-
verbose_name=_('Column type'),
116+
verbose_name=_("Column type"),
99117
choices=GRID_COLUMN_CHOICES,
100118
default=GRID_COLUMN_CHOICES[0][0],
101119
blank=True,
102120
max_length=255,
103121
)
104122
column_alignment = models.CharField(
105-
verbose_name=_('Alignment'),
123+
verbose_name=_("Alignment"),
106124
choices=GRID_COLUMN_ALIGNMENT_CHOICES,
107125
blank=True,
108126
max_length=255,
@@ -114,33 +132,35 @@ def __str__(self):
114132
return str(self.pk)
115133

116134
def get_short_description(self):
117-
text = ''
135+
text = ""
118136
classes = self.get_grid_values()
119137
if self.xs_col:
120-
text += f'(col-{self.xs_col}) '
138+
text += f"(col-{self.xs_col}) "
121139
else:
122-
text += '(auto) '
123-
if self.column_type != 'col':
124-
text += f'.{self.column_type} '
140+
text += "(auto) "
141+
if self.column_type != "col":
142+
text += f".{self.column_type} "
125143
if classes:
126-
text += '.{}'.format(' .'.join(self.get_grid_values()))
144+
text += ".{}".format(" .".join(self.get_grid_values()))
127145
return text
128146

129147
def get_grid_values(self):
130148
classes = []
131149
for device in DEVICE_SIZES:
132-
for element in ('col', 'order', 'offset', 'ml', 'mr'):
133-
size = getattr(self, f'{device}_{element}')
134-
if isinstance(size, int) and (element == 'col' or element == 'order' or element == 'offset'):
135-
if device == 'xs':
136-
classes.append(f'{element}-{int(size)}')
150+
for element in ("col", "order", "offset", "ml", "mr"):
151+
size = getattr(self, f"{device}_{element}")
152+
if isinstance(size, int) and (
153+
element == "col" or element == "order" or element == "offset"
154+
):
155+
if device == "xs":
156+
classes.append(f"{element}-{int(size)}")
137157
else:
138-
classes.append(f'{element}-{device}-{int(size)}')
158+
classes.append(f"{element}-{device}-{int(size)}")
139159
elif size:
140-
if device == 'xs':
141-
classes.append('{}-{}'.format(element, 'auto'))
160+
if device == "xs":
161+
classes.append("{}-{}".format(element, "auto"))
142162
else:
143-
classes.append('{}-{}-{}'.format(element, device, 'auto'))
163+
classes.append("{}-{}-{}".format(element, device, "auto"))
144164

145165
return classes
146166

@@ -162,26 +182,26 @@ def get_grid_values(self):
162182
for size in DEVICE_SIZES:
163183
# Grid size
164184
Bootstrap4GridColumn.add_to_class(
165-
f'{size}_col',
185+
f"{size}_col",
166186
IntegerRangeFieldPartial(),
167187
)
168188
# Grid ordering
169189
Bootstrap4GridColumn.add_to_class(
170-
f'{size}_order',
190+
f"{size}_order",
171191
IntegerRangeFieldPartial(),
172192
)
173193
# Grid offset
174194
Bootstrap4GridColumn.add_to_class(
175-
f'{size}_offset',
195+
f"{size}_offset",
176196
IntegerRangeFieldPartial(),
177197
)
178198
# Grid margin left (ml)
179199
Bootstrap4GridColumn.add_to_class(
180-
f'{size}_ml',
200+
f"{size}_ml",
181201
BooleanFieldPartial(),
182202
)
183203
# Grid margin right (ml)
184204
Bootstrap4GridColumn.add_to_class(
185-
f'{size}_mr',
205+
f"{size}_mr",
186206
BooleanFieldPartial(),
187207
)

tests/requirements/base.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ isort
77
flake8
88
pyflakes>=2.1
99
wheel
10+
django-filer<3

0 commit comments

Comments
 (0)