summaryrefslogtreecommitdiff
path: root/ishtar_common/widgets.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-11-27 18:14:29 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-11-27 18:15:01 +0100
commite510cab9cd85e9824c6e80ec280b69df5dd7cae6 (patch)
tree6b93265a90dcedcfcb8861b8b59d9cd8c6f2da18 /ishtar_common/widgets.py
parent727587e46c738916a08be018f5afb909c1cce877 (diff)
downloadIshtar-e510cab9cd85e9824c6e80ec280b69df5dd7cae6.tar.bz2
Ishtar-e510cab9cd85e9824c6e80ec280b69df5dd7cae6.zip
JQueryJqGrid replacement by DataTables
Diffstat (limited to 'ishtar_common/widgets.py')
-rw-r--r--ishtar_common/widgets.py31
1 files changed, 8 insertions, 23 deletions
diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py
index 323a2e547..6abaa927b 100644
--- a/ishtar_common/widgets.py
+++ b/ishtar_common/widgets.py
@@ -651,22 +651,14 @@ class JQueryPersonOrganization(forms.TextInput):
return html
-class JQueryJqGrid(forms.RadioSelect):
- COL_TPL = "{name:'%(idx)s', index:'%(idx)s', sortable:true}"
-
- # class Media:
- # js = ['%s/js/i18n/grid.locale-%s.js' % (settings.STATIC_URL,
- # settings.COUNTRY),
- # '%s/js/jquery.jqGrid.min.js' % settings.STATIC_URL]
- # css = {'all': ['%s/media/ui.jqgrid.css' % settings.STATIC_URL]}
-
+class DataTable(forms.RadioSelect):
def __init__(self, source, form, associated_model, attrs={},
table_cols='TABLE_COLS', multiple=False, multiple_cols=[2],
new=False, new_message="", source_full=None,
multiple_select=False, sortname="__default__",
col_prefix=''):
"""
- JQueryJqGrid widget init.
+ DataTable widget init.
:param source: url to get the item from -- get_item
:param form:
@@ -682,7 +674,7 @@ class JQueryJqGrid(forms.RadioSelect):
:param sortname: column name (model attribute) to use to sort
:param col_prefix: prefix to remove to col_names
"""
- super(JQueryJqGrid, self).__init__(attrs=attrs)
+ super(DataTable, self).__init__(attrs=attrs)
self.source = source
self.form = form
if not attrs:
@@ -742,15 +734,7 @@ class JQueryJqGrid(forms.RadioSelect):
else:
jq_col_names.append(settings.JOINT.join(
[f for f in field_verbose_names if f]))
- if not python:
- jq_col_names[-1] = u'"%s"' % jq_col_names[-1]
- if python:
- extra_cols.append(field_name)
- else:
- extra_cols.append(self.COL_TPL % {'idx': field_name})
- if not python:
- jq_col_names = jq_col_names and ", ".join(jq_col_names) or ""
- extra_cols = extra_cols and ", ".join(extra_cols) or ""
+ extra_cols.append(field_name)
return jq_col_names, extra_cols
def render(self, name, value, attrs=None, renderer=None):
@@ -793,10 +777,11 @@ class JQueryJqGrid(forms.RadioSelect):
dct['extra_sources'].append((
imp.slug, imp.name,
reverse('get-by-importer', args=[imp.slug])))
+ source = unicode(self.source)
dct.update({'name': name,
'col_names': col_names,
'extra_cols': extra_cols,
- 'source': unicode(self.source),
+ 'source': source,
'col_idx': col_idx,
'no_result': unicode(_("No results")),
'loading': unicode(_("Loading...")),
@@ -805,7 +790,7 @@ class JQueryJqGrid(forms.RadioSelect):
'multiple': self.multiple,
'multiple_select': self.multiple_select,
'multi_cols': ",".join((u'"%d"' % col
- for col in self.multiple_cols))})
- t = loader.get_template('blocks/JQueryJqGrid.html')
+ for col in self.multiple_cols))})
+ t = loader.get_template('blocks/DataTables.html')
rendered += t.render(dct)
return mark_safe(rendered)