summaryrefslogtreecommitdiff
path: root/ishtar_common/widgets.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/widgets.py')
-rw-r--r--ishtar_common/widgets.py35
1 files changed, 21 insertions, 14 deletions
diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py
index 9bffe4ec5..66380db8b 100644
--- a/ishtar_common/widgets.py
+++ b/ishtar_common/widgets.py
@@ -524,19 +524,8 @@ class JQueryJqGrid(forms.RadioSelect):
self.new, self.new_message = new, new_message
self.source_full = source_full
- def render(self, name, value=None, attrs=None):
- t = loader.get_template('blocks/form_snippet.html')
- form = self.form()
- rendered = t.render(Context({'form': form}))
- dct = {}
- if self.new:
- model_name = self.associated_model._meta.object_name.lower()
- dct['url_new'] = reverse('new-' + model_name, args=['0'])
- dct['new_message'] = self.new_message
- extra_cols = []
- col_names, col_idx = [], []
- for k in form.get_input_ids():
- col_idx.append(u'"%s"' % k)
+ def get_cols(self):
+ col_names, extra_cols = [], []
for field_name in getattr(self.associated_model, self.table_cols):
field = self.associated_model
keys = field_name.split('.')
@@ -557,8 +546,26 @@ class JQueryJqGrid(forms.RadioSelect):
col_names.append(u'"%s"' % field_verbose_name)
extra_cols.append(self.COL_TPL % {'idx': field_name})
col_names = col_names and ", ".join(col_names) or ""
- col_idx = col_idx and ", ".join(col_idx) or ""
extra_cols = extra_cols and ", ".join(extra_cols) or ""
+ return col_names, extra_cols
+
+ def render(self, name, value=None, attrs=None):
+ t = loader.get_template('blocks/form_snippet.html')
+ form = self.form()
+ rendered = t.render(Context({'form': form}))
+ dct = {}
+ if self.new:
+ model_name = self.associated_model._meta.object_name.lower()
+ dct['url_new'] = reverse('new-' + model_name, args=['0'])
+ dct['new_message'] = self.new_message
+
+ col_names, extra_cols = self.get_cols()
+
+ col_idx = []
+ for k in form.get_input_ids():
+ col_idx.append(u'"%s"' % k)
+ col_idx = col_idx and ", ".join(col_idx) or ""
+
dct['encoding'] = settings.ENCODING or 'utf-8'
dct['source'] = unicode(self.source)
if unicode(self.source_full) and unicode(self.source_full) != 'None':