From 307b94638bf02f2af88a13fed9521234c4c6ad72 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 26 Dec 2018 11:22:03 +0100 Subject: Table gallery: optionnaly display the gallery on tables --- archaeological_context_records/forms.py | 1 + archaeological_finds/forms.py | 7 ++ archaeological_finds/forms_treatments.py | 4 +- archaeological_operations/forms.py | 2 + .../templates/blocks/DataTables-content.html | 45 ++++++++++++ .../templates/blocks/DataTables-gallery.html | 33 +++++++++ ishtar_common/templates/blocks/DataTables.html | 82 +++------------------- ishtar_common/widgets.py | 5 +- 8 files changed, 104 insertions(+), 75 deletions(-) create mode 100644 ishtar_common/templates/blocks/DataTables-content.html create mode 100644 ishtar_common/templates/blocks/DataTables-gallery.html diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py index 8bd3db9f5..54ae74202 100644 --- a/archaeological_context_records/forms.py +++ b/archaeological_context_records/forms.py @@ -122,6 +122,7 @@ class RecordFormSelection(CustomFormSearch): widget=widgets.DataTable( reverse_lazy('get-contextrecord'), RecordSelect, models.ContextRecord, + gallery=True, source_full=reverse_lazy('get-contextrecord-full')), validators=[valid_id(models.ContextRecord)]) diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index ae592d013..3073c5c23 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -992,6 +992,7 @@ class FindFormSelection(CustomFormSearch): widget=widgets.DataTable( reverse_lazy('get-find'), FindSelect, models.Find, + gallery=True, source_full=reverse_lazy('get-find-full')), validators=[valid_id(models.Find)]) @@ -1002,6 +1003,7 @@ class FindFormSelectionWarehouseModule(FindFormSelection): widget=widgets.DataTable( reverse_lazy('get-find'), FindSelectWarehouseModule, models.Find, + gallery=True, source_full=reverse_lazy('get-find-full')), validators=[valid_id(models.Find)]) @@ -1015,6 +1017,7 @@ class MultipleFindFormSelection(forms.Form): widget=widgets.DataTable( reverse_lazy('get-find'), FindSelect, models.Find, + gallery=True, multiple_select=True, source_full=reverse_lazy('get-find-full')), validators=[valid_id(models.Find)]) @@ -1026,6 +1029,7 @@ class MultipleFindFormSelectionWarehouseModule(MultipleFindFormSelection): widget=widgets.DataTable( reverse_lazy('get-find'), FindSelectWarehouseModule, models.Find, + gallery=True, multiple_select=True, source_full=reverse_lazy('get-find-full')), validators=[valid_id(models.Find)]) @@ -1041,6 +1045,7 @@ class FindMultipleFormSelection(forms.Form): label="", required=False, widget=widgets.DataTable( reverse_lazy('get-find'), FindSelectWarehouseModule, models.Find, + gallery=True, multiple=True, multiple_cols=[2, 3, 4]), validators=[valid_ids(models.Find)]) @@ -1186,6 +1191,7 @@ class UpstreamFindFormSelection(PkWizardSearch, FindFormSelection): widget=widgets.DataTable( reverse_lazy('get-find'), FindSelect, current_model, + gallery=True, multiple_select=True, source_full=reverse_lazy('get-find-full')), validators=[valid_ids(current_model)]) @@ -1203,6 +1209,7 @@ class SingleUpstreamFindFormSelection(UpstreamFindFormSelection): widget=widgets.DataTable( reverse_lazy('get-find'), FindSelect, current_model, + gallery=True, source_full=reverse_lazy('get-find-full')), validators=[valid_ids(current_model)]) diff --git a/archaeological_finds/forms_treatments.py b/archaeological_finds/forms_treatments.py index 10c4527ef..18c0697fc 100644 --- a/archaeological_finds/forms_treatments.py +++ b/archaeological_finds/forms_treatments.py @@ -74,7 +74,9 @@ class TreatmentFormSelection(forms.Form): label="", required=False, widget=widgets.DataTable( reverse_lazy('get-treatment'), - TreatmentSelect, models.Treatment), + TreatmentSelect, models.Treatment, + gallery=True, + ), validators=[valid_id(models.Treatment)]) diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index 3103990c9..abb5de8a9 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -603,6 +603,7 @@ class OperationFormSelection(IshtarForm): label="", required=False, widget=widgets.DataTable( reverse_lazy('get-operation'), OperationSelect, models.Operation, + gallery=True, source_full=reverse_lazy('get-operation-full')), validators=[valid_id(models.Operation)]) @@ -1313,6 +1314,7 @@ class SiteFormSelection(IshtarForm): widget=widgets.DataTable( reverse_lazy('get-site'), SiteSelect, models.ArchaeologicalSite, + gallery=True, source_full=reverse_lazy('get-site-full')), validators=[valid_id(models.ArchaeologicalSite)]) diff --git a/ishtar_common/templates/blocks/DataTables-content.html b/ishtar_common/templates/blocks/DataTables-content.html new file mode 100644 index 000000000..41513aade --- /dev/null +++ b/ishtar_common/templates/blocks/DataTables-content.html @@ -0,0 +1,45 @@ +{% load i18n %} +
+ + + + + {% for col in col_names %} + + {% endfor %} + +
{{col}}
+
+ +
+
+
+ +
+
+
+
+ {% 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 multiple %} + + + {% endif %} + + diff --git a/ishtar_common/templates/blocks/DataTables-gallery.html b/ishtar_common/templates/blocks/DataTables-gallery.html new file mode 100644 index 000000000..5fa448d89 --- /dev/null +++ b/ishtar_common/templates/blocks/DataTables-gallery.html @@ -0,0 +1,33 @@ +{% load i18n %} + + + + +
+
+ {% include "blocks/DataTables-content.html" %} +
+ +
+ + diff --git a/ishtar_common/templates/blocks/DataTables.html b/ishtar_common/templates/blocks/DataTables.html index 07725353c..2e2897539 100644 --- a/ishtar_common/templates/blocks/DataTables.html +++ b/ishtar_common/templates/blocks/DataTables.html @@ -27,79 +27,11 @@ - - - -
-
- -
- - - - - {% for col in col_names %} - - {% endfor %} - -
{{col}}
-
- -
-
-
- -
-
-
-
- {% 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 multiple %} - -
    - {% endif %} - - -
    - -
    +{% if gallery %} +{% include "blocks/DataTables-gallery.html" %} +{% else %} +{% include "blocks/DataTables-content.html" %} +{% endif %}