updated update base models
This commit is contained in:
@@ -271,18 +271,22 @@ class Build(CrudCollection, SelectActionWithEmployee):
|
||||
@classmethod
|
||||
def update_action(cls, data: UpdateBuild, build_uu_id: str, token):
|
||||
from databases import Addresses
|
||||
|
||||
print('data_dict', data.dump())
|
||||
data_dict = data.excluded_dump()
|
||||
if data.official_address_uu_id:
|
||||
if data.address_uu_id:
|
||||
official_address = Addresses.filter_one(
|
||||
Addresses.uu_id == data.address_uu_id
|
||||
).data
|
||||
data_dict["address_id"] = official_address.id if official_address else None
|
||||
del data_dict["address_uu_id"]
|
||||
print('data_dict', data_dict)
|
||||
if build_to_update := cls.filter_one(
|
||||
cls.uu_id == build_uu_id, cls.person_id == token.id
|
||||
cls.uu_id == build_uu_id
|
||||
).data:
|
||||
return build_to_update.update(**data_dict)
|
||||
print('build_to_update', build_to_update.get_dict())
|
||||
updated_build = build_to_update.update(**data_dict)
|
||||
updated_build.save()
|
||||
print('updated_build', updated_build.get_dict())
|
||||
return updated_build
|
||||
|
||||
@property
|
||||
def top_flat(self):
|
||||
|
||||
Reference in New Issue
Block a user