Source code for cadrumo.application.user_profile.presentation
"""Profile presentation helpers consumed by the interactive entrypoint."""from__future__importannotationsfrom...core.i18n.renderimporttrfrom...core.json_contractimportNotice,ResolvedNoticeActionfrom...core.presentationimportNoticePresentationfrom...domain.user_profile.schemaimportProfileFieldType
[docs]defprofile_field_shape_hint(field_type:ProfileFieldType)->str:"""Return the localized accepted-shape hint for a typed profile field."""matchfield_type:caseProfileFieldType.DATE:returntr("flows.manager.edit.shape.date")caseProfileFieldType.EMAIL:returntr("flows.manager.edit.shape.email")caseProfileFieldType.INTEGER:returntr("flows.manager.edit.shape.integer")caseProfileFieldType.DECIMAL:returntr("flows.manager.edit.shape.decimal")caseProfileFieldType.MONEY:returntr("flows.manager.edit.shape.money")case_:return""
[docs]defnotice_presentation(notice:Notice)->NoticePresentation:"""Project one resolved notice into the inert cross-entrypoint shape."""action=notice.actionaction_target=Noneifisinstance(action,ResolvedNoticeAction)andaction.action.cli_pathisnotNoneandnotaction.argument_bindings:action_target="aeat "+" ".join(action.action.cli_path)returnNoticePresentation(severity=notice.severity.value,message=notice.message,action_target=action_target,)