Skip to content

Story 2436: Mailing List Subscription Post Auth#2475

Open
herzog0 wants to merge 1 commit into
teo/2283-mailing-list-modalfrom
teo/2436-ml-post-auth
Open

Story 2436: Mailing List Subscription Post Auth#2475
herzog0 wants to merge 1 commit into
teo/2283-mailing-list-modalfrom
teo/2436-ml-post-auth

Conversation

@herzog0

@herzog0 herzog0 commented May 29, 2026

Copy link
Copy Markdown
Collaborator

Issue: #2436

⚠️ Base branch is teo/2283-mailing-list-modal

Summary & Context

Adds a post-login mailing list subscription modal that appears automatically on the homepage the first (and only) time a user lands there after logging in. The modal pre-fills the user's account email and lets them choose which lists to subscribe to.

Changes

  • users/signals.py - set request.session["show_ml_post_auth_modal"] in user_logged_in when user hasn't seen the modal yet (User.data["ml_post_auth_seen"] falsy)
  • ak/views.py (HomepageView) - pop session flag in get_v3_context_data; mark user as seen immediately; inject modal list context
  • mailing_list/views.py - add PostAuthSubscribeView (login required); reuses existing subscription + confirmation-email logic; returns empty HTMX fragment to remove modal from DOM
  • mailing_list/urls.py - register /mailing-list/post-auth-subscribe/
  • templates/v3/includes/_mailing_list_post_auth_modal.html - new standalone modal partial; auto-opens via Alpine x-init + CSS :target; reuses .mailing-list-modal__* classes for checkboxes/list items
  • static/css/v3/mailing-list-card.css - add .ml-post-auth-modal__* classes for email row, body, footer row, and count
  • templates/v3/homepage.html - conditionally include the modal when show_ml_post_auth_modal is in context

How the "seen once" logic works

  1. User logs in - user_logged_in signal sets request.session["show_ml_post_auth_modal"] = True (only if User.data["ml_post_auth_seen"] is not set)
  2. User lands on homepage - HomepageView.get_v3_context_data pops the session key and immediately sets User.data["ml_post_auth_seen"] = True on the User record
  3. Template renders the modal; Alpine x-init opens it by setting the URL hash
  4. Close/cancel: no backend call needed - the seen flag is already persisted from step 2
  5. Subscribe: HTMX POSTs to PostAuthSubscribeView, which creates PENDING subscription records and sends the confirmation email, then returns an empty response that HTMX uses to remove the modal from DOM

Risks & Considerations

  • The User.data JSONField is used for the ml_post_auth_seen flag - no migration needed since the field already exists and defaults to {}
  • The modal only renders on V3 homepage (waffle v3 flag gate via HomepageView.get_v3_context_data)
  • No-JS: modal won't auto-open (Alpine required), but subscription is still accessible via the mailing list card on other pages

Screenshots

image image image

Peer-review testing steps

  1. Mkae sure the v3 flag is enabled
  2. Log out completely
  3. Log in - you should be redirected to homepage and the modal should open automatically
  4. Subscribe or cancel - modal closes, no reappearance on refresh
  5. Log out and log in again - modal should NOT appear (flag set in the user model)
  6. For a fresh test (you'll have to log out and log in again):
    • Open a djano shell in a new terminal with docker compose exec web python manage.py shell
    • Run (replace your email):
from users.models import User
user = User.objects.get(email="your@email.com")
user.data.pop("ml_post_auth_seen", None)
user.save()

Self-review Checklist

  • Tag at least one team member from each team to review this PR
  • Link this PR to the related GitHub Project ticket

Frontend

  • UI implementation matches Figma design
  • Tested in light and dark mode
  • Responsive / mobile verified
  • Accessibility checked (keyboard navigation, etc.)
  • Ensure design tokens are used for colors, spacing, typography, etc. - No hardcoded values
  • Test without JavaScript (if applicable)
  • No console errors or warnings

@herzog0 herzog0 linked an issue May 29, 2026 that may be closed by this pull request
@herzog0 herzog0 force-pushed the teo/2283-mailing-list-modal branch from a2851ad to a7c3795 Compare May 29, 2026 17:03
@herzog0 herzog0 force-pushed the teo/2436-ml-post-auth branch from 75d904c to fcfd84e Compare May 29, 2026 17:03
@herzog0 herzog0 force-pushed the teo/2283-mailing-list-modal branch from a7c3795 to d4c3e88 Compare May 29, 2026 17:05
@herzog0 herzog0 force-pushed the teo/2436-ml-post-auth branch from fcfd84e to 6bc71c1 Compare May 29, 2026 17:05
@julioest julioest self-requested a review June 2, 2026 15:25

@julioest julioest left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected on my end ✅

@herzog0 herzog0 force-pushed the teo/2283-mailing-list-modal branch from d4c3e88 to 6a64a43 Compare June 3, 2026 15:22
@herzog0 herzog0 force-pushed the teo/2436-ml-post-auth branch 2 times, most recently from c722aa4 to bd2f4c3 Compare June 3, 2026 17:11
feat: inject post-auth modal context in HomepageView

feat: add PostAuthSubscribeView for post-login modal

feat: add post-auth mailing list modal template

feat: add post-auth modal CSS

feat: wire post-auth modal into v3 homepage

fix: correct post-auth modal width, email field, and button padding

fix: use $refs for checkbox container to fix unselect all

fix: drop only from modal include so CSRF token is available

refactor: extract _subscribe_pending helper to remove duplicate sub logic

feat: toggle select all / unselect all button based on checked state

fix: add missing bottom padding below select/unselect all row

fix: title padding

fix: correct email field text color and font size to match text field spec

fix: revert email field color and font-size to match figma spec

fix: colors and radii

fix: remove aria-hidden from backdrop links to prevent focus conflict warning
@herzog0 herzog0 force-pushed the teo/2283-mailing-list-modal branch from 99178e5 to 879e91d Compare June 8, 2026 14:48
@herzog0 herzog0 force-pushed the teo/2436-ml-post-auth branch from bd2f4c3 to abb2720 Compare June 8, 2026 14:48
@ycanales ycanales self-requested a review June 11, 2026 16:59
@ycanales

Copy link
Copy Markdown
Collaborator

Works great, approving :)

Should the modal be disimissable with Esc key? I noticed that pattern in other modals with aria-label="Close", it does not work here so maybe that attribute that dialog.js uses to bind the Esc key is missing?

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.

Mailing List Subscription Post Auth

3 participants