-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschemas.py
132 lines (101 loc) · 2.39 KB
/
schemas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
from pydantic import BaseModel, EmailStr
from datetime import date
from typing import Optional, Literal
import uuid
class CommunityCentreCreate(BaseModel):
name: str
address: str
latitude: float
longitude: float
contact: str
email: EmailStr
password: str
class CommunityCentreResponse(BaseModel):
id: str
name: str
address: str
latitude: float
longitude: float
contact: str
email: EmailStr
class Config:
from_attributes = True
class UserBase(BaseModel):
name: str
address: str
contact: str
email: EmailStr
class UserCreate(BaseModel):
name: str
address: str
contact: str
email: EmailStr
password: str # Accepts plain text (will be hashed before storing)
class UserResponse(BaseModel):
id: str
name: str
address: str
contact: str
email: EmailStr
class Config:
orm_mode = True
from_attributes = True # Ensures conversion from SQLAlchemy model
class RequirementBase(BaseModel):
community_centre_id: str
servings: int
date: date
meal_type: str
status: str
class RequirementCreate(RequirementBase):
pass
class RequirementResponse(BaseModel):
id: str
servings: int
date: date
meal_type: str
status: str
community_centre: CommunityCentreResponse # ✅ Include full details
class Config:
orm_mode = True
from pydantic import BaseModel
from typing import Optional
class FoodItemCreate(BaseModel):
image: str
title: str
description: str
servings: int
request_id: str
user_id: str
class FoodItemResponse(FoodItemCreate):
id: str
status: str
class Config:
orm_mode = True
from pydantic import BaseModel
class UserResponse(BaseModel):
id: str
name: str
address: str
contact: str
email: str
token_count: int
class Config:
from_attributes = True
class FoodItemResponseWithUser(BaseModel):
id: str
image: str
title: str
description: str
servings: int
status: str
user: UserResponse # Embed user details
class FoodItemStatusUpdate(BaseModel):
status: Literal["Open", "Approved", "In Transit", "Received", "Not fulfilled"]
class TokenUpdate(BaseModel):
token_count: int
class CommunityCentreLogin(BaseModel):
email: EmailStr
password: str
class UserLogin(BaseModel):
email: EmailStr
password: str