Commit 3afa378e authored by Nicolas Schmid's avatar Nicolas Schmid
Browse files

feat: get creationinfo submodel working and add to projects

parent be2b2da4
......@@ -29,15 +29,24 @@ def real_value_factory(quantity_type: type) -> Type[BaseModel]:
return retval
# def creationinfo_factory() -> Type[BaseModel]:
# _func_map = dict([
# ('author', (Optional[str], None)),
# ('agencyid', (Optional[str], None)),
# ('creationtime', (Optional[datetime], None)),
# ('version', (Optional[str], None)),
# ('copyrightowner', (Optional[str], None)),
# ('licence', (Optional[str], None)),
# ])
def creationinfo_factory() -> Type[BaseModel]:
_func_map = dict([
('author', (Optional[str], None)),
('agencyid', (Optional[str], None)),
('creationtime', (Optional[datetime], None)),
('version', (Optional[str], None)),
('copyrightowner', (Optional[str], None)),
('licence', (Optional[str], None)),
])
retval = create_model(
'CreationInfo',
__config__=BaseConfig,
**_func_map)
return retval
class CreationInfo(creationinfo_factory()):
pass
class RealFloatValue(real_value_factory(float)):
......@@ -58,11 +67,11 @@ class ValueGetter(GetterDict):
if key in cols:
return getattr(self._obj, key, default)
# else it's probably a real value
# else it's probably a sub value
# get all column names which are present for this key
elem = [k for k in cols if k.startswith(f'{key}_')]
if elem:
# create a dict for the real_value
# create a dict for the sub value
return_dict = {}
for k in elem:
return_dict[k.partition(
......@@ -208,6 +217,7 @@ class InjectionWellSchema(BaseModel):
class ProjectSchema(BaseModel):
id: int
name: Optional[str]
creationinfo: Optional[CreationInfo]
description: Optional[str]
referencepoint_x: Optional[float]
referencepoint_y: Optional[float]
......@@ -218,6 +228,9 @@ class ProjectSchema(BaseModel):
settings: dict
_get_forecasts: classmethod = create_validator('forecasts', get_ids)
class Config:
getter_dict = ValueGetter
class ForecastSchema(BaseModel):
id: int
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment