本文整理汇总了Python中the_tale.accounts.prototypes.AccountPrototype.create方法的典型用法代码示例。如果您正苦于以下问题:Python AccountPrototype.create方法的具体用法?Python AccountPrototype.create怎么用?Python AccountPrototype.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类the_tale.accounts.prototypes.AccountPrototype
的用法示例。
在下文中一共展示了AccountPrototype.create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register_user
# 需要导入模块: from the_tale.accounts.prototypes import AccountPrototype [as 别名]
# 或者: from the_tale.accounts.prototypes.AccountPrototype import create [as 别名]
def register_user(nick, email=None, password=None, referer=None, referral_of_id=None, action_id=None, is_bot=False):
if Account.objects.filter(nick=nick).exists():
return REGISTER_USER_RESULT.DUPLICATE_USERNAME, None, None
if email and Account.objects.filter(email=email).exists():
return REGISTER_USER_RESULT.DUPLICATE_EMAIL, None, None
try:
referral_of = AccountPrototype.get_by_id(referral_of_id)
except ValueError:
referral_of = None
if (email and not password) or (not email and password):
raise exceptions.EmailAndPasswordError()
is_fast = not (email and password)
if is_fast and is_bot:
raise exceptions.BotIsFastError()
if password is None:
password = accounts_settings.FAST_REGISTRATION_USER_PASSWORD
account = AccountPrototype.create(nick=nick,
email=email,
is_fast=is_fast,
is_bot=is_bot,
password=password,
referer=referer,
referral_of=referral_of,
action_id=action_id)
AccountAchievementsPrototype.create(account)
AccountItemsPrototype.create(account)
market_logic.create_goods(account.id)
hero = HeroPrototype.create(account=account)
dress_new_hero(hero)
messages_for_new_hero(hero)
hero.save()
return REGISTER_USER_RESULT.OK, account.id, hero.actions.current_action.bundle_id