本文整理汇总了Python中kallithea.model.user.UserModel.add_extra_email方法的典型用法代码示例。如果您正苦于以下问题:Python UserModel.add_extra_email方法的具体用法?Python UserModel.add_extra_email怎么用?Python UserModel.add_extra_email使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kallithea.model.user.UserModel
的用法示例。
在下文中一共展示了UserModel.add_extra_email方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_email
# 需要导入模块: from kallithea.model.user import UserModel [as 别名]
# 或者: from kallithea.model.user.UserModel import add_extra_email [as 别名]
def add_email(self, id):
"""POST /user_emails:Add an existing item"""
# url('user_emails', id=ID, method='put')
email = request.POST.get('new_email')
user_model = UserModel()
try:
user_model.add_extra_email(id, email)
Session().commit()
h.flash(_("Added email %s to user") % email, category='success')
except formencode.Invalid, error:
msg = error.error_dict['email']
h.flash(msg, category='error')
示例2: add_email
# 需要导入模块: from kallithea.model.user import UserModel [as 别名]
# 或者: from kallithea.model.user.UserModel import add_extra_email [as 别名]
def add_email(self, id):
user = self._get_user_or_raise_if_default(id)
email = request.POST.get('new_email')
user_model = UserModel()
try:
user_model.add_extra_email(id, email)
Session().commit()
h.flash(_("Added email %s to user") % email, category='success')
except formencode.Invalid as error:
msg = error.error_dict['email']
h.flash(msg, category='error')
except Exception:
log.error(traceback.format_exc())
h.flash(_('An error occurred during email saving'),
category='error')
raise HTTPFound(location=url('edit_user_emails', id=id))