Add endpoint for creating local contacts with access control

Introduced a new `local_contact_router` to handle creation of local contacts. The endpoint enforces role-based access control and ensures no duplication of email addresses. Updated the router exports for consistency and cleaned up a large test file to improve readability.
This commit is contained in:
GotthardG
2025-02-26 09:58:19 +01:00
parent 43d67b1044
commit f588bc0cda
13 changed files with 360 additions and 418 deletions

View File

@ -17,6 +17,7 @@ class loginToken(BaseModel):
class loginData(BaseModel):
username: str
pgroups: List[str]
# role: Optional[str] = "user"
class DewarTypeBase(BaseModel):
@ -417,6 +418,29 @@ class ContactMinimal(BaseModel):
id: int
class Proposal(BaseModel):
id: int
number: str
class Config:
from_attributes = True
class LocalContactCreate(BaseModel):
firstname: str
lastname: str
phone_number: str
email: EmailStr
status: str = "active"
class Config:
from_attributes = True
class LocalContact(LocalContactCreate):
id: int
class AddressCreate(BaseModel):
pgroups: str
house_number: Optional[str] = None
@ -617,14 +641,6 @@ class DewarTable(BaseModel):
from_attributes = True
class Proposal(BaseModel):
id: int
number: str
class Config:
from_attributes = True
class Shipment(BaseModel):
id: int
pgroups: str
@ -752,3 +768,18 @@ class PuckWithTellPosition(BaseModel):
class Config:
from_attributes = True
class Beamtime(BaseModel):
id: int
pgroups: str
beamtime_name: str
beamline: str
start_date: date
end_date: date
status: str
comments: Optional[constr(max_length=200)] = None
proposal_id: Optional[int]
proposal: Optional[Proposal]
local_contact_id: Optional[int]
local_contact: Optional[LocalContact]