add gewobag form

This commit is contained in:
Aron Petau 2026-01-05 19:08:39 +01:00
parent bc06db593b
commit a072899cfd

View file

@ -180,27 +180,45 @@ class GewobagHandler(BaseHandler):
except Exception as e: except Exception as e:
logger.warning(f"[GEWOBAG] Could not fill Ort: {e}") logger.warning(f"[GEWOBAG] Could not fill Ort: {e}")
# Anzahl der einziehenden Erwachsenen # Gesamtzahl der einziehenden Personen (Erwachsene + Kinder) - REQUIRED
try: try:
anzahl_erwachsene = os.environ.get("FORM_ADULTS", "1") anzahl_erwachsene = int(os.environ.get("FORM_ADULTS", "1"))
adults_input = await iframe_page.query_selector('#formly_3_input_gewobag_anzahl_erwachsene_0') anzahl_kinder = int(os.environ.get("FORM_CHILDREN", "0"))
if adults_input: total_persons = str(anzahl_erwachsene + anzahl_kinder)
await adults_input.fill(anzahl_erwachsene) total_input = await iframe_page.query_selector('#formly_2_input_gewobag_gesamtzahl_der_einziehenden_personen_erwachsene_und_kinder_0')
logger.info(f"[GEWOBAG] Filled Anzahl Erwachsene: {anzahl_erwachsene}") if total_input:
await total_input.fill(total_persons)
logger.info(f"[GEWOBAG] Filled Gesamtzahl Personen: {total_persons}")
form_filled = True form_filled = True
except Exception as e: except Exception as e:
logger.warning(f"[GEWOBAG] Could not fill Anzahl Erwachsene: {e}") logger.warning(f"[GEWOBAG] Could not fill Gesamtzahl Personen: {e}")
# Anzahl der einziehenden Kinder # "Für wen wird die Wohnungsanfrage gestellt?" dropdown - REQUIRED
# Select "für mich selbst" (for myself)
try: try:
anzahl_kinder = os.environ.get("FORM_CHILDREN", "0") dropdown_input = await iframe_page.query_selector('#formly_9_select_gewobag_fuer_wen_wird_die_wohnungsanfrage_gestellt_0')
children_input = await iframe_page.query_selector('#formly_3_input_gewobag_anzahl_kinder_1') if dropdown_input:
if children_input: await dropdown_input.click()
await children_input.fill(anzahl_kinder) await iframe_page.wait_for_timeout(300)
logger.info(f"[GEWOBAG] Filled Anzahl Kinder: {anzahl_kinder}") # Select the first option "für mich selbst"
for_myself_option = await iframe_page.query_selector('.ng-option:has-text("für mich selbst")')
if for_myself_option:
await for_myself_option.click()
logger.info("[GEWOBAG] Selected 'für mich selbst'")
form_filled = True form_filled = True
except Exception as e: except Exception as e:
logger.warning(f"[GEWOBAG] Could not fill Anzahl Kinder: {e}") logger.warning(f"[GEWOBAG] Could not select 'für wen' dropdown: {e}")
# Mobilfunknummer (Mobile phone) - REQUIRED
try:
mobile_phone = os.environ.get("FORM_PHONE", "")
mobile_input = await iframe_page.query_selector('#formly_17_input_$$_telephone_number_$$_0')
if mobile_input:
await mobile_input.fill(mobile_phone)
logger.info(f"[GEWOBAG] Filled Mobilfunknummer: {mobile_phone}")
form_filled = True
except Exception as e:
logger.warning(f"[GEWOBAG] Could not fill Mobilfunknummer: {e}")
# WBS (Wohnberechtigungsschein) - Click "Ja" radio button # WBS (Wohnberechtigungsschein) - Click "Ja" radio button
try: try:
@ -212,25 +230,15 @@ class GewobagHandler(BaseHandler):
except Exception as e: except Exception as e:
logger.warning(f"[GEWOBAG] Could not select WBS: {e}") logger.warning(f"[GEWOBAG] Could not select WBS: {e}")
# Privacy checkbox 1 (WBS data consent) # Privacy checkbox (Main Datenschutzbestimmungen) - REQUIRED
try: try:
privacy_checkbox_1 = await iframe_page.query_selector('#formly_20_checkbox_gewobag_datenschutzhinweis_iv0027_bestaetigt_0') privacy_checkbox = await iframe_page.query_selector('#formly_20_checkbox_gewobag_datenschutzhinweis_bestaetigt_0')
if privacy_checkbox_1: if privacy_checkbox:
await privacy_checkbox_1.check() await privacy_checkbox.check()
logger.info("[GEWOBAG] Checked privacy checkbox 1 (WBS data consent)") logger.info("[GEWOBAG] Checked privacy checkbox (Datenschutzbestimmungen)")
form_filled = True form_filled = True
except Exception as e: except Exception as e:
logger.warning(f"[GEWOBAG] Could not check privacy checkbox 1: {e}") logger.warning(f"[GEWOBAG] Could not check privacy checkbox: {e}")
# Privacy checkbox 2 (Main Datenschutzbestimmungen)
try:
privacy_checkbox_2 = await iframe_page.query_selector('#formly_21_checkbox_gewobag_datenschutzhinweis_bestaetigt_0')
if privacy_checkbox_2:
await privacy_checkbox_2.check()
logger.info("[GEWOBAG] Checked privacy checkbox 2 (Datenschutzbestimmungen)")
form_filled = True
except Exception as e:
logger.warning(f"[GEWOBAG] Could not check privacy checkbox 2: {e}")
await asyncio.sleep(1) await asyncio.sleep(1)