Skip to content
Snippets Groups Projects
Verified Commit 8e3f8149 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Add error handling for PDF generation view

parent 40631c19
No related branches found
No related tags found
1 merge request!5Resolve "Allow editing layout"
Pipeline #72102 failed
...@@ -105,13 +105,20 @@ class CardPrintView(PermissionRequiredMixin, RevisionMixin, SingleObjectMixin, V ...@@ -105,13 +105,20 @@ class CardPrintView(PermissionRequiredMixin, RevisionMixin, SingleObjectMixin, V
printer = self.request.GET.get("printer") printer = self.request.GET.get("printer")
printer = get_object_or_404(CardPrinter, pk=printer) printer = get_object_or_404(CardPrinter, pk=printer)
self.object.print_card(printer) try:
messages.success( job = self.object.print_card(printer)
request, messages.success(
_( request,
"The print job for the card {} on the printer {} has been created successfully." _(
).format(self.object.person, printer.name), "The print job #{} for the card {} on "
) "the printer {} has been created successfully."
).format(job.pk, self.object.person, printer.name),
)
except ValueError as e:
messages.error(
request,
_("The print job couldn't be started because of the following error: {}").format(e),
)
return redirect(self.success_url) return redirect(self.success_url)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment