Skip to content

Batch confirm members#549

Open
georgelgeback wants to merge 3 commits into
mainfrom
batch-confirm-members
Open

Batch confirm members#549
georgelgeback wants to merge 3 commits into
mainfrom
batch-confirm-members

Conversation

@georgelgeback

@georgelgeback georgelgeback commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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-members router with CRUD + batch endpoints.
  • Adds test coverage for prereg-member routes and for invalid stil-id during /auth/register.
  • Refactors check_stil_id into 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
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