Batch confirm members#549
Open
georgelgeback wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new “pre-registration member” entity and admin API endpoints for managing known members (by email/stil-id/telephone) before they register on the site, plus centralizes and strengthens stil-id validation.
Changes:
- Introduces
PreregMember_DB+ Pydantic schemas and a new/prereg-membersrouter with CRUD + batch endpoints. - Adds test coverage for prereg-member routes and for invalid stil-id during
/auth/register. - Refactors
check_stil_idinto a shared helper and adds Pydantic-level stil-id validation in user schemas.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_users.py | Adds a registration test asserting invalid stil_id is rejected (422). |
| tests/test_prereg_members.py | Adds end-to-end tests for prereg-member CRUD and batch behavior. |
| services/user.py | Switches stil-id validation to the shared helper import. |
| routes/prereg_member_router.py | New prereg-member API router (list/get/create/batch create/update/delete + batch delete). |
| routes/init.py | Registers the prereg-member router under /prereg-members. |
| helpers/check_stil_id.py | New shared stil-id validator helper. |
| db_models/prereg_member_model.py | New prereg-member DB model + constraints. |
| api_schemas/user_schemas.py | Adds reusable stil-id validator mixin used by UserCreate/UserUpdate. |
| api_schemas/prereg_member_schema.py | New prereg-member request/response schemas. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+153
to
+155
| for var, value in vars(data).items(): | ||
| # Update the fields even if they are being set to None so they can be cleared | ||
| setattr(prereg_member, var, value) |
Comment on lines
+99
to
+101
| prereg_members: list[PreregMember_DB] = [] | ||
| existing_prereg_members: list[PreregMember_DB] = [] | ||
| for member_data in data: |
Comment on lines
+133
to
+134
| if len(existing_prereg_members) >= 0 and len(existing_prereg_members) == len(data): | ||
| raise HTTPException(400, detail="All prereg members already exist") |
Comment on lines
+138
to
+139
| # Note: returns all existing prereg members that would collide unless they were skipped, not the newly created prereg members | ||
| return existing_prereg_members |
| "telephone_number IS NOT NULL OR stil_id IS NOT NULL OR email IS NOT NULL", | ||
| name="at_least_one_identifier_required", | ||
| ), | ||
| UniqueConstraint("telephone_number", "stil_id", "email", name="unique_prereg_member_identifiers"), |
Comment on lines
+95
to
+100
| def test_update_prereg_member(client, admin_token, db_session): | ||
| member = create_db_prereg_member(db_session, email="old@test.com") | ||
| payload = {"email": "new@test.com"} | ||
| resp = client.patch(f"/prereg-members/{member.prereg_member_id}", json=payload, headers=auth_headers(admin_token)) | ||
| assert resp.status_code == 200 | ||
| assert resp.json()["email"] == "new@test.com" |
Comment on lines
+15
to
+25
| class StilIdValidationMixin: | ||
| stil_id: str | None = None | ||
|
|
||
| @field_validator("stil_id", mode="after") | ||
| @classmethod | ||
| def validate_stil_id(cls, value: str | None) -> str | None: | ||
| if value is None: | ||
| return None | ||
| if not check_stil_id(value): | ||
| raise ValueError("Invalid stil-id") | ||
| return value |
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.
Ready to be merged in!
Adds a new pre-registration member object to store email addresses, stil-id, and telephone numbers of people we know are members but who have not yet been registered as members on the website. This is really important for the frontend member admin pipeline to be as simple as possible, and doesn't touch the existing user system.