示例#1
0
def _create_attribute_from_draft(
        draft: types.AttributeDefinitionDraft) -> types.AttributeDefinition:
    return types.AttributeDefinition(
        type=draft.type,
        name=draft.name,
        label=draft.label,
        is_required=draft.is_required,
        attribute_constraint=draft.attribute_constraint,
        input_tip=draft.input_tip,
        input_hint=draft.input_hint or types.TextInputHint.SINGLE_LINE,
        is_searchable=draft.is_searchable,
    )
    def _create_attributes_from_draft(
        self,
        draft_attributes: typing.Optional[typing.List[types.AttributeDefinitionDraft]],
    ) -> typing.List[types.AttributeDefinition]:

        result: typing.List[types.AttributeDefinition] = []
        if not draft_attributes:
            return result

        for draft in draft_attributes:
            ad = types.AttributeDefinition(
                type=draft.type,
                name=draft.name,
                label=draft.label,
                is_required=draft.is_required,
                attribute_constraint=draft.attribute_constraint,
                input_tip=draft.input_tip,
                input_hint=draft.input_hint,
                is_searchable=draft.is_searchable,
            )
            result.append(ad)
        return result
示例#3
0
 def post_load(self, data, **kwargs):
     return types.AttributeDefinition(**data)