email template

This commit is contained in:
debu-2 2026-10-05 21:00:05 +05:30
parent ebbb582e99
commit 2451045693
15 changed files with 447 additions and 156 deletions

View file

@ -3,7 +3,7 @@ from datetime import date
from typing import Literal
from uuid import UUID
from pydantic import BaseModel, ConfigDict, EmailStr, Field
from pydantic import BaseModel, ConfigDict, EmailStr, Field, model_validator
class AccountRegister(BaseModel):
@ -61,7 +61,13 @@ class OrgMemberCreate(BaseModel):
org_role: Literal["user", "admin"] = "user"
send_invitation: bool = True
force_password_change: bool = False
password: str = Field(min_length=8, max_length=128)
password: str | None = Field(default=None, min_length=8, max_length=128)
@model_validator(mode="after")
def password_required_without_invite(self) -> OrgMemberCreate:
if not self.send_invitation and not self.password:
raise ValueError("Password is required when not sending an invitation.")
return self
class OrgMemberRead(BaseModel):
@ -99,6 +105,18 @@ class PasswordChangeRequest(BaseModel):
new_password: str = Field(min_length=8, max_length=128)
class InvitePreview(BaseModel):
work_email: EmailStr
first_name: str
organization: str
invited_by: str
expires_at: datetime
class InviteAcceptRequest(BaseModel):
password: str = Field(min_length=8, max_length=128)
class OrgMemberListResponse(BaseModel):
items: list[OrgMemberRead]
counts: dict[str, int]
@ -109,7 +127,7 @@ class OrgMemberImportRow(BaseModel):
last_name: str = Field(min_length=1, max_length=80)
work_email: str = Field(min_length=1, max_length=320)
invitation_email: EmailStr | None = None
password: str = Field(min_length=8, max_length=128)
password: str | None = Field(default=None, min_length=8, max_length=128)
class OrgMemberImportRequest(BaseModel):