本文整理匯總了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))