11
11
class BaseSchema (BaseModel ):
12
12
@property
13
13
def as_db_dict (self ):
14
- to_db = self .model_dump (
15
- exclude_defaults = True , exclude_none = True , exclude = {"identifier, id" }
16
- )
14
+ to_db = self .model_dump (exclude_defaults = True , exclude_none = True , exclude = {"identifier, id" })
17
15
for key in ["id" , "identifier" ]:
18
16
if key in self .model_dump ().keys ():
19
17
to_db [key ] = self .model_dump ()[key ].hex
@@ -23,16 +21,12 @@ def as_db_dict(self):
23
21
class MetadataBaseSchema (BaseSchema ):
24
22
# Receive via API
25
23
# https://www.dublincore.org/specifications/dublin-core/dcmi-terms/#section-3
26
- title : Optional [str ] = Field (
27
- None , description = "A human-readable title given to the resource."
28
- )
24
+ title : Optional [str ] = Field (None , description = "A human-readable title given to the resource." )
29
25
description : Optional [str ] = Field (
30
26
None ,
31
27
description = "A short description of the resource." ,
32
28
)
33
- isActive : Optional [bool ] = Field (
34
- default = True , description = "Whether the resource is still actively maintained."
35
- )
29
+ isActive : Optional [bool ] = Field (default = True , description = "Whether the resource is still actively maintained." )
36
30
isPrivate : Optional [bool ] = Field (
37
31
default = True ,
38
32
description = "Whether the resource is private to team members with appropriate authorisation." ,
@@ -44,22 +38,14 @@ class MetadataBaseCreate(MetadataBaseSchema):
44
38
45
39
46
40
class MetadataBaseUpdate (MetadataBaseSchema ):
47
- identifier : UUID = Field (
48
- ..., description = "Automatically generated unique identity for the resource."
49
- )
41
+ identifier : UUID = Field (..., description = "Automatically generated unique identity for the resource." )
50
42
51
43
52
44
class MetadataBaseInDBBase (MetadataBaseSchema ):
53
45
# Identifier managed programmatically
54
- identifier : UUID = Field (
55
- ..., description = "Automatically generated unique identity for the resource."
56
- )
57
- created : date = Field (
58
- ..., description = "Automatically generated date resource was created."
59
- )
60
- isActive : bool = Field (
61
- ..., description = "Whether the resource is still actively maintained."
62
- )
46
+ identifier : UUID = Field (..., description = "Automatically generated unique identity for the resource." )
47
+ created : date = Field (..., description = "Automatically generated date resource was created." )
48
+ isActive : bool = Field (..., description = "Whether the resource is still actively maintained." )
63
49
isPrivate : bool = Field (
64
50
...,
65
51
description = "Whether the resource is private to team members with appropriate authorisation." ,
0 commit comments