From 30eed6a434816fad76855e8323f665c2d0874499 Mon Sep 17 00:00:00 2001 From: Derek Guijt Date: Tue, 16 Jul 2024 14:44:35 -0400 Subject: [PATCH 1/3] user model --- backend/app/main.py | 14 +++++++------- backend/app/model/__init__.py | 0 backend/app/model/user_model.py | 0 3 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 backend/app/model/__init__.py create mode 100644 backend/app/model/user_model.py diff --git a/backend/app/main.py b/backend/app/main.py index 5fad945..e7616f7 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -36,10 +36,10 @@ async def main_function(): return RedirectResponse(url="/docs/") -# if __name__ == "__main__": -# uvicorn.run( -# "main:app", -# host=settings.HOST, -# reload=settings.DEBUG_MODE, -# port=settings.PORT, -# ) +if __name__ == "__main__": + uvicorn.run( + "main:app", + host=settings.HOST, + reload=settings.DEBUG_MODE, + port=settings.PORT, + ) diff --git a/backend/app/model/__init__.py b/backend/app/model/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/app/model/user_model.py b/backend/app/model/user_model.py new file mode 100644 index 0000000..e69de29 From 88a417b3f489d038b56683bfc65d32dc5a152aec Mon Sep 17 00:00:00 2001 From: Derek Guijt Date: Tue, 16 Jul 2024 19:13:00 -0400 Subject: [PATCH 2/3] user_model --- backend/app/model/user_model.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/backend/app/model/user_model.py b/backend/app/model/user_model.py index e69de29..c85b89f 100644 --- a/backend/app/model/user_model.py +++ b/backend/app/model/user_model.py @@ -0,0 +1,32 @@ +from pydantic import BaseModel, EmailStr, Field +from typing import Optional, List +from datetime import datetime + +class User(BaseModel): + id: str = Field(..., description="Unique identifier for the user") + email: EmailStr = Field(..., description="User's email address") + username: str = Field(..., min_length=3, max_length=50, description="User's chosen username") + password_hash: str = Field(..., description="Hashed password") + full_name: Optional[str] = Field(None, description="User's full name") + is_active: bool = Field(default=True, description="Whether the user account is active") + created_at: datetime = Field(default_factory=datetime.utcnow, description="Timestamp of account creation") + last_login: Optional[datetime] = Field(None, description="Timestamp of last login") + watch_history: List[str] = Field(default_factory=list, description="List of IDs of watched content") + bookmark: List[str] = Field(default_factory=list, description="List of IDs of content in bookmarks") + + class Config: + allow_population_by_field_name = True + schema_extra = { + "example": { + "id": "user123", + "email": "user@example.com", + "username": "netflixfan", + "password_hash": "hashed_password_here", + "full_name": "John Doe", + "is_active": True, + "created_at": "2023-01-01T00:00:00", + "last_login": "2023-07-16T12:30:00", + "watch_history": ["movie123", "series456"], + "bookmark": ["movie789", "series101"] + } + } \ No newline at end of file From cbf52890a803c9d7701f1db25e9b11c9057359a2 Mon Sep 17 00:00:00 2001 From: Derek Guijt Date: Tue, 16 Jul 2024 19:14:44 -0400 Subject: [PATCH 3/3] undo main change --- backend/app/main.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/app/main.py b/backend/app/main.py index e7616f7..5fad945 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -36,10 +36,10 @@ async def main_function(): return RedirectResponse(url="/docs/") -if __name__ == "__main__": - uvicorn.run( - "main:app", - host=settings.HOST, - reload=settings.DEBUG_MODE, - port=settings.PORT, - ) +# if __name__ == "__main__": +# uvicorn.run( +# "main:app", +# host=settings.HOST, +# reload=settings.DEBUG_MODE, +# port=settings.PORT, +# )