43 lines
1.0 KiB
Python
43 lines
1.0 KiB
Python
from flask import render_template
|
|
|
|
TEMPLATE = 'components/modul_absperrung.html'
|
|
|
|
def get_formular_html():
|
|
return render_template(TEMPLATE)
|
|
|
|
def berechne(form_data):
|
|
positionen = []
|
|
tage = _int(form_data.get('tage', 1))
|
|
typ = form_data.get('absperr_typ', 'voll')
|
|
|
|
if typ == 'voll':
|
|
positionen.append({
|
|
'pos_nr': '10041001',
|
|
'kurztext': 'Vollsperrung einrichten',
|
|
'menge': tage,
|
|
'einheit': 'ST',
|
|
})
|
|
elif typ == 'teil':
|
|
positionen.append({
|
|
'pos_nr': '10041002',
|
|
'kurztext': 'Teilsperrung einrichten',
|
|
'menge': tage,
|
|
'einheit': 'ST',
|
|
})
|
|
|
|
if form_data.get('ampel') == 'an':
|
|
positionen.append({
|
|
'pos_nr': '10041003',
|
|
'kurztext': 'Baustellenampel',
|
|
'menge': tage,
|
|
'einheit': 'ST',
|
|
})
|
|
|
|
return positionen
|
|
|
|
def _int(val, default=0):
|
|
try:
|
|
return int(float(str(val).replace(',', '.')))
|
|
except (ValueError, TypeError):
|
|
return default
|