Aufgrund einer Störung des s3 Storage, könnten in nächster Zeit folgende GitLab Funktionen nicht zur Verfügung stehen: LFS, Container Registry, Job Artifacs, Uploads (Wiki, Bilder, Projekt-Exporte). Wir bitten um Verständnis. Es wird mit Hochdruck an der Behebung des Problems gearbeitet. Weitere Informationen zur Störung des Object Storage finden Sie hier:

Aufgrund einer Wartung wird GitLab am 03.08. zwischen 8:00 und 9:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 03.08. between 8:00 and 9:00 am.

Commit 0e8054d8 authored by LammLukas's avatar LammLukas
Browse files

Added protocol class with docx export

parent bff94528
Class for protocol objects
Author: L. Lamm (
from src.exam import Exam
from src.exceptions import *
from docxtpl import DocxTemplate
import re
class Protocol:
"""Class for objects of type protocol"""
def __init__(self, exam):
"""Constructor of protocol object"""
self.exam = exam
def make_protocol(self, file, doc_format='docx', lang='german'):
"""Exports protocol"""
if doc_format == 'docx':
self.make_docx_protocol(file, lang)
raise FormatNotDefined()
def make_docx_protocol(self, file, lang):
"""Export docx protocol from template"""
if lang == 'german':
doc = DocxTemplate("./templates/protocols/protocol_german_written.docx")
raise ProtocolTemplateDoesNotExist()
for room in self.exam.Rooms:
split_str = re.sub("\.docx$", '', file)
file_str = split_str + '_' + room.Name + '.docx'
if room.SupervisorInCharge is None:
supervisor = ''
supervisor = room.SupervisorInCharge
if room.ExtraSupervisors is None:
ex_supervisor = ''
ex_supervisor = room.SupervisorInCharge
context = {'COURSE': self.exam.Name,
'EXAMINER': self.exam.Examiner,
'DATE': self.exam.Date,
'ROOM': room.Name,
'SUPERVISOR': supervisor,
'EX_SUPERVISORS': ex_supervisor}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment