本文整理汇总了Python中models.User.User.avatar方法的典型用法代码示例。如果您正苦于以下问题:Python User.avatar方法的具体用法?Python User.avatar怎么用?Python User.avatar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.User.User
的用法示例。
在下文中一共展示了User.avatar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_user
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import avatar [as 别名]
def create_user(self):
''' Add user to the database '''
if User.by_handle(self.get_argument('handle', '')) is not None:
raise ValidationError("This handle is already registered")
if self.get_argument('pass1', '') != self.get_argument('pass2', ''):
raise ValidationError("Passwords do not match")
user = User()
user.handle = self.get_argument('handle', '')
user.password = self.get_argument('pass1', '')
user.bank_password = self.get_argument('bpass', '')
user.name = self.get_argument('playername', '')
user.email = self.get_argument('email','')
team = self.get_team()
self.dbsession.add(user)
self.dbsession.add(team)
self.dbsession.commit()
# Avatar
avatar_select = self.get_argument('user_avatar_select', '')
if avatar_select and len(avatar_select) > 0:
user._avatar = avatar_select
elif hasattr(self.request, 'files') and 'avatar' in self.request.files:
user.avatar = self.request.files['avatar'][0]['body']
team.members.append(user)
if not options.teams:
if avatar_select and len(avatar_select) > 0:
team._avatar = avatar_select
elif hasattr(self.request, 'files') and 'avatar' in self.request.files:
team.avatar = self.request.files['avatar'][0]['body']
self.dbsession.add(user)
self.dbsession.add(team)
self.dbsession.commit()
self.event_manager.user_joined_team(user)
return user