From 4a763d7b4b5d9694ac6a9c72cff794a5fb86b7f2 Mon Sep 17 00:00:00 2001 From: Andrea Lepori Date: Tue, 13 Sep 2022 19:31:23 +0200 Subject: permit multiple documents of the same type --- client/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/views.py b/client/views.py index deeb93c..4cb3d3d 100644 --- a/client/views.py +++ b/client/views.py @@ -130,7 +130,7 @@ def create(request): filter = filter & Q(staff_only=False) # remove from the list documents from already used types - doctypes = DocumentType.objects.filter(filter).values_list("id", flat=True).difference(Document.objects.filter(user=request.user).select_related("document_type").values_list("document_type", flat=True)) + doctypes = DocumentType.objects.filter(filter).values_list("id", flat=True).difference(Document.objects.filter(Q(user=request.user) & ~Q(status="archive")).select_related("document_type").values_list("document_type", flat=True)) context['docs'] = DocumentType.objects.filter(id__in=doctypes) if request.method == "POST": @@ -183,7 +183,7 @@ def create(request): return HttpResponseRedirect("/") # get list of docs with that type - current_docs = Document.objects.filter(user=request.user).filter(document_type=document_type) + current_docs = Document.objects.filter(user=request.user).filter(Q(document_type=document_type) & ~Q(status="archive")) if len(current_docs) > 0: # if there is already a document with that type abort (user is cheating) return HttpResponseRedirect("/") -- cgit v1.2.1