diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-08-09 13:09:45 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-04-16 16:38:32 +0200 |
commit | 145f02926494e34e12ba773485348f9269087431 (patch) | |
tree | 69778b19b68803a509ee9be2bf4e2a1b5ad745cd | |
parent | df7044e23e0123558124a600e5b470ed2d537135 (diff) | |
download | Ishtar-145f02926494e34e12ba773485348f9269087431.tar.bz2 Ishtar-145f02926494e34e12ba773485348f9269087431.zip |
✨ Imports groups: get import list sorted by order in importer group
-rw-r--r-- | ishtar_common/models_imports.py | 17 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/import_table.html | 34 |
2 files changed, 27 insertions, 24 deletions
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); </tr> {% endif %} {% if not import.importer_type.type_label %} {# group #} - {% for sub in import.imports.all %} + {% for sub in import.import_list %} <tr> <td></td> - <td> - {{sub.importer_type}} - </td> - <td> - {% if sub.imported_file %} + <td>{{sub.importer_type}}</td> + <td>{% if sub.imported_file %} <a href='{{sub.imported_file.url}}'>{% trans "Source file" %}</a> - {% endif %} - </td> - <td> - {% if sub.imported_images %} + {% endif %}</td> + <td>{% if sub.imported_images %} <a href="{{ sub.imported_images.url }}">{% trans "Media file" %}</a> - {% else %} - – + {% else %} – {% endif %} </td> - <td> - </td> - <td> - {{sub.status}} - </td> - <td> - </td> - <td> - {% if sub.need_matching %} + <td></td> + <td>{{sub.status}}</td> + <td></td> + <td>{% if sub.need_matching %} <a href='{% url "import_link_unmatched" sub.pk %}'>{% trans "Match"%}</a> - {% endif %} - </td> + {% endif %}</td> <td style="white-space: nowrap;">{% if sub.error_file %} <i class="text-danger fa fa-exclamation-triangle" aria-hidden="true"></i> <a href='{{sub.error_file.url}}'>{% trans "File" context "not a directory" %}</a> {% endif %}</td> |