views

Functions

intranet.apps.printing.views.check_page_range(page_range: str, max_pages: int) int | None[source]

Returns the number of pages included in the range, or None if it is an invalid range.

Parameters:
  • page_range – The page range as a string, such as “1-5” or “1,2,3”.

  • max_pages – The number of pages in the submitted document. If the number of pages in the given range exceeds this, it will be considered invalid.

Returns:

The number of pages in the range, or None if it is an invalid range.

intranet.apps.printing.views.convert_file(tmpfile_name: str, orig_fname: str) str | None[source]
intranet.apps.printing.views.convert_pdf(tmpfile_name: str, cmdname: str = 'ps2pdf') str | None[source]
intranet.apps.printing.views.convert_soffice(tmpfile_name: str) str | None[source]

Converts a doc or docx to a PDF with soffice.

Parameters:

tmpfile_name – The path to the file to print.

Returns:

The path to the converted file. If it fails, false.

intranet.apps.printing.views.get_mimetype(tmpfile_name: str) str[source]
intranet.apps.printing.views.get_numpages(tmpfile_name: str) int[source]
intranet.apps.printing.views.get_printers() Dict[str, List[str]][source]

Returns a dictionary mapping name:description for available printers.

This requires that a CUPS client be configured on the server. Otherwise, this returns an empty dictionary.

Returns:

[description,alerts] for available printers.

Return type:

A dictionary mapping name

intranet.apps.printing.views.get_user_ratelimit_status(username: str) bool[source]
intranet.apps.printing.views.html_to_pdf(template_src, filename, context=None)[source]
intranet.apps.printing.views.parse_alerts(alerts: str) Tuple[str, str][source]
intranet.apps.printing.views.print_job(obj: PrintJob, do_print: bool = True)[source]
intranet.apps.printing.views.set_user_ratelimit_status(username: str) None[source]

Exceptions

InvalidInputPrintingError

An error occurred while printing, but it was due to invalid input from the user and is not worthy of a CRITICAL log message.

RatelimitCacheError

An error occurred while accessing the cache to rate limit a user

RatelimitExceededError

An error occurred because the user exceeded the printing rate limit