Skip to content

Add admin page, browser location, privacy explainer - #3

Merged
dbader merged 3 commits into
masterfrom
claude/project-thread-pm5duv
Dec 3, 2026
Merged

dbader merged 3 commits into
masterfrom
claude/project-thread-pm5duv

Conversation

@dbader

@dbader dbader commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Requested by Dan · project thread

What

Admin page (/admin/)

  • HTTP basic auth with the ADMIN_PASSWORD config var (any username). It returns 404 when the var is unset.
  • Lists every pin, newest first, with a live filter on location and nickname.
  • Inline edit of location and nickname, delete with a confirmation, and a JSON download of all pins (id, created, location, coordinates, nickname).
  • POST forms carry a session CSRF token. Browsers resend basic auth on their own, so without the token a third-party page could delete pins.
  • This replaces /export/json and EXPORT_PASSWORD.

Flagging bad pins

  • Each pin stores its country in a new country column, which init-db adds. New pins get the country from the geocoder.
  • flask --app members_map check-pins fills in the country for older pins at Nominatim's rate of one request per second. It tries the typed text first and falls back to the coordinates. It can be stopped and rerun.
  • The admin page flags pins that aren't in any country, duplicates of an older pin (the oldest copy stays unflagged), and links in the location or nickname. You can filter by flag, select all shown, and delete them in bulk.

Use my current location

  • The browser asks for permission. The coordinates are rounded to 1 decimal place (about 11 km) in the browser, rounded again on the server, and labeled with a town-level Nominatim reverse lookup ("Vancouver, Canada").
  • If the reverse lookup is down, the pin is still added and labeled with its rounded coordinates.

Privacy

  • Every new pin is stored at about 11 km precision, typed locations included, so a street address no longer gives an exact pin.
  • The release phase (init-db) also rounds existing pins. It's idempotent and touches only rows that aren't rounded yet.
  • A "How we handle your data" dialog explains what's stored, what isn't, the third-party services, and how to get a pin removed.

Only real places

  • A typed location must geocode to a place with a country, so "Atlantic Ocean" is rejected. Browser locations must reverse-geocode to a country too, so a spot at sea is rejected with a prompt to type the city instead.
  • The browser sends coordinates rounded to about 1 km. The server names the place from those, then stores the pin at about 10 km, so coastal towns that round into the water still work.
  • Checked against live Nominatim: Vancouver and Sydney are accepted, while "Atlantic Ocean", "Pacific Ocean", gibberish, and a mid-Atlantic coordinate are rejected.

Small extras

  • A honeypot field silently drops bot submissions.
  • The header shows a member count ("1,067 Pythonistas on the map").

Testing

  • uv run pytest: 58 passed. Ruff is clean.
  • Ran it under gunicorn in headless Chromium with a mocked geolocation of Vancouver. The pin was added as "Vancouver, Canada" at 49.3, -123.1, and the reverse lookup went to Nominatim for real.
  • In the admin: renamed the pin, filtered, and deleted it. The count went from 1,068 back to 1,067.
  • Checked that the privacy dialog opens and closes.

Deploy notes

  • Set ADMIN_PASSWORD in Heroku config vars. EXPORT_PASSWORD is no longer used.
  • After the deploy, run heroku run -a members-map flask --app members_map check-pins once. It takes about 20 to 40 minutes for roughly 1,000 pins.
  • On the first release, the release phase rounds all existing pins to 1 decimal place. This is intended and can't be undone, so take a pg:backups:capture first if you want the original coordinates.

https://claude.ai/code/session_01WLRZ1bCeX4qyg1QpD6AQFG


Generated by Claude Code

- /admin/ behind HTTP basic auth (ADMIN_PASSWORD): list and filter pins,
  edit location and nickname, delete, export JSON. Replaces
  /export/json and EXPORT_PASSWORD. Forms carry a session CSRF token
  since browsers resend basic auth automatically.
- "Use my current location" button: coordinates are rounded to one
  decimal (about 11 km) in the browser and again on the server, and the
  label comes from a Nominatim reverse lookup at town level.
- Every pin is now stored at about 11 km precision, including typed
  locations. The release phase rounds existing pins too (idempotent).
- Privacy explainer dialog on the map page, honeypot spam field, member
  count in the header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WLRZ1bCeX4qyg1QpD6AQFG
@dbader dbader self-assigned this Dec 3, 2026
Typed places must geocode to something with a country, which rules out
"Atlantic Ocean" and the like. Browser locations must reverse-geocode to
a country too, so a pin out at sea is rejected instead of being labeled
with bare coordinates.

The browser now rounds to about 1 km before sending. The server names
the place from that, then stores the pin at about 10 km as before, so a
coastal town that rounds into the water is still accepted. The privacy
explainer says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WLRZ1bCeX4qyg1QpD6AQFG
- Pins store their country (new column, added by init-db). New pins get
  it from the geocoder; `flask check-pins` fills it in for older pins at
  Nominatim's one request per second, from the typed text first and the
  coordinates second, and can be stopped and rerun.
- The admin flags pins that aren't in any country, duplicates of an
  older pin, and links in the location or nickname, with a filter per
  flag and checkboxes to delete the selection in one go.
- geo returns a Place (name, country, coordinates) for both lookups.
- CLI commands push an app context themselves, so they also work from
  app.cli in tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WLRZ1bCeX4qyg1QpD6AQFG
@dbader
dbader merged commit 497f4d5 into master Dec 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants