diff options
| 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 | 
| commit | 56cdde3c9d9b8ff40c8d27a31e2160aa8944d783 (patch) | |
| tree | 6b93265a90dcedcfcb8861b8b59d9cd8c6f2da18 /ishtar_common/widgets.py | |
| parent | eb503b15cadf1149323fbaee9f9716283961994a (diff) | |
| download | Ishtar-56cdde3c9d9b8ff40c8d27a31e2160aa8944d783.tar.bz2 Ishtar-56cdde3c9d9b8ff40c8d27a31e2160aa8944d783.zip | |
JQueryJqGrid replacement by DataTables
Diffstat (limited to 'ishtar_common/widgets.py')
| -rw-r--r-- | ishtar_common/widgets.py | 31 | 
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) | 
