From be017ab3369ff1c4b4943b45243974dc761c2ddb Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 9 Aug 2023 13:09:45 +0200 Subject: ✨ Imports groups: get import list sorted by order in importer group MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/models_imports.py | 17 +++++++++++- ishtar_common/templates/ishtar/import_table.html | 34 ++++++++---------------- 2 files changed, 27 insertions(+), 24 deletions(-) (limited to 'ishtar_common') diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index 735ad0b10..201b39a5b 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -1311,11 +1311,26 @@ class ImportGroup(BaseImport): def __str__(self): return f"{self.name} ({self.importer_type.name})" + def import_list(self): + """ + Sorted import list by order in the importer group + """ + import_list = [] + for imp in self.imports.all(): + igi = ImporterGroupImporter.objects.filter( + group=self.importer_type, + importer_type=imp.importer_type + ) + if not igi.count(): # inconsistent data + continue + import_list.append((igi.all()[0].order, imp)) + return [imp for order, imp in sorted(import_list, key=lambda i: i[0])] + @property def status(self): if self.state not in IMPORT_GROUP_STATE_DCT: return "" - return IMPORT_GROUP_STATE_DCT[self.state] + return IMPORT_GROUP_STATE_DCT[str(self.state)] def get_actions(self): """ diff --git a/ishtar_common/templates/ishtar/import_table.html b/ishtar_common/templates/ishtar/import_table.html index cf33341d1..41ee54f05 100644 --- a/ishtar_common/templates/ishtar/import_table.html +++ b/ishtar_common/templates/ishtar/import_table.html @@ -100,36 +100,24 @@ $("#import-list").find('input').prop('disabled', true); {% endif %} {% if not import.importer_type.type_label %} {# group #} - {% for sub in import.imports.all %} + {% for sub in import.import_list %} - - {{sub.importer_type}} - - - {% if sub.imported_file %} + {{sub.importer_type}} + {% if sub.imported_file %} {% trans "Source file" %} - {% endif %} - - - {% if sub.imported_images %} + {% endif %} + {% if sub.imported_images %} {% trans "Media file" %} - {% else %} - – + {% else %} – {% endif %} - - - - {{sub.status}} - - - - - {% if sub.need_matching %} + + {{sub.status}} + + {% if sub.need_matching %} {% trans "Match"%} - {% endif %} - + {% endif %} {% if sub.error_file %} {% trans "File" context "not a directory" %} {% endif %} -- cgit v1.2.3