From 6393088eb7490f6dbb9a74a12184ca5cb0e11433 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 5 Oct 2023 11:30:02 +0200 Subject: ✨ import group sheet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog/en/changelog_2022-06-15.md | 2 +- changelog/fr/changelog_2023-01-25.md | 2 +- ishtar_common/models_common.py | 25 +++--- ishtar_common/models_imports.py | 7 +- .../ishtar/blocks/sheet_creation_section.html | 4 +- ishtar_common/templates/ishtar/import_table.html | 2 +- ishtar_common/templates/ishtar/sheet_import.html | 98 +--------------------- .../templates/ishtar/sheet_import_gen.html | 98 ++++++++++++++++++++++ .../templates/ishtar/sheet_importgroup.html | 12 +++ .../templates/ishtar/sheet_importgroup_pdf.html | 14 ++++ .../templates/ishtar/sheet_importgroup_window.html | 3 + ishtar_common/urls.py | 5 ++ ishtar_common/utils.py | 14 +++- ishtar_common/views.py | 1 + 14 files changed, 169 insertions(+), 118 deletions(-) create mode 100644 ishtar_common/templates/ishtar/sheet_import_gen.html create mode 100644 ishtar_common/templates/ishtar/sheet_importgroup.html create mode 100644 ishtar_common/templates/ishtar/sheet_importgroup_pdf.html create mode 100644 ishtar_common/templates/ishtar/sheet_importgroup_window.html diff --git a/changelog/en/changelog_2022-06-15.md b/changelog/en/changelog_2022-06-15.md index ea40b2b98..8d2a989a2 100644 --- a/changelog/en/changelog_2022-06-15.md +++ b/changelog/en/changelog_2022-06-15.md @@ -9,7 +9,7 @@ v4.0.XX - 2099-12-31 - automatic progress refresh - reorganization of fields - improved presentation -- sheet import +- import sheet (links from other sheet to the import sheet) ### Technical ### - update relationship between imports and main items diff --git a/changelog/fr/changelog_2023-01-25.md b/changelog/fr/changelog_2023-01-25.md index 24f0f4841..d7b39fcdd 100644 --- a/changelog/fr/changelog_2023-01-25.md +++ b/changelog/fr/changelog_2023-01-25.md @@ -9,7 +9,7 @@ v4.0.XX - 2099-12-31 - rafraîchissement automatique de l'avancement - réorganisation des champs - amélioration de la présentation -- fiche d'import +- fiche d'import (liens des autres fiches vers la fiche import) ### Technique ### - relation de mise à jour entre imports et les éléments principaux diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 79c9600dd..43677bca4 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -49,6 +49,7 @@ from ishtar_common.utils import ( get_image_path, get_columns_from_class, human_date, + SheetItem ) from simple_history.models import HistoricalRecords as BaseHistoricalRecords from simple_history.signals import ( @@ -1111,9 +1112,16 @@ class Imported(models.Model): return [] q = getattr(self, key) if user.is_superuser or user.ishtaruser.has_right("view_import"): - return list(q.all()) - q = q.filter(Q(user=user.ishtaruser) | Q(importer_type__users__pk=user.ishtaruser.pk)) - return list(q.all()) + lst = list(q.all()) + else: + lst = q.filter(Q(user=user.ishtaruser) | Q(importer_type__users__pk=user.ishtaruser.pk)) + new_lst = [] + for imprt in lst: + if imprt.group: + new_lst.append(imprt.group) + else: + new_lst.append(imprt) + return new_lst def get_imports(self, user): return self._get_imports(user, "imports") @@ -3102,7 +3110,7 @@ class ShortMenuItem: return "" -class MainItem(ShortMenuItem, SerializeItem): +class MainItem(ShortMenuItem, SerializeItem, SheetItem): """ Item with quick actions available from tables Extra actions are available from sheets @@ -3182,15 +3190,6 @@ class MainItem(ShortMenuItem, SerializeItem): except NoReverseMatch: return - def get_show_url(self): - show_url = self.SHOW_URL - if not show_url: - show_url = "show-" + self.__class__.__name__.lower() - try: - return reverse(show_url, args=[self.pk, ""]) - except NoReverseMatch: - return - @classmethod def get_columns(cls, table_cols_attr="TABLE_COLS", dict_col_labels=True): """ diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index 02b86849c..84ea42112 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -75,7 +75,8 @@ from ishtar_common.utils import ( put_session_var, reverse_coordinates, update_data, - OwnPerms + OwnPerms, + SheetItem ) from ishtar_common.data_importer import ( Importer, @@ -1340,7 +1341,7 @@ IMPORT_GEOMETRY = { } -class BaseImport(models.Model, OwnPerms): +class BaseImport(models.Model, OwnPerms, SheetItem): user = models.ForeignKey( "IshtarUser", blank=True, null=True, on_delete=models.SET_NULL ) @@ -1484,6 +1485,7 @@ class ImportGroup(BaseImport): ) ADMIN_SECTION = _("Imports") SLUG = "importgroup" + SHOW_URL = "show-importgroup" def __str__(self): return f"{self.name} ({self.importer_type.name})" @@ -1879,6 +1881,7 @@ class Import(BaseImport): ) ADMIN_SECTION = _("Imports") SLUG = "import" + SHOW_URL = "show-import" def __str__(self): return "{} | {}".format(self.name or "-", self.importer_type) diff --git a/ishtar_common/templates/ishtar/blocks/sheet_creation_section.html b/ishtar_common/templates/ishtar/blocks/sheet_creation_section.html index 4460809d4..fc969bb17 100644 --- a/ishtar_common/templates/ishtar/blocks/sheet_creation_section.html +++ b/ishtar_common/templates/ishtar/blocks/sheet_creation_section.html @@ -22,7 +22,7 @@
{% trans "Imports (creation)" %}
{% for imprt in get_import_list %}{% if loop.counter %} ; {% endif %} - + {{imprt}}{% endfor %}
@@ -31,7 +31,7 @@
{% trans "Imports (update)" %}
{% for imprt in get_import_updated %}{% if loop.counter %} ; {% endif %} - + {{imprt}}{% endfor %}
diff --git a/ishtar_common/templates/ishtar/import_table.html b/ishtar_common/templates/ishtar/import_table.html index 0a894b778..be3af600b 100644 --- a/ishtar_common/templates/ishtar/import_table.html +++ b/ishtar_common/templates/ishtar/import_table.html @@ -65,7 +65,7 @@ class='import-row{% if import.has_error or not import.pre_import_form_is_valid %}-error{% endif %}{% if import.pk in refreshed_pks %} bg-info{% endif %}'>