-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
87 lines (79 loc) · 2.78 KB
/
models.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
import uuid
from typing import Optional
from pydantic import BaseModel, Field, PastDate, PositiveFloat
from datetime import date, timedelta
class Asset(BaseModel):
id: str = Field(default_factory=uuid.uuid4, alias="_id")
name: str = Field(...)
description: str = Field(None)
site: str = Field(None, alias='main_location')
location: str = Field(None, alias='specific_location')
purchaseDate: PastDate = Field(None)
manufacturer: str = Field(None)
model: str = Field(None)
serial: str = Field(None)
originalCost: PositiveFloat = Field(None)
estimatedValueA: PositiveFloat = Field(None)
estimatedValueB: PositiveFloat = Field(None)
owner: str = Field(None)
assetImage: str = Field(None)
receipt: str = Field(None)
class Config:
populate_by_name = True
exclude_unset = True
extra = "forbid"
json_schema_extra = {
"example": {
"name": "Samsung 75 TV",
"description": "smart tv",
"site": "house",
"location": "room",
"purchaseDate": '2023-12-01',
"manufacturer": "Samsung",
"model": "sam75big",
"serial": "1231214124",
"originalCost": 12.23,
"estimatedValueA": 12.50,
"estimatedValueB": 100.00,
"owner": "user1",
"assetImage": "/mnt/stor",
"receipt": "/mnt/recp",
}
}
class AssetUpdate(BaseModel):
name: str = Field(None)
description: str = Field(None)
site: str = Field(None, alias='main_location')
location: str = Field(None, alias='specific_location')
purchaseDate: PastDate = Field(None)
manufacturer: str = Field(None)
model: str = Field(None)
serial: str = Field(None)
originalCost: PositiveFloat = Field(None)
estimatedValueA: PositiveFloat = Field(None)
estimatedValueB: PositiveFloat = Field(None)
owner: str = Field(None)
assetImage: str = Field(None)
receipt: str = Field(None)
class Config:
populate_by_name = True
exclude_unset = True
extra = "forbid"
json_schema_extra = {
"example": {
"name": "Samsung 75 TV",
"description": "smart tv",
"site": "house",
"location": "room",
"purchaseDate": '2023-12-01',
"manufacturer": "Samsung",
"model": "sam75big",
"serial": "1231214124",
"originalCost": 12.23,
"estimatedValueA": 12.50,
"estimatedValueB": 100.00,
"owner": "user1",
"assetImage": "/mnt/stor",
"receipt": "/mnt/recp",
}
}