From 99c9a183b6a7f5d0d009186901a15ec94992ac6e Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Fri, 28 Mar 2025 04:36:07 +0000 Subject: [PATCH] Add User schema --- schemas/user.py | 51 ++++++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/schemas/user.py b/schemas/user.py index 77c1252..d2d2419 100644 --- a/schemas/user.py +++ b/schemas/user.py @@ -1,26 +1,19 @@ from pydantic import BaseModel, Field, EmailStr -from enum import Enum -from datetime import datetime from typing import Optional -class UserRoles(str, Enum): - student = "student" - teacher = "teacher" - admin = "admin" - class UserBase(BaseModel): - first_name: str = Field(..., min_length=1, max_length=50) - last_name: str = Field(..., min_length=1, max_length=50) - email: EmailStr = Field(..., max_length=100) - role: UserRoles - phone_number: str = Field(..., max_length=20) - address: str = Field(..., max_length=200) - date_of_birth: datetime - profile_picture: Optional[str] = None + first_name: str = Field(..., min_length=2, max_length=50) + last_name: str = Field(..., min_length=2, max_length=50) + email: EmailStr = Field(..., description="User email address") + phone: str = Field(..., min_length=10, max_length=15) + address: Optional[str] = Field(None, max_length=200) + city: Optional[str] = Field(None, max_length=100) + country: Optional[str] = Field(None, max_length=100) is_active: bool = True + is_admin: bool = False class UserCreate(UserBase): - password: str = Field(..., min_length=8) + password: str = Field(..., min_length=8, max_length=100) class Config: schema_extra = { @@ -28,19 +21,18 @@ class UserCreate(UserBase): "first_name": "John", "last_name": "Doe", "email": "john.doe@example.com", - "password": "secretpass123", - "role": "student", - "phone_number": "+1234567890", - "address": "123 Main St, City, Country", - "date_of_birth": "1990-01-01T00:00:00", - "profile_picture": "http://example.com/profile.jpg", - "is_active": True + "phone": "1234567890", + "password": "securepass123", + "address": "123 Main St", + "city": "New York", + "country": "USA", + "is_active": True, + "is_admin": False } } class UserResponse(UserBase): id: int - last_login: Optional[datetime] = None class Config: orm_mode = True @@ -50,12 +42,11 @@ class UserResponse(UserBase): "first_name": "John", "last_name": "Doe", "email": "john.doe@example.com", - "role": "student", - "phone_number": "+1234567890", - "address": "123 Main St, City, Country", - "date_of_birth": "1990-01-01T00:00:00", - "profile_picture": "http://example.com/profile.jpg", + "phone": "1234567890", + "address": "123 Main St", + "city": "New York", + "country": "USA", "is_active": True, - "last_login": "2023-01-01T12:00:00" + "is_admin": False } } \ No newline at end of file