intranet.apps.printing package¶
Submodules¶
intranet.apps.printing.admin module¶
intranet.apps.printing.forms module¶
- class intranet.apps.printing.forms.PrintJobForm(*args, **kwargs)[source]¶
Bases:
ModelForm
- declared_fields = {'file': <django.forms.fields.FileField object>, 'page_range': <django.forms.fields.RegexField object>, 'printer': <django.forms.fields.ChoiceField object>}¶
intranet.apps.printing.models module¶
- class intranet.apps.printing.models.PrintJob(*args, **kwargs)[source]¶
Bases:
Model
Represents a submitted print job to Ion printing.
- user¶
The user submitting the job.
- Type:
User
- file¶
The file that the user submitted.
- Type:
File
- time¶
The time the job was submitted.
- Type:
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- duplex¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- file¶
The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:
>>> from myapp.models import MyModel >>> instance = MyModel.objects.get(pk=1) >>> instance.file.size
Assign a file object on assignment so you can do:
>>> with open('/path/to/hello.world') as f: ... instance.file = File(f)
- fit¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_time(*, field=<django.db.models.fields.DateTimeField: time>, is_next=True, **kwargs)¶
- get_previous_by_time(*, field=<django.db.models.fields.DateTimeField: time>, is_next=False, **kwargs)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- num_pages¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>¶
- page_range¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- printed¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- printer¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- time¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- user¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- user_id¶
intranet.apps.printing.tests module¶
- class intranet.apps.printing.tests.PrintingTest(methodName='runTest')[source]¶
Bases:
IonTestCase
intranet.apps.printing.urls module¶
intranet.apps.printing.views module¶
- exception intranet.apps.printing.views.InvalidInputPrintingError[source]¶
Bases:
Exception
An error occurred while printing, but it was due to invalid input from the user and is not worthy of a
CRITICAL
log message.
- exception intranet.apps.printing.views.RatelimitCacheError[source]¶
Bases:
Exception
An error occurred while accessing the cache to rate limit a user
- exception intranet.apps.printing.views.RatelimitExceededError[source]¶
Bases:
Exception
An error occurred because the user exceeded the printing rate limit
- intranet.apps.printing.views.check_page_range(page_range: str, max_pages: int) Optional[int] [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) Optional[str] [source]¶
- intranet.apps.printing.views.convert_pdf(tmpfile_name: str, cmdname: str = 'ps2pdf') Optional[str] [source]¶
- intranet.apps.printing.views.convert_soffice(tmpfile_name: str) Optional[str] [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_printers() Dict[str, 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 for available printers.
- Return type:
A dictionary mapping name