80 lines
1.6 KiB
Plaintext
80 lines
1.6 KiB
Plaintext
debug(f'edit_profile.dspy: {params_kw=}')
|
|
|
|
userid = await get_user()
|
|
if userid is None:
|
|
return UiError(title='Error', message='You need login first')
|
|
|
|
db = DBPools()
|
|
dbname = get_module_dbname('rbac')
|
|
async with db.sqlorContext(dbname) as sor:
|
|
recs = await sor.R('users', {'id': userid})
|
|
if not recs:
|
|
return UiError(title='Error', message='User not found')
|
|
user = recs[0]
|
|
nick_name = user.nick_name or ''
|
|
email = user.email or ''
|
|
mobile = user.mobile or ''
|
|
address = user.address or ''
|
|
|
|
return {
|
|
"widgettype": "Form",
|
|
"options": {
|
|
"title": "完善个人信息",
|
|
"description": "请填写或更新您的个人信息",
|
|
"fields": [
|
|
{
|
|
"name": "nick_name",
|
|
"type": "str",
|
|
"length": 255,
|
|
"uitype": "str",
|
|
"datatype": "str",
|
|
"required": False,
|
|
"label": "显示名",
|
|
"value": nick_name
|
|
},
|
|
{
|
|
"name": "email",
|
|
"type": "str",
|
|
"length": 255,
|
|
"uitype": "email",
|
|
"datatype": "str",
|
|
"required": False,
|
|
"label": "邮件地址",
|
|
"value": email
|
|
},
|
|
{
|
|
"name": "mobile",
|
|
"type": "str",
|
|
"length": 255,
|
|
"uitype": "tel",
|
|
"datatype": "str",
|
|
"required": False,
|
|
"label": "手机号",
|
|
"value": mobile
|
|
},
|
|
{
|
|
"name": "address",
|
|
"type": "str",
|
|
"length": 255,
|
|
"uitype": "str",
|
|
"datatype": "str",
|
|
"required": False,
|
|
"label": "地址",
|
|
"value": address
|
|
}
|
|
]
|
|
},
|
|
"binds": [
|
|
{
|
|
"wid": "self",
|
|
"event": "submit",
|
|
"actiontype": "urlwidget",
|
|
"target": "self",
|
|
"options": {
|
|
"method": "POST",
|
|
"url": entire_url('save_profile.dspy')
|
|
}
|
|
}
|
|
]
|
|
}
|