From 663ade97650ce0088513c1e9fc4c3c5315112d8e Mon Sep 17 00:00:00 2001 From: Maxime Bombar Date: Sun, 21 Oct 2018 19:48:10 +0200 Subject: [PATCH] [Printer] Fix major bug. See below for more explanations : Before, I used request.session to store some information about the current jobs to be printed. This was because in the very beginning, I had an issue with disappearing files in my model. I was able to fix this issue in a previous commit, but I still needed the jids. However, because of this storage system, if someone tried to print a file, then oppened a second tab, and tried to print anoter file, he/she would pay twice for the second file .... I decided to add a hidden field to store the job id and deal with it, and it is readonly to avoid changing it. --- printer/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/printer/views.py b/printer/views.py index 0c340824..14c086e3 100644 --- a/printer/views.py +++ b/printer/views.py @@ -59,8 +59,6 @@ def new_job(request): form_kwargs={'user': request.user}, ) - - if job_formset.is_valid(): data = [] i=0 @@ -86,7 +84,9 @@ def new_job(request): i+=1 job_formset_filled_in = formset_factory(PrintForm, extra=0)( initial=data, - form_kwargs={'user': request.user}, + # jids=jids, + form_kwargs={'user': request.user, + }, ) if job_formset.total_error_count() == 0: @@ -150,6 +150,7 @@ def new_job(request): ### GET request else: + # raise Exception("Coucou2") job_formset = formset_factory(JobWithOptionsForm)( form_kwargs={'user': request.user} )