From ed3f985309bc265e07d30f7d6df375b2800c57ea Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 30 Apr 2019 13:35:51 +0200 Subject: Label generation: label generation available at the bottom of tables --- .../templates/blocks/DataTables-content.html | 44 ++++++++++++++++------ ishtar_common/templates/blocks/DataTables.html | 10 ++++- ishtar_common/widgets.py | 1 + 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/ishtar_common/templates/blocks/DataTables-content.html b/ishtar_common/templates/blocks/DataTables-content.html index 1b069f674..4a9257f65 100644 --- a/ishtar_common/templates/blocks/DataTables-content.html +++ b/ishtar_common/templates/blocks/DataTables-content.html @@ -21,19 +21,39 @@
-
- {% if source_full or extra_sources %} - {% trans "Simple CSV" %} - {% if source_full %}{% trans "CSV full" %}{% endif %} - {% for slug, name, extra_source in extra_sources %} - {{name}} - {% endfor %} - {% else %} - {% trans "CSV" %} - {% endif %} +
+ +
+ {% if current_model.has_label_templates %}
+ + +
{% endif %}
diff --git a/ishtar_common/templates/blocks/DataTables.html b/ishtar_common/templates/blocks/DataTables.html index 90eced2f9..a20a151a9 100644 --- a/ishtar_common/templates/blocks/DataTables.html +++ b/ishtar_common/templates/blocks/DataTables.html @@ -163,8 +163,14 @@ update_submit_args = function(){ var csv_full_url = "{{source_full}}csv?submited=1&" + data; $(".{{sname}}-csv-full").attr("href", csv_full_url); {% for slug, name, extra_source in extra_sources %} - $(".{{slug}}-csv-full").attr("href", '{{extra_source}}csv?submited=1&' + data); - {% endfor %} + $(".{{slug}}-csv-full").attr("href", '{{extra_source}}csv?submited=1&' + data);{% endfor %} + {% for template in current_model.label_templates %} + $(".{{template.slug}}-labels").attr("href", '{{template.get_baselink_for_labels}}?submited=1&' + data);{% endfor %} + + if ($('.modal-progress').length > 0){ + $('.modal-progress').modal('hide'); + } + return false; }; diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 3d69ff117..5b5f44477 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -1089,6 +1089,7 @@ class DataTable(Select2Media, forms.RadioSelect): dct['extra_sources'] = [] dct['quick_actions'] = [] if self.associated_model: + dct['current_model'] = self.associated_model model_name = "{}.{}".format( self.associated_model.__module__, self.associated_model.__name__) -- cgit v1.2.3