From f58aa8293e992f8a666823f81df8d99af5cd4ef6 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 12 Aug 2019 16:33:46 +0200 Subject: Import - match form: only display 250 first matches --- ishtar_common/views.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'ishtar_common/views.py') diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 8b4d212a7..f867a03cf 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -1606,16 +1606,28 @@ class ImportLinkView(IshtarMixin, LoginRequiredMixin, ModelFormSetView): } form_class = forms.TargetKeyForm formset_class = forms.TargetKeyFormset + max_fields = 250 def get_formset_kwargs(self): kwargs = super(ImportLinkView, self).get_formset_kwargs() kwargs['user'] = self.request.user return kwargs - def get_queryset(self): + def full_queryset(self): return self.model.objects.filter( is_set=False, associated_import=self.kwargs['pk']) + def get_queryset(self): + return self.full_queryset()[:self.max_fields] + + def get_context_data(self, **kwargs): + data = super().get_context_data(**kwargs) + total = self.full_queryset().count() + if total > self.max_fields: + data['MAX_FIELDS_REACHED'] = self.max_fields + data['TOTAL'] = total + return data + def get_success_url(self): return reverse('import_link_unmatched', args=[self.kwargs['pk']]) -- cgit v1.2.3