aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Lepori <alepori@student.ethz.ch>2020-08-30 15:12:29 +0200
committerAndrea Lepori <alepori@student.ethz.ch>2020-08-30 15:12:29 +0200
commit0fbe45eb55801d41caa5ec55da87350234ae3ba1 (patch)
treeaa80b0d963c50314e4e71f2b29730481eb9a31c9
parentgenerate file progressbar (diff)
downloadscout-subs-0fbe45eb55801d41caa5ec55da87350234ae3ba1.tar.gz
scout-subs-0fbe45eb55801d41caa5ec55da87350234ae3ba1.zip
more reliable generation progress
-rw-r--r--server/views.py9
1 files changed, 2 insertions, 7 deletions
diff --git a/server/views.py b/server/views.py
index e8fbe8b..c585d8b 100644
--- a/server/views.py
+++ b/server/views.py
@@ -791,7 +791,7 @@ def doclist(request):
if request.method == "POST":
if request.POST["action"] == "download" and len(selected) > 0:
code = request.user.username + "_" + str(random.randint(100, 999))
- progress[code] = [0, 0, False, request.user, None]
+ progress[code] = [0, len(selected), False, request.user, None]
threading.Thread(target=zip_documents, args=(selected, code)).start()
context["task_id"] = code
@@ -816,10 +816,6 @@ def get_progress(request):
def zip_documents(docs, code):
files = []
- total = len(docs)
- status = 0
- progress[code][0] = status
- progress[code][1] = total
for i in docs:
vac_file = ""
health_file = ""
@@ -852,8 +848,7 @@ def zip_documents(docs, code):
pdf = pdfkit.from_string(html, False)
filename = i.user.username+"_"+i.document_type.name+".pdf"
files.append((filename, pdf))
- status += 1
- progress[code][0] = status
+ progress[code][0] += 1
mem_zip = BytesIO()