diff --git a/printer/forms.py b/printer/forms.py index 7c3d1d50..a1dab8ed 100644 --- a/printer/forms.py +++ b/printer/forms.py @@ -51,8 +51,11 @@ class PrintAgainForm(JobWithOptionsForm): user=kwargs.get('user') super(PrintAgainForm, self).__init__(*args, **kwargs) if 'printAs' in self.fields: - self.fields['printAs'].queryset = User.objects.filter(club__in=user.adherent.club_members.all()) | User.objects.filter(pseudo='dstan') - + self.fields['printAs'].empty_label = user.pseudo + if self.instance.user != user: + self.fields['printAs'].queryset = User.objects.filter(club__in=user.adherent.club_members.all()) | User.objects.filter(id=self.instance.user.id) + else: + self.fields['printAs'].queryset = user.adherent.club_members.all() class Meta: model = JobWithOptions diff --git a/printer/templates/printer/aff_jobs.html b/printer/templates/printer/aff_jobs.html index 5eb2f44c..6bcd2b0d 100644 --- a/printer/templates/printer/aff_jobs.html +++ b/printer/templates/printer/aff_jobs.html @@ -41,7 +41,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% can_view job %} {{ job.filename }} - {{ job.user }} {% if job.user != job.printAs %} {% trans "for" %} {{ job.printAs }}{% endif %} + {{ job.user }} {% if job.printAs %} {% trans "for" %} {{ job.printAs }}{% endif %} {{ job.starttime }} {{ job.status }} {{ job.count }} diff --git a/printer/views.py b/printer/views.py index 6b98b24c..3d7690ee 100644 --- a/printer/views.py +++ b/printer/views.py @@ -67,7 +67,6 @@ def new_job(request): job_instance.filename = filename job_instance.print_operation = print_operation job_instance.user=request.user - job_instance.printAs = job.cleaned_data.get('printAs', request.user) metadata = pdfinfo(request.FILES['form-%s-file' % count].temporary_file_path()) job_instance.pages = metadata["Pages"] job_instance.save() @@ -155,10 +154,10 @@ def payment(request, jobs): users = {} for job in jobs: try: - users[job.printAs][0]+=job.price - users[job.printAs][1].append(job.id) + users[job.printAs or job.user][0]+=job.price + users[job.printAs or job.user][1].append(job.id) except KeyError: - users[job.printAs]=[job.price, [job.id]] + users[job.printAs or job.user]=[job.price, [job.id]] balancePayment = BalancePayment.objects.get() minimum_balance = balancePayment.minimum_balance