timApp.upload package#

Submodules#

timApp.upload.upload module#

class timApp.upload.upload.AttachmentModel(issueNumber: int | str, attachmentLetter: str, uploadUrl: str, upToDate: bool | None = None)[source]#

Bases: object

attachmentLetter: str#
issueNumber: int | str#
upToDate: bool | None = None#
uploadUrl: str#
class timApp.upload.upload.RestampModel(attachments: list[timApp.upload.upload.AttachmentModel], meetingDate: str, stampFormat: str | None = None, customStampModel: str | None = None)[source]#

Bases: object

attachments: list[timApp.upload.upload.AttachmentModel]#
customStampModel: str | None = None#
meetingDate: str#
stampFormat: str | None = None#
timApp.upload.upload.add_csp_if_not_pdf(resp: flask.wrappers.Response, mime: str, value: str = 'sandbox')[source]#
timApp.upload.upload.allowed_file(filename)[source]#
timApp.upload.upload.convert_pdf_or_compress_image(f: timApp.upload.uploadedfile.UploadedFile, u: timApp.user.user.User, d: timApp.document.docinfo.DocInfo, task_id: str)[source]#
timApp.upload.upload.get_file(file_id, file_filename)[source]#
timApp.upload.upload.get_image(image_id, image_filename)[source]#
timApp.upload.upload.get_pluginupload(relfilename: str) tuple[str, timApp.upload.uploadedfile.PluginUpload][source]#
timApp.upload.upload.get_upload(relfilename: str)[source]#
timApp.upload.upload.pluginupload_file(doc_id: int, task_id: str)[source]#
timApp.upload.upload.pluginupload_file2(doc_id: int, task_id: str, user_id)[source]#
timApp.upload.upload.restamp_attachments(args: timApp.upload.upload.RestampModel)[source]#

Route for updating stamps for one or more uploaded attachments. :return: Ok response or an error in stamping process.

timApp.upload.upload.save_file_and_grant_access(d: timApp.document.docinfo.DocInfo, content, file, block_type: timApp.item.block.BlockType) timApp.upload.uploadedfile.UploadedFile[source]#
timApp.upload.upload.set_csp(resp: flask.wrappers.Response)[source]#
timApp.upload.upload.upload_and_stamp_attachment(d: timApp.document.docinfo.DocInfo, file, stamp_data: timApp.util.pdftools.AttachmentStampData, stampformat: str, custom_stamp_model_content: Optional[str] = None)[source]#

Uploads the file and makes a stamped version of it into the same folder.

Parameters
  • d – Document info.

  • file – The file to upload and stamp.

  • stamp_data – Stamp data object (attachment and list ids) without the path.

  • stampformat – Formatting of stamp text.

  • custom_stamp_model_content – LaTeX-string for a custom stamp.

Returns

Json response containing the stamped file path.

timApp.upload.upload.upload_document(folder, file)[source]#
timApp.upload.upload.upload_file()[source]#
timApp.upload.upload.upload_image_or_file(d: timApp.document.docinfo.DocInfo, file)[source]#

timApp.upload.uploadedfile module#

class timApp.upload.uploadedfile.PluginUpload(b: timApp.item.block.Block)[source]#

Bases: timApp.upload.uploadedfile.UploadedFile

A file that is associated with an Answer.

property filename#
property relative_filesystem_path: pathlib.Path#
class timApp.upload.uploadedfile.PluginUploadInfo(task_id_name: str, doc: timApp.document.docinfo.DocInfo, user: timApp.user.user.User)[source]#

Bases: NamedTuple

Additional information required for saving a PluginUpload.

doc: timApp.document.docinfo.DocInfo#

Alias for field number 1

task_id_name: str#

Alias for field number 0

user: timApp.user.user.User#

Alias for field number 2

class timApp.upload.uploadedfile.StampedPDF(b: timApp.item.block.Block)[source]#

Bases: timApp.upload.uploadedfile.UploadedFile

property filename#
class timApp.upload.uploadedfile.UploadedFile(b: timApp.item.block.Block)[source]#

Bases: timApp.item.item.ItemBase

A file that has been uploaded by a user.

property base_path#
property block_type#
property content_mimetype#
property data#
property filename#
property filesystem_path#
static find_by_id(block_id: int) Optional[timApp.upload.uploadedfile.UploadedFile][source]#
static get_by_id_and_filename(file_id: int, filename: str) Optional[Union[timApp.upload.uploadedfile.UploadedFile, timApp.upload.uploadedfile.StampedPDF]][source]#

Get uploaded file or its stamped version in case file name differs (i.e. it has “_stamped” in it).

Parameters
  • file_id – File id.

  • filename – File name, which may contain “_stamped”.

Returns

UploadedFile, StampedPDF, or None, if neither was found.

static get_by_url(url: str) Optional[timApp.upload.uploadedfile.UploadedFile][source]#

Get file matching the given URL string.

Parameters

url – File url as a string.

Returns

UploadedFile, StampedPDF, or None, if neither was found.

property id#

Returns the item id.

property is_content_pdf#
property relative_filesystem_path#
classmethod save_new(file_filename: str, block_type: timApp.item.block.BlockType, file_data: Optional[bytes] = None, original_file: Optional[pathlib.Path] = None, upload_info: Optional[timApp.upload.uploadedfile.PluginUploadInfo] = None) timApp.upload.uploadedfile.UploadedFile[source]#
property size#
timApp.upload.uploadedfile.get_mimetype(p)[source]#
timApp.upload.uploadedfile.get_storage_path(block_type: timApp.item.block.BlockType)[source]#

Gets the storage path for the given block type.

Parameters

block_type – The block type.

Returns

The storage path.

Module contents#