8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-24 20:33:11 +00:00

[Printer] Fix prinas None crash

This commit is contained in:
detraz 2018-10-27 05:29:13 +02:00 committed by root
parent 10f24f4591
commit aa2b79bd87
3 changed files with 9 additions and 7 deletions

View file

@ -51,8 +51,11 @@ class PrintAgainForm(JobWithOptionsForm):
user=kwargs.get('user') user=kwargs.get('user')
super(PrintAgainForm, self).__init__(*args, **kwargs) super(PrintAgainForm, self).__init__(*args, **kwargs)
if 'printAs' in self.fields: 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: class Meta:
model = JobWithOptions model = JobWithOptions

View file

@ -41,7 +41,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% can_view job %} {% can_view job %}
<tr> <tr>
<td>{{ job.filename }}</td> <td>{{ job.filename }}</td>
<td>{{ job.user }} {% if job.user != job.printAs %} {% trans "for" %} {{ job.printAs }}{% endif %}</td> <td>{{ job.user }} {% if job.printAs %} {% trans "for" %} {{ job.printAs }}{% endif %}</td>
<td>{{ job.starttime }}</td> <td>{{ job.starttime }}</td>
<td>{{ job.status }}</td> <td>{{ job.status }}</td>
<td>{{ job.count }}</td> <td>{{ job.count }}</td>

View file

@ -67,7 +67,6 @@ def new_job(request):
job_instance.filename = filename job_instance.filename = filename
job_instance.print_operation = print_operation job_instance.print_operation = print_operation
job_instance.user=request.user 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()) metadata = pdfinfo(request.FILES['form-%s-file' % count].temporary_file_path())
job_instance.pages = metadata["Pages"] job_instance.pages = metadata["Pages"]
job_instance.save() job_instance.save()
@ -155,10 +154,10 @@ def payment(request, jobs):
users = {} users = {}
for job in jobs: for job in jobs:
try: try:
users[job.printAs][0]+=job.price users[job.printAs or job.user][0]+=job.price
users[job.printAs][1].append(job.id) users[job.printAs or job.user][1].append(job.id)
except KeyError: except KeyError:
users[job.printAs]=[job.price, [job.id]] users[job.printAs or job.user]=[job.price, [job.id]]
balancePayment = BalancePayment.objects.get() balancePayment = BalancePayment.objects.get()
minimum_balance = balancePayment.minimum_balance minimum_balance = balancePayment.minimum_balance