diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-03-13 23:25:18 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-03-13 23:28:13 +0100 | 
| commit | a0bc331d6a48f334f145063e6695696045d92c13 (patch) | |
| tree | d292159ee07f6f6f52eee9867ff97abd0d601c95 /ishtar_common | |
| parent | 37e7eb4e3abc92fd2914eba00e951d6c2507ef8e (diff) | |
| download | Ishtar-a0bc331d6a48f334f145063e6695696045d92c13.tar.bz2 Ishtar-a0bc331d6a48f334f145063e6695696045d92c13.zip | |
Better display of sheet sources (refs #3065)
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html | 8 | ||||
| -rw-r--r-- | ishtar_common/templatetags/window_tables.py | 58 | ||||
| -rw-r--r-- | ishtar_common/views.py | 5 | ||||
| -rw-r--r-- | ishtar_common/widgets.py | 2 | 
4 files changed, 33 insertions, 40 deletions
| diff --git a/ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html b/ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html index 76172d3ac..7239b64fc 100644 --- a/ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html +++ b/ishtar_common/templates/ishtar/blocks/window_tables/dynamic_documents.html @@ -7,10 +7,10 @@  <div id='foot_{{name}}' class='gridfooter'>  {% if source_full %}  {% trans "Export as CSV" %} ({{encoding}}) -<a href='{{simple_source}}csv{{ source_attrs }}' target='_blank'>{% trans "simple" %}</a> -  -<a href='{{source_full}}csv{{ source_attrs }}' target='_blank'>{% trans "full" %}</a> +<a href='{{simple_source}}csv{{ source_attrs|safe }}' target='_blank'>{% trans "simple" %}</a> -  +<a href='{{source_full}}csv{{ source_attrs|safe }}' target='_blank'>{% trans "full" %}</a>  {% else %} -<a href="{{simple_source}}csv{{ source_attrs }}" target="_blank">{% trans "Export as CSV" %} ({{encoding}})</a> +<a href="{{simple_source}}csv{{ source_attrs|safe }}" target="_blank">{% trans "Export as CSV" %} ({{encoding}})</a>  {% endif %}  </div> @@ -19,7 +19,7 @@  setTimeout(      function(){        $("#grid_{{name}}").jqGrid({ -        url:'{{source}}', +        url:'{{source|safe}}',          datatype: "json",          mtype: 'GET',          colNames:['id', '', {{col_names|safe}}], diff --git a/ishtar_common/templatetags/window_tables.py b/ishtar_common/templatetags/window_tables.py index 53075b20e..cdd681b52 100644 --- a/ishtar_common/templatetags/window_tables.py +++ b/ishtar_common/templatetags/window_tables.py @@ -6,11 +6,18 @@ from django.conf import settings  from django.core.urlresolvers import resolve  from django.template.defaultfilters import slugify  from django.template.loader import get_template +from django.utils.safestring import mark_safe  from django.utils.translation import ugettext_lazy as _  from ishtar_common.forms import reverse_lazy  from ishtar_common.widgets import JQueryJqGrid +from archaeological_files.models import File +from archaeological_operations.models import OperationSource, Operation +from archaeological_context_records.models import ContextRecord, \ +    ContextRecordSource +from archaeological_finds.models import Find, FindSource +  register = template.Library() @@ -19,40 +26,21 @@ def table_document(caption, data):      return {'caption': caption, 'data': data}  ASSOCIATED_MODELS = {} -try: -    from archaeological_files.models import File -    ASSOCIATED_MODELS['files'] = (File, 'get-file', '') -except: -    pass - -try: -    from archaeological_operations.models import OperationSource, Operation -    ASSOCIATED_MODELS['operation_docs'] = (OperationSource, -                                           'get-operationsource', '') -    ASSOCIATED_MODELS['operations'] = (Operation, 'get-operation', '') -except: -    pass - -try: -    from archaeological_context_records.models import ContextRecord, \ -        ContextRecordSource -    ASSOCIATED_MODELS['context_records'] = (ContextRecord, 'get-contextrecord', -                                            'get-contextrecord-full') -    ASSOCIATED_MODELS['context_records_for_ope'] = ( -        ContextRecord, -        'get-contextrecord-for-ope', 'get-contextrecord-full') -    ASSOCIATED_MODELS['context_records_docs'] = (ContextRecordSource, -                                                 'get-contextrecordsource', '') -except: -    pass - -try: -    from archaeological_finds.models import Find -    ASSOCIATED_MODELS['finds'] = (Find, 'get-find', 'get-find-full') -    ASSOCIATED_MODELS['finds_for_ope'] = ( -        Find, 'get-find-for-ope', 'get-find-full') -except: -    pass +ASSOCIATED_MODELS['files'] = (File, 'get-file', '') +ASSOCIATED_MODELS['operation_docs'] = (OperationSource, +                                       'get-operationsource', '') +ASSOCIATED_MODELS['operations'] = (Operation, 'get-operation', '') +ASSOCIATED_MODELS['context_records'] = (ContextRecord, 'get-contextrecord', +                                        'get-contextrecord-full') +ASSOCIATED_MODELS['context_records_for_ope'] = ( +    ContextRecord, +    'get-contextrecord-for-ope', 'get-contextrecord-full') +ASSOCIATED_MODELS['context_records_docs'] = (ContextRecordSource, +                                             'get-contextrecordsource', '') +ASSOCIATED_MODELS['finds'] = (Find, 'get-find', 'get-find-full') +ASSOCIATED_MODELS['finds_for_ope'] = ( +    Find, 'get-find-for-ope', 'get-find-full') +ASSOCIATED_MODELS['finds_docs'] = (FindSource, 'get-findsource', '')  @register.simple_tag(takes_context=True) @@ -64,7 +52,7 @@ def dynamic_table_document(context, caption, associated_model, key, value,      grid = JQueryJqGrid(None, None, model, table_cols=table_cols)      source = unicode(reverse_lazy(url))      source_full = unicode(reverse_lazy(url_full)) if url_full else '' -    source_attrs = '?submited=1&{}={}'.format(key, value) +    source_attrs = mark_safe('?submited=1&{}={}'.format(key, value))      if output == 'html':          col_names, extra_cols = grid.get_cols()          t = get_template('ishtar/blocks/window_tables/dynamic_documents.html') diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 5ea53374d..54eb9164f 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -572,7 +572,12 @@ def get_item(model, func_name, default_name, extra_request_keys=[],          datas = []          if old:              items = [item.get_previous(old) for item in items] +        c_ids = []          for item in items: +            # manual deduplicate when distinct is not enough +            if item.pk in c_ids: +                continue +            c_ids.append(item.pk)              data = [item.pk]              for keys in table_cols:                  if type(keys) not in (list, tuple): diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 57aa8cf69..b8b104a61 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -1,6 +1,6 @@  #!/usr/bin/env python  # -*- coding: utf-8 -*- -# Copyright (C) 2010-2015 Étienne Loks  <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2010-2016 Étienne Loks  <etienne.loks_AT_peacefrogsDOTnet>  # Copyright (C) 2007  skam <massimo dot scamarcia at gmail.com>  #                          (http://djangosnippets.org/snippets/233/) | 
