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 ++-- version.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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("/") diff --git a/version.txt b/version.txt index 6239158..78ab950 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ version=0.6 -rev=3 +rev=4 -- cgit v1.2.1