translator_directory.generate_docx
Classes
InlineImage adds images to .docx files, but additional tweaking |
|
Functions
|
Fills the variables in a docx file with the given key-value pairs. |
|
Creates the word file. |
|
|
|
|
|
|
|
Parses information from the filename. The delimiter is '__'. |
The signature of the current user. It is an image that is manually |
Module Contents
- translator_directory.generate_docx.fill_docx_with_variables(original_docx: IO[bytes], t: onegov.translator_directory.models.translator.Translator, request: onegov.translator_directory.request.TranslatorAppRequest, signature_file: IO[bytes] | None = None, **kwargs: Any) tuple[dict[str, Any], bytes] [source]
- Fills the variables in a docx file with the given key-value pairs.
The original_docx template contains Jinja-Variables that map to keys in the template_variables dictionary.
- Returns A tuple containing two elements:
Variables that were found to be None or empty.
The rendered docx file (bytes).
- class translator_directory.generate_docx.FixedInplaceInlineImage(tpl, image_descriptor, width=None, height=None, anchor=None)[source]
Bases:
docxtpl.InlineImage
InlineImage adds images to .docx files, but additional tweaking was required for left margin alignment.
We determined the precise values needed for alignment by manually aligning the image within a .docx file, saving the changes, and then comparing the updated document’s XML with the previous version.
- translator_directory.generate_docx.render_docx(docx_template: docxtpl.DocxTemplate, template_variables: dict[str, Any]) bytes [source]
Creates the word file.
template_variables: dictionary of values to find and replace in final word file. Values not present are simply ignored.
- translator_directory.generate_docx.translator_functions(translator: onegov.translator_directory.models.translator.Translator) Iterator[str] [source]
- translator_directory.generate_docx.gendered_greeting(translator: onegov.translator_directory.models.translator.Translator) str [source]
- translator_directory.generate_docx.get_ticket_nr_of_translator(translator: onegov.translator_directory.models.translator.Translator, request: onegov.translator_directory.request.TranslatorAppRequest) str [source]
- translator_directory.generate_docx.parse_from_filename(abs_signature_filename: str) Signature [source]
Parses information from the filename. The delimiter is ‘__’.
This is kind of implicit here, information about the user is stored in the filename of the signature image of the user.
- translator_directory.generate_docx.signature_for_mail_templates(request: onegov.translator_directory.request.TranslatorAppRequest) onegov.org.models.GeneralFile | None [source]
The signature of the current user. It is an image that is manually uploaded. It should contain the string ‘Unterschrift’, as well as the first and last name of the user.