当前位置: 首页>>代码示例>>Python>>正文


Python UserProfile.forecast_email方法代码示例

本文整理汇总了Python中accounts.models.UserProfile.forecast_email方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.forecast_email方法的具体用法?Python UserProfile.forecast_email怎么用?Python UserProfile.forecast_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在accounts.models.UserProfile的用法示例。


在下文中一共展示了UserProfile.forecast_email方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_new_user

# 需要导入模块: from accounts.models import UserProfile [as 别名]
# 或者: from accounts.models.UserProfile import forecast_email [as 别名]
def create_new_user(email, name = None):
    ups = UserProfile.objects.filter(email = email)
    if len(ups) > 0:
        print (len(ups))
        print ("User(s) with email {} already exists, aborting user creation!".
                format(email))
        return None

    username = new_user_name()
    user = User.objects.create_user(username, email = None, password = None)
    user.is_active = True
    user.is_staff = False
    user.is_superuser = False
    # The following fields are fields we store in the UserProfile object instead
    #   user.first_name
    #   user.last_name
    #   user.email
    user.save()

    up = UserProfile()
    up.user = user
    up.password_is_set = False
    up.magic_login_code = random.randint(100000000, 999999999)
    # If the user doesn't specify a name, email is used as the default
    if name is None:
        up.name = email
    else:
        up.name = name
    up.email = email
    up.phone = ''
    up.verification_code = new_phone_verification_number()
    up.is_verified = False
    up.state = 'CA'

    up.message_frequency = 3
    up.forecast_email = False
    up.set_equipment([])
    up.beta_test = True

    # In the future, we should separate phone-number, etc., into a separate model

    up.save()

    print ("User {} created.".format(email))
    return user
开发者ID:colinmccormick,项目名称:watttime,代码行数:47,代码来源:views.py


注:本文中的accounts.models.UserProfile.forecast_email方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。