lazyflat/apply/providers/stadtundland.py
Moritz 7444f90d6a per-step screenshot + html snapshots, matches-only list, full German UI, CSV export
* apply: Recorder.step_snap(page, name) captures both a JPEG screenshot and
  the page HTML for every major moment; every provider now calls step_snap at
  each logical step so failure reports contain the exact DOM and rendered
  state at every stage of the flow
* ZIP report: each snapshot becomes snapshots/NN_<label>.jpg +
  snapshots/NN_<label>.html for AI-assisted debugging
* web: Wohnungsliste zeigt nur noch Flats, die die eigenen Filter treffen;
  Match-Chip entfernt (Liste ist jetzt implizit matchend)
* UI komplett auf Deutsch: Protokoll statt Logs, Administrator statt admin,
  Trockenmodus statt dry-run, Automatik pausiert statt circuit open,
  Alarm statt Alert, Abmelden statt Logout
* Wohnungen-Header: Zeile 1 Info (Alarm + Filter), Zeile 2 Schalter mit
  echten Radio-Paaren (An/Aus) für Automatisch bewerben und Trockenmodus;
  hx-confirm auf den kritischen Radios; per-form CSS für sichtbaren Check-State
* Protokoll: von/bis-Datumsfilter (Berliner Zeit) + CSV-Download
  (/logs/export.csv) mit UTC + lokaler Zeit

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 11:40:12 +02:00

58 lines
2.6 KiB
Python

import logging
from actions import open_page
from classes.application_result import ApplicationResult
from language import _
from providers._provider import ApplyContext, Provider
logger = logging.getLogger("flat-apply")
class Stadtundland(Provider):
@property
def domain(self) -> str:
return "stadtundland.de"
async def apply_for_flat(self, url: str, ctx: ApplyContext) -> ApplicationResult:
r = ctx.recorder
p = ctx.profile
async with open_page(url, recorder=r) as page:
await r.step_snap(page, "cookies.check")
cookie_accept_btn = page.get_by_text("Alle akzeptieren")
if await cookie_accept_btn.is_visible():
await cookie_accept_btn.click()
await r.step_snap(page, "cookies.accepted")
await r.step_snap(page, "page.offline_check")
if await page.get_by_role("heading", name="Hier ist etwas schief gelaufen").is_visible():
await r.step_snap(page, "abort.offline", status="warn")
return ApplicationResult(False, message=_("ad_offline"))
await r.step_snap(page, "form.fill")
await page.locator("#name").fill(p.firstname)
await page.locator("#surname").fill(p.lastname)
await page.locator("#street").fill(p.street)
await page.locator("#houseNo").fill(p.house_number)
await page.locator("#postalCode").fill(p.postcode)
await page.locator("#city").fill(p.city)
await page.locator("#phone").fill(p.telephone)
await page.locator("#email").fill(p.email)
await page.locator("#privacy").check()
await page.locator("#provision").check()
await r.step_snap(page, "form.filled")
if not ctx.submit_forms:
await r.step_snap(page, "submit.dry_run")
return ApplicationResult(True, _("application_success_dry"))
await r.step_snap(page, "submit.review")
await page.get_by_role("button", name="Eingaben prüfen").click()
await r.step_snap(page, "submit.send")
await page.get_by_role("button", name="Absenden").click()
await page.wait_for_timeout(2000)
await r.step_snap(page, "success.check")
if await page.locator("p").filter(has_text="Vielen Dank!").is_visible():
return ApplicationResult(True)
await r.step_snap(page, "success.not_found", status="warn")
return ApplicationResult(success=False, message=_("submit_conformation_msg_not_found"))