Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(printing): attribute error when requesting print job #1715

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions intranet/apps/printing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,21 @@ def print_job(obj: PrintJob, do_print: bool = True):
if obj.page_range:
if not range_count:
raise InvalidInputPrintingError("You specified an invalid page range.")
elif range_count > settings.PRINTING_PAGES_LIMIT:
elif range_count > settings.PRINTING_PAGES_LIMIT_TEACHERS and (obj.user.is_teacher or obj.user.is_printing_admin):
raise InvalidInputPrintingError(
f"You specified a range of {range_count} pages. You may only print up to {settings.PRINTING_PAGES_LIMIT} pages using this tool."
f"You specified a range of {range_count} pages. "
f"You may only print up to {settings.PRINTING_PAGES_LIMIT_TEACHERS} pages using this tool."
)
elif num_pages > settings.PRINTING_PAGES_LIMIT:

elif range_count > settings.PRINTING_PAGES_LIMIT_STUDENTS:
raise InvalidInputPrintingError(
f"You specified a range of {range_count} pages. "
f"You may only print up to {settings.PRINTING_PAGES_LIMIT_STUDENTS} pages using this tool."
)

elif num_pages > settings.PRINTING_PAGES_LIMIT_TEACHERS and (obj.user.is_teacher or obj.user.is_printing_admin):
raise InvalidInputPrintingError(
f"This file contains {num_pages} pages. You may only print up to {settings.PRINTING_PAGES_LIMIT} pages using this tool."
f"This file contains {num_pages} pages. " f"You may only print up to {settings.PRINTING_PAGES_LIMIT_TEACHERS} pages using this tool."
)

elif num_pages > settings.PRINTING_PAGES_LIMIT_STUDENTS:
Expand Down
Loading