Add settings modal with account management - #97
Closed
vanajmoorthy wants to merge 1 commit into
Closed
Conversation
Placeholder for the settings modal reimplementation. See PR description for full implementation plan. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
Author
|
Closing in favor of a fresh rebuild on current main. This scaffold predates the |
vanajmoorthy
added a commit
that referenced
this pull request
Jul 29, 2026
… toggles Consolidates all account management into a single neobrutalist modal opened from the dashboard action bar. Rebuilds the stale scaffold PR #97 fresh against the current core/views/ package. Backend (core/forms.py, core/views/profile.py, core/urls.py): - UpdateEmailForm (case-insensitive uniqueness, excludes self — email is the login key so duplicates must be rejected) and ChangePasswordForm (current- password check + match + Django password validators). - update_email_view, change_password_view (calls update_session_auth_hash so the user stays logged in), delete_account_view (requires typing "DELETE" AND the correct password; fires track_account_deleted before deletion, logs out, then cascade-deletes the User — no deletion on any failed check). - update_privacy_view + update_recommendation_visibility now support BOTH AJAX (JSON via X-Requested-With) and form-POST (redirect); a _wants_json() helper gates the response shape. All existing side effects preserved. - 3 new routes under dashboard/; new views re-exported from core/views/__init__. Model: flip UserProfile.is_public default False -> True (migration 0030_userprofile_is_public_default_true; affects new profiles only — pre-approved). Analytics: track_account_deleted event added + exported. Frontend: - New core/templates/core/partials/settings_modal.html: teleported modal (Escape/ backdrop close, scroll-lock) with Display Name (reuses the username-editor fetch pattern), Email, Password, Privacy toggle, Recommendation-visibility toggle, and a guarded Danger Zone (delete disabled until "DELETE" + password entered). All buttons obey the buttons-only-move-DOWN rule. - dashboard.html: Settings button in the action bar (opens the modal via a settingsModalOpen flag spread into the existing share-modal scope); inline privacy toggle control moved into the modal (status text + public link remain). Tests: new core/tests/test_settings.py (29 tests) — email valid/dup/own-email/ invalid, password wrong-current/mismatch/weak/session-stays-alive, delete requires DELETE+password (each failure leaves the account intact), both AJAX and form-POST toggle paths, and auth guards on every endpoint. Analytics mocked and asserted. Full suite green: 563 tests (was 534). makemigrations --check clean. Claude-Session: https://claude.ai/code/session_01ShoZQjFpF3LxP9tEwmabRn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reimplement the settings modal from #72 (closed due to merge conflicts after 65 commits diverged on main). This PR consolidates all user account management into a single modal dialog accessible from the dashboard.
Plan
1. Backend: New forms (
core/forms.py)UpdateEmailForm— validates email format and case-insensitive uniquenessChangePasswordForm— validates current password + new password confirmation2. Backend: New views (
core/views.py)update_email_view—@login_required @require_POST, handles email update with duplicate checking, returns JSON for AJAXchange_password_view—@login_required @require_POST, changes password and re-authenticates user (prevents logout), returns JSONdelete_account_view—@login_required @require_POST, requires text confirmation ("DELETE") + password verification, deletes user cascade, returns JSONupdate_privacy_viewandupdate_recommendation_visibilityto support both AJAX (JSON response) and form POST (redirect) patterns3. Backend: URLs (
core/urls.py)Add 3 new paths:
4. Backend: Analytics (
core/analytics/events.py)track_account_deleted(user_id)eventtrack_settings_updated()to cover email/password changes5. Frontend: Settings modal template (
core/templates/core/partials/settings_modal.html)New partial with Alpine.js state management containing:
update_username_api)6. Frontend: Dashboard integration (
core/templates/core/dashboard.html)settingsOpento the existingshareModalData()Alpine.js scope (or merge scopes)7. Database migration
UserProfile.is_publicdefault fromFalsetoTrue(new migration)8. Tests (
core/tests/test_settings.py)Comprehensive test suite covering:
Files to modify
core/forms.py— add 2 formscore/views.py— add 3 views, enhance 2 existing viewscore/urls.py— add 3 URL pathscore/analytics/events.py— add 1 event, update 1 eventcore/models.py— changeis_publicdefault (1 line)core/templates/core/dashboard.html— add settings button + modal include, remove inline privacy togglecore/templates/core/partials/settings_modal.html— new filecore/tests/test_settings.py— new filecore/migrations/0027_*.py— new migrationTest plan
🤖 Generated with Claude Code