use f_id as e_r_num - rename files add f_type - README
This commit is contained in:
parent
4a35900bf5
commit
d3885c47d9
15
README.md
15
README.md
|
@ -1,7 +1,11 @@
|
|||
# Lodur Einsatzapp
|
||||
# From Mail to Lodur - all automated
|
||||
|
||||
"Loki - Nordischer Gott des Feuers"
|
||||
|
||||
This app helps a Feuerwehr Fourier from the Canton of Zurich
|
||||
in Switzerland to ease the pain of the huge work for getting
|
||||
Einsätze correctly into [Lodur](https://www.lodur.ch/lodur.html).
|
||||
|
||||
## Idea
|
||||
|
||||
* Get mails sent by ELZ with subjects
|
||||
|
@ -16,13 +20,16 @@
|
|||
|
||||
### Version 1
|
||||
|
||||
* Lodur Connect
|
||||
* Fill in Einsatzprotokoll data
|
||||
* Much more error handling
|
||||
* Parse PDF
|
||||
* Store parsed data in Lodur text fields for copy/paste
|
||||
* Cleanup code into proper functions and classes
|
||||
* Lodur "API" class
|
||||
* Proper exit
|
||||
* Healthchecks for Kubernetes probes
|
||||
|
||||
Before version 1 can be tagged, it must have processed at least 5 real
|
||||
Einsätze!
|
||||
|
||||
### Known instabilities
|
||||
|
||||
|
@ -37,7 +44,7 @@
|
|||
* Webapp to see what's going on
|
||||
* Get as many data out of the PDFs as possible
|
||||
* Simple webform to fill-in missing data (skipping Lodur completely)
|
||||
* Webapp for chosing who was there during the Einsatz
|
||||
* Webapp for chosing who was there during the Einsatz (tablet ready)
|
||||
|
||||
## Lodur Information Gathering
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ def create_einsatzrapport(username, password, base_url, f_id):
|
|||
)
|
||||
|
||||
data = {
|
||||
'e_r_num': (None, '1'), # 01. Einsatzrapportnummer
|
||||
'e_r_num': (None, f_id), # 01. Einsatzrapportnummer
|
||||
'eins_stat_kantone': (None, '1'), # 02. Einsatzart FKS
|
||||
'emergency_concept_id': (None, '2'), # 03. Verrechnungsart
|
||||
'ver_sart': (None, 'ab'), # 03. Verrechnungsart internal: ab, th, uh, ak, tt
|
||||
|
|
6
main.py
6
main.py
|
@ -87,8 +87,10 @@ def store_attachments(imap, msg_ids):
|
|||
logger.info('Extracting attachment: ' + file_name)
|
||||
|
||||
if bool(file_name):
|
||||
f_type, f_id = parse_subject(subject)
|
||||
renamed_file_name = f_type + '_' + file_name
|
||||
# save attachment to filesystem
|
||||
file_path = os.path.join(tmp_dir, file_name)
|
||||
file_path = os.path.join(tmp_dir, renamed_file_name)
|
||||
|
||||
logger.info('Saving attachment to ' + file_path)
|
||||
if not os.path.isfile(file_path):
|
||||
|
@ -96,7 +98,7 @@ def store_attachments(imap, msg_ids):
|
|||
file.write(part.get_payload(decode=True))
|
||||
file.close()
|
||||
|
||||
data[subject] = file_name
|
||||
data[subject] = renamed_file_name
|
||||
|
||||
# mark as seen
|
||||
imap.store(msg_id, '+FLAGS', '(\\Seen)')
|
||||
|
|
Loading…
Reference in New Issue