summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ishtar_common/forms.py8
-rw-r--r--ishtar_common/widgets.py4
2 files changed, 8 insertions, 4 deletions
diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py
index 311f6fee4..448c06ceb 100644
--- a/ishtar_common/forms.py
+++ b/ishtar_common/forms.py
@@ -660,6 +660,10 @@ class ClosingDateFormSelection(IshtarForm):
super(ClosingDateFormSelection, self).__init__(*args, **kwargs)
+def has_map():
+ return models.get_current_profile().mapping
+
+
def get_form_selection(
class_name, label, key, model, base_form, get_url,
not_selected_error=_(u"You should select an item."), new=False,
@@ -688,8 +692,8 @@ def get_form_selection(
widget_kwargs['source_full'] = reverse_lazy(get_full_url)
if gallery:
widget_kwargs['gallery'] = True
- if map and models.get_current_profile().mapping:
- widget_kwargs['map'] = True
+ if map:
+ widget_kwargs['map'] = has_map
attrs[key] = forms.IntegerField(
label="", required=False,
validators=[models.valid_id(model)],
diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py
index cc4f5c8e8..37f44e938 100644
--- a/ishtar_common/widgets.py
+++ b/ishtar_common/widgets.py
@@ -971,7 +971,7 @@ class DataTable(Select2Media, forms.RadioSelect):
:param sortname: column name (model attribute) to use to sort
:param col_prefix: prefix to remove to col_names
:param gallery: display the gallery if True
- :param map: display the map if True
+ :param map: display the map if True - can be a callable
"""
super(DataTable, self).__init__(attrs=attrs)
self.source = source
@@ -1113,7 +1113,7 @@ class DataTable(Select2Media, forms.RadioSelect):
'remove': unicode(_(u"Remove")),
'sname': name.replace('-', ''),
'gallery': self.gallery,
- 'use_map': self.map,
+ 'use_map': self.map() if callable(self.map) else self.map,
'multiple': self.multiple,
'multiple_select': self.multiple_select,
'multi_cols': ",".join((u'"%d"' % col