def _create_from_draft(self, obj: types.CategoryDraft, id: typing.Optional[str] = None) -> types.Category: object_id = str(uuid.UUID(id) if id is not None else uuid.uuid4()) return types.Category( id=str(object_id), version=1, name=obj.name, description=obj.description, slug=obj.slug, key=obj.key, created_at=datetime.datetime.now(), last_modified_at=datetime.datetime.now(), custom=utils.create_from_draft(obj.custom), )
def _create_from_draft(self, draft: types.CategoryDraft, id: typing.Optional[str] = None) -> types.Category: object_id = str(uuid.UUID(id) if id is not None else uuid.uuid4()) return types.Category( id=str(object_id), version=1, name=draft.name, description=draft.description, slug=draft.slug, key=draft.key, created_at=datetime.datetime.now(datetime.timezone.utc), last_modified_at=datetime.datetime.now(datetime.timezone.utc), ancestors=[], order_hint="", custom=utils.create_from_draft(draft.custom), )
def post_load(self, data, **kwargs): return types.Category(**data)
def post_load(self, data): return types.Category(**data)