multi-user: users, per-user profiles/filters/notifications, tab UI, apply forensics
* DB: users + user_profiles/filters/notifications/preferences; applications gets user_id + forensics_json + profile_snapshot_json; new errors table with 14d retention; schema versioning via MIGRATIONS list * auth: password hashes in DB (argon2); env vars seed first admin; per-user sessions; CSRF bound to user id * apply: personal info/WBS moved out of env into the request body; providers take an ApplyContext with Profile + submit_forms; full Playwright recorder (step log, console, page errors, network, screenshots, final HTML) * web: five top-level tabs (Wohnungen/Bewerbungen/Logs/Fehler/Einstellungen); settings sub-tabs profil/filter/benachrichtigungen/account/benutzer; per-user matching, auto-apply and notifications (UI/Telegram/SMTP); red auto-apply switch on Wohnungen tab; forensics detail view for bewerbungen and fehler; retention background thread Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e663386a19
commit
c630b500ef
36 changed files with 2763 additions and 1113 deletions
|
|
@ -1,81 +1,69 @@
|
|||
from actions import *
|
||||
from language import _
|
||||
from classes.application_result import ApplicationResult
|
||||
from providers._provider import Provider
|
||||
from settings import *
|
||||
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 Gesobau(Provider):
|
||||
@property
|
||||
def domain(self) -> str:
|
||||
return "gesobau.de"
|
||||
|
||||
async def apply_for_flat(self, url) -> ApplicationResult:
|
||||
async with open_page(url) as page:
|
||||
logger.info("\tSTEP 1: extracting immomio link")
|
||||
async def apply_for_flat(self, url: str, ctx: ApplyContext) -> ApplicationResult:
|
||||
r = ctx.recorder
|
||||
p = ctx.profile
|
||||
if not (p.immomio_email and p.immomio_password):
|
||||
r.step("immomio_creds_missing", "warn")
|
||||
return ApplicationResult(False, _("missing_fields"))
|
||||
|
||||
async with open_page(url, recorder=r) as page:
|
||||
r.step("extract.immomio_link")
|
||||
immomio_link = await page.get_by_role("link", name="Jetzt bewerben").get_attribute("href")
|
||||
|
||||
logger.info("\tSTEP 2: going to auth page")
|
||||
await page.goto("https://tenant.immomio.com/de/auth/login")
|
||||
r.step("auth.goto"); await page.goto("https://tenant.immomio.com/de/auth/login")
|
||||
await page.wait_for_timeout(1000)
|
||||
|
||||
logger.info("\tSTEP 3: logging in")
|
||||
await page.locator('input[name="email"]').fill(IMMOMIO_EMAIL)
|
||||
r.step("auth.login")
|
||||
await page.locator('input[name="email"]').fill(p.immomio_email)
|
||||
await page.get_by_role("button", name="Anmelden").click()
|
||||
await page.wait_for_timeout(1000)
|
||||
await page.locator("#password").fill(IMMOMIO_PASSWORD)
|
||||
await page.locator("#password").fill(p.immomio_password)
|
||||
await page.locator("#kc-login").click()
|
||||
await page.wait_for_timeout(1000)
|
||||
|
||||
logger.info("\tSTEP 4: going back to immomio")
|
||||
r.step("back.to_immomio", detail=immomio_link or "")
|
||||
await page.goto(immomio_link)
|
||||
await page.wait_for_timeout(1000)
|
||||
|
||||
logger.info("\tSTEP 5: accepting cookies")
|
||||
r.step("cookies.check")
|
||||
cookie_accept_btn = page.get_by_role("button", name="Alle erlauben")
|
||||
if await cookie_accept_btn.is_visible():
|
||||
await cookie_accept_btn.click()
|
||||
logger.debug("\t\tcookie accept button clicked")
|
||||
else:
|
||||
logger.debug("\t\tno cookie accept button found")
|
||||
|
||||
logger.info("\tSTEP 6: click apply now")
|
||||
await page.get_by_role("button", name="Jetzt bewerben").click()
|
||||
r.step("apply.click"); await page.get_by_role("button", name="Jetzt bewerben").click()
|
||||
await page.wait_for_timeout(3000)
|
||||
|
||||
logger.info("\tSTEP 7: check if already applied")
|
||||
r.step("already_applied.check")
|
||||
if page.url == "https://tenant.immomio.com/de/properties/applications":
|
||||
return ApplicationResult(False, message=_("already_applied"))
|
||||
|
||||
logger.info("\tSTEP 8: clicking answer questions")
|
||||
r.step("answer_questions.click")
|
||||
answer_questions_btn = page.get_by_role("button", name="Fragen beantworten")
|
||||
if await answer_questions_btn.is_visible():
|
||||
await answer_questions_btn.click()
|
||||
logger.debug("\t\tanswer questions button clicked")
|
||||
await page.wait_for_timeout(2000)
|
||||
else:
|
||||
logger.debug("\t\tno answer questions button found")
|
||||
|
||||
if await answer_questions_btn.is_visible(): # sometimes this button must be clicked twice
|
||||
if await answer_questions_btn.is_visible():
|
||||
await answer_questions_btn.click()
|
||||
logger.debug("\t\tanswer questions button clicked")
|
||||
await page.wait_for_timeout(2000)
|
||||
|
||||
|
||||
logger.info("\tSTEP 9: verifying success by answer button vanishing")
|
||||
if not await answer_questions_btn.is_visible(): # TODO better verify success
|
||||
logger.info("\t\tsuccess detected by answer button vanishing")
|
||||
r.step("success.check")
|
||||
if not await answer_questions_btn.is_visible():
|
||||
return ApplicationResult(True)
|
||||
|
||||
logger.info("\t\tsubmit conformation not found")
|
||||
r.step("success.not_found", "warn")
|
||||
return ApplicationResult(False, _("submit_conformation_msg_not_found"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# url = "https://www.gesobau.de/?immo_ref=10-03239-00007-1185" # already applied
|
||||
# url = "https://www.gesobau.de/mieten/wohnungssuche/detailseite/florastrasse-10-12179-00002-1002-1d4d1a94-b555-48f8-b06d-d6fc02aecb0d/"
|
||||
url = "https://www.gesobau.de/mieten/wohnungssuche/detailseite/rolandstrasse-10-03020-00007-1052-7f47d893-e659-4e4f-a7cd-5dcd53f4e6d7/"
|
||||
provider = Gesobau()
|
||||
provider.test_apply(url)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue