Merge pull request #39 from yourowndisaster09/master

Added bootstrap column number configuration
This commit is contained in:
tzangms
2013-12-05 11:49:14 -08:00
2 changed files with 9 additions and 4 deletions

3
bootstrapform/config.py Normal file
View File

@@ -0,0 +1,3 @@
from django.conf import settings
BOOTSTRAP_COLUMN_COUNT = getattr(settings, 'BOOTSTRAP_COLUMN_COUNT', 12)

View File

@@ -3,6 +3,8 @@ from django.template import Context
from django.template.loader import get_template from django.template.loader import get_template
from django import template from django import template
from bootstrapform import config
register = template.Library() register = template.Library()
@register.filter @register.filter
@@ -32,14 +34,14 @@ def bootstrap_horizontal(element, label_cols={}):
try: try:
value_nb_cols = int(splited_class[-1]) value_nb_cols = int(splited_class[-1])
except ValueError: except ValueError:
value_nb_cols = 12 value_nb_cols = config.BOOTSTRAP_COLUMN_COUNT
if value_nb_cols >= 12: if value_nb_cols >= config.BOOTSTRAP_COLUMN_COUNT:
splited_class[-1] = 12 splited_class[-1] = config.BOOTSTRAP_COLUMN_COUNT
else: else:
offset_class = cl.split('-') offset_class = cl.split('-')
offset_class[-1] = 'offset-' + str(value_nb_cols) offset_class[-1] = 'offset-' + str(value_nb_cols)
splited_class[-1] = str(12 - value_nb_cols) splited_class[-1] = str(config.BOOTSTRAP_COLUMN_COUNT - value_nb_cols)
markup_classes['single_value'] += ' ' + '-'.join(offset_class) markup_classes['single_value'] += ' ' + '-'.join(offset_class)
markup_classes['single_value'] += ' ' + '-'.join(splited_class) markup_classes['single_value'] += ' ' + '-'.join(splited_class)