diff options
| -rw-r--r-- | ishtar_common/forms_common.py | 2 | ||||
| -rw-r--r-- | ishtar_common/models_imports.py | 15 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/import_table.html | 2 | ||||
| -rw-r--r-- | ishtar_common/views.py | 16 | 
4 files changed, 23 insertions, 12 deletions
| diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index e5ff21cd8..6a351ab3c 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -374,7 +374,7 @@ class NewImportForm(BaseImportForm):              if "imported_images_link" in self.cleaned_data              else None          ) -        item = super(BaseImportForm, self).save(commit) +        item = super().save(commit)          if not imported_images_link:              return item          request = requests.get(imported_images_link, stream=True) diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index d0aa6f4d6..e9a7cf6df 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -1293,10 +1293,6 @@ class BaseImport(models.Model):  class ImportGroup(BaseImport): -    class Meta: -        verbose_name = _("Import - Group") -        verbose_name_plural = _("Import - Groups") -    ADMIN_SECTION = _("Imports")      importer_type = models.ForeignKey(ImporterGroup, on_delete=models.CASCADE,                                        verbose_name=_("Importer group type"))      current_import = models.PositiveIntegerField(_("Current import"), blank=True, null=True) @@ -1304,6 +1300,17 @@ class ImportGroup(BaseImport):          _("State"), max_length=2, choices=IMPORT_GROUP_STATE, default="C"      ) +    class Meta: +        verbose_name = _("Import - Group") +        verbose_name_plural = _("Import - Groups") +    ADMIN_SECTION = _("Imports") + +    @property +    def status(self): +        if self.state not in IMPORT_GROUP_STATE_DCT: +            return "" +        return IMPORT_GROUP_STATE_DCT[self.state] +  class Import(BaseImport):      importer_type = models.ForeignKey(ImporterType, on_delete=models.CASCADE, diff --git a/ishtar_common/templates/ishtar/import_table.html b/ishtar_common/templates/ishtar/import_table.html index df58cb6e2..aec59babc 100644 --- a/ishtar_common/templates/ishtar/import_table.html +++ b/ishtar_common/templates/ishtar/import_table.html @@ -42,7 +42,7 @@ $("#import-list").find('input').prop('disabled', true);                  {{import.name|default:"-"}}              </td>              <td> -                {{import.importer_type}} ({% trans import.importer_type.type_label %}) +                {{import.importer_type}} ({% if import.importer_type.type_label %}{% trans import.importer_type.type_label %}{% else %}{% trans "Group" %}{% endif %})              </td>              <td>                  {% if import.imported_file %} diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 31d3d9516..2beade02d 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -1527,11 +1527,15 @@ class ImportListView(IshtarMixin, LoginRequiredMixin, ListView):      current_url = "current_imports"      def get_queryset(self): -        q = self.model.objects.exclude(state="AC") -        if self.request.user.is_superuser: -            return q.order_by("-pk") -        user = models.IshtarUser.objects.get(pk=self.request.user.pk) -        return q.filter(user=user).order_by("-pk") +        q1 = self.model.objects.exclude(state="AC") +        q2 = models.ImportGroup.objects.exclude(state="AC") +        if not self.request.user.is_superuser: +            user = models.IshtarUser.objects.get(pk=self.request.user.pk) +            q1 = q1.filter(user=user) +            q2 = q2.filter(user=user) +        q1 = q1.order_by("-creation_date", "-pk") +        q2 = q2.order_by("-creation_date", "-pk") +        return reversed(sorted(list(q1) + list(q2), key=lambda x: x.creation_date))      def post(self, request, *args, **kwargs):          for field in request.POST: @@ -1597,7 +1601,7 @@ class ImportListView(IshtarMixin, LoginRequiredMixin, ListView):          return HttpResponseRedirect(reverse(self.current_url))      def get_context_data(self, **kwargs): -        dct = super(ImportListView, self).get_context_data(**kwargs) +        dct = super().get_context_data(**kwargs)          dct.update({              "autorefresh_available": settings.USE_BACKGROUND_TASK,              "has_import_table": models.ImporterType.objects.filter(available=True, is_import=True, type='tab').count(), | 
