mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-03 13:04:46 +00:00
Added regex to detect if a col class added to fieldrowpanel. If not, add default
This commit is contained in:
parent
ba807e5f45
commit
b559f411be
1 changed files with 10 additions and 0 deletions
|
|
@ -3,6 +3,8 @@ from __future__ import absolute_import, unicode_literals
|
|||
import warnings
|
||||
|
||||
import django
|
||||
import re
|
||||
import math
|
||||
from django import forms
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
|
@ -347,6 +349,14 @@ class FieldRowPanel(object):
|
|||
self.classname = classname
|
||||
|
||||
def bind_to_model(self, model):
|
||||
col_count = " col" + str(int(math.floor(12 / len(self.children))))
|
||||
|
||||
# If child panel doesn't have a col# class then append default based on
|
||||
# number of columns
|
||||
for child in self.children:
|
||||
if re.match("^.*?(col)[1-9]{1}(?![3-9])[0-2]{0,1}.*?$", child.classname) is None:
|
||||
child.classname += col_count
|
||||
|
||||
return type(str('_FieldRowPanel'), (BaseFieldRowPanel,), {
|
||||
'model': model,
|
||||
'children': [child.bind_to_model(model) for child in self.children],
|
||||
|
|
|
|||
Loading…
Reference in a new issue