Commit graph

8 commits

Author SHA1 Message Date
2ebbf76a80 experiment: shade excluded Bezirke on map (faint yellow overlay)
Tints districts the user's Bezirk filter has EXCLUDED in light yellow
(#fde68a, fillOpacity 0.35) so the active selection is obvious from
the map alone — and you can see at a glance whether a "rausgefiltert"
flat fell in a no-go district. When no district filter is set the
overlay stays off entirely (nothing is excluded).

Wiring:
- Berlin Bezirke GeoJSON checked in at web/static/berlin-districts.geojson
  (12 features, name property matches our DISTRICTS list 1:1, props
  stripped down to {name} and minified — 312KB raw, ~80KB gzipped).
- Route exposes the user's selected_districts_csv to the template.
- The flats-map-data <script> carries it on data-selected-districts so
  it flows in alongside csrf and the marker payload.
- map.js fetches the GeoJSON once (cache normally), keeps the layer in
  a module-level reference, and re-styles it via setStyle() on every
  swap (cheap). Marker layer is kicked to the front so pins always
  paint above the shaded polygons. fingerprintOf now also folds in
  the selected-districts CSV so a Bezirk-only filter change still
  triggers a re-render.

Branch only — kept off main while we see if this reads well.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 13:30:30 +02:00
ee7ba6c6ff fix: round €/m² in Telegram, drop "Bilder nachladen" admin button, fix lightbox visibility
- notifications: round sqm_price to whole € in Telegram match messages
  (was emitting raw float like "12.345614 €/m²").

- wohnungen: remove the admin-only "Bilder nachladen (N)" button. It
  flickered into view whenever a freshly-scraped flat was still in
  pending state, which was effectively random from the user's point of
  view, and the manual backfill it triggered isn't needed anymore — new
  flats are auto-enriched at scrape time. Also drops the dead helpers
  it was the sole caller of: enrichment.kick_backfill,
  enrichment._backfill_runner, db.flats_needing_enrichment,
  db.enrichment_counts.

- lightbox: the modal didn't appear because Tailwind's Play CDN injects
  its own .hidden { display: none } rule at runtime, which kept fighting
  our class toggle. Switch the show/hide to inline style.display so no
  external stylesheet can mask it. Single-class .lightbox now only owns
  the layout — the initial-hidden state is on the element via
  style="display:none".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 12:48:14 +02:00
fe43a402d8 feat(wohnungen): "Rausgefilterte Wohnungen" section with reason chips
Below "Abgelehnte Wohnungen", surface flats that survived the time
filter and aren't rejected but failed at least one of the user's
filters. Same collapsed-card style. Action buttons are replaced by
chips naming each failed dimension — "Zimmer", "Preis", "Größe",
"WBS", "Bezirk" — so it's obvious which constraint to relax.

Refactored matching: flat_matches_filter now delegates to a new
flat_filter_failures(flat, f) that returns the failed-dimension
labels (empty list = full match). rooms_min and rooms_max collapse
to a single "Zimmer" chip; reasons emit in stable _REASON_ORDER for
consistent rendering. The section is suppressed entirely when the
user has no filters set, since "everything matches" makes the chips
meaningless.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 11:27:49 +02:00
77246d1381 fix(notifications): district filter silently dropped every match
internal.py's flat-match path fed the raw scraper payload into
flat_matches_filter, which has no "district" key. Combined with the
match rule "active districts filter + unknown district → reject",
this meant any user with a non-empty districts filter stopped
receiving match notifications as soon as the 0011 migration ran.

Extract the Bezirk once from payload.address before the per-user
loop, so all users' filter evaluations see a concrete district.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 10:18:04 +02:00
d13f9c5b6e feat(filter): Berlin-Bezirk filter in Einstellungen
Adds a collapsible 12-Bezirk checkbox list to the filter tab. The UI
speaks Bezirke; internally the match runs on the PLZ extracted from
flat.address and resolved to a dominant Bezirk via a curated 187-PLZ
map (berlin_districts.py).

- Migration 0011 adds user_filters.districts (CSV of selected names)
- Empty stored value = no filter = all Bezirke ticked in the UI.
  Submitting "all ticked" or "none ticked" both normalise to empty
  so the defaults and the nuclear state mean the same thing.
- When a Bezirk filter is active, flats with an unknown/unmapped PLZ
  are excluded — if the user bothered to narrow by district, sneaking
  in unplaceable flats would be the wrong default.
- Filter summary on the Wohnungen page shows "N Bezirke" so it's
  visible the filter is active.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 10:05:55 +02:00
64439fd42e feat(notifications): add Telegram test button
New "Test senden" button next to Speichern posts current form
credentials (not DB) to /actions/notifications/test, which fires a
test message and redirects back with a flash chip showing the outcome
(including the Telegram API's error description on failure).

telegram_send is now public and returns (ok, detail) so the UI can
surface real error messages ("chat not found", "Unauthorized", etc.).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 09:35:02 +02:00
d06dfdaca1 refactor: rename wohnungsdidi → lazyflat
Container names, FastAPI titles, email subjects, filenames, brand text,
session cookie, User-Agent, docstrings, README. Volume lazyflat_data and
/data/lazyflat.sqlite already used the new name, so on-disk data is
preserved; dropped the now-obsolete legacy-rename comments.

Side effect: SESSION_COOKIE_NAME change logs everyone out on deploy.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 09:26:12 +02:00
f1e26b38d0 refactor: split web/app.py into routers
app.py was ~1300 lines with every route, helper, and middleware mixed
together. Split into:

- app.py (~100 lines): FastAPI bootstrap, lifespan, /health, security
  headers, Jinja filter registration, include_router calls
- common.py: shared helpers (templates, apply_client, base_context,
  _is_htmx, client_ip, require_internal, time helpers, filter helpers,
  apply-gate helpers, _kick_apply / _finish_apply_background,
  _bg_tasks, _spawn, _mask_secret, _has_running_application, BERLIN_TZ)
- routes/auth.py: /login (GET+POST), /logout
- routes/wohnungen.py: /, /partials/wohnungen, /partials/wohnung/{id},
  /flat-images/{slug}/{idx}, /actions/apply|reject|unreject|auto-apply|
  submit-forms|reset-circuit|filters|enrich-all|enrich-flat; owns
  _wohnungen_context + _wohnungen_partial_or_redirect
- routes/bewerbungen.py: /bewerbungen, /bewerbungen/{id}/report.zip
- routes/einstellungen.py: /einstellungen, /einstellungen/{section},
  /actions/profile|notifications|account/password|partner/*; owns
  VALID_SECTIONS
- routes/admin.py: /logs redirect, /admin, /admin/{section},
  /logs/export.csv, /actions/users/*|secrets; owns ADMIN_SECTIONS,
  _parse_date_range, _collect_events
- routes/internal.py: /internal/flats|heartbeat|error|secrets

Route-diff before/after is empty — all 41 routes + /static mount
preserved. No behavior changes, pure mechanical split.

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