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


Python Profile.full_name方法代码示例

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


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

示例1: create_user

# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import full_name [as 别名]
def create_user(username, email_id="", password=None, first_name="", last_name=""):
    """ This function called for new user sign up on p. interface. Thus username should be a valid phone number."""
    usr = None
    profile = None
    if not username:
        return usr, profile
    username = username.strip()
    is_type = "id"
    if is_valid_mobile(username):
        is_type = "mobile"
        try:
            usr = User(username=username, email="")
            if password is None or password == "":
                # use set_unusable_password to allow user to set his password in future
                usr.set_unusable_password()
            else:
                usr.set_password(password)
            if first_name:
                usr.first_name = first_name
            if last_name:
                usr.last_name = last_name
            usr.save()
            profile = Profile(
                user=usr, created_on=datetime.now(), primary_phone="", primary_email="", secondary_email=""
            )
            if first_name and last_name:
                profile.full_name = "%s %s" % (first_name, last_name)
            profile.save()
            phone = Phone(user=profile, phone=username, type="primary")
            phone.is_verified = True
            phone.verified_on = datetime.now()
            phone.save()
        except Exception, e:
            log.exception("Error create_user username: %s  Exception: %s" % (username, repr(e)))
            return None, None
开发者ID:,项目名称:,代码行数:37,代码来源:

示例2: add_agents

# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import full_name [as 别名]
def add_agents():
    from users.models import Profile
    from django.contrib.auth.models import User

    f = open('chaupaati')
    lines = f.readlines()
    for line in lines:
        print line
        line = line.strip()
        print line.split(',')
        password, name, loginid = line.split(',')
        name = name.strip()
        first_name = name.split(' ')[0]
        loginid = loginid.strip()
        password = password.strip()
        u = User.objects.create_user(loginid, '[email protected]', password)
        u.name = name
        u.save()

        agent = Profile()
        agent.user = u
        agent.full_name = '%s%s' % (name,password)
        agent.primary_phone = '%s%s' % (first_name,password)
        agent.is_agent = True
        agent.save()
开发者ID:,项目名称:,代码行数:27,代码来源:

示例3: get_or_create_user

# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import full_name [as 别名]
def get_or_create_user(username, email_id="", password=None, first_name="", last_name=""):
    usr = None
    profile = None
    if not username:
        return usr, profile
    username = username.strip()
    is_type = "id"
    if is_valid_mobile(username):
        is_type = "mobile"
        try:
            phone = Phone.objects.get(phone=username)
            profile = phone.user
            usr = profile.user
        except Phone.DoesNotExist:
            try:
                usr = User.objects.get(username=username)
            except User.DoesNotExist:
                usr = User(username=username, email="")
                if password is None or password == "":
                    # use set_unusable_password to allow user to set his password in future
                    usr.set_unusable_password()
                else:
                    usr.set_password(password)
            if first_name:
                usr.first_name = first_name
            if last_name:
                usr.last_name = last_name
            usr.save()
            try:
                profile = Profile.objects.get(user=usr)
            except Profile.DoesNotExist:
                profile = Profile(
                    user=usr, created_on=datetime.now(), primary_phone="", primary_email="", secondary_email=""
                )
                profile.full_name = "%s %s" % (first_name, last_name)
            if first_name and last_name:
                profile.full_name = "%s %s" % (first_name, last_name)
            profile.save()
            phone = Phone(user=profile, phone=username, type="primary")
            phone.save()
        except Exception, e:
            log.exception("Error get_or_create_user %s" % repr(e))
            return None, None
开发者ID:,项目名称:,代码行数:45,代码来源:

示例4: attach_fb

# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import full_name [as 别名]
def attach_fb(request):
    if request.method == "POST":
        data = request.POST
        facebookid = data["id"]
        email = data["email"]
        first_name = data["first_name"]
        last_name = data["last_name"]

        user, profile = None, None
        u_email = None
        try:
            u_email = UserEmail.objects.get(email=email)
            profile = u_email.user
            user = profile.user
        except UserEmail.DoesNotExist:
            try:
                user = User.objects.get(Q(email=email) | Q(username=email))
            except User.DoesNotExist:
                user = User.objects.create_user(email, email, None)
                user.first_name = first_name
                user.last_name = last_name
                user.save()
        if not user.first_name:
            user.first_name = first_name
            user.save()
        if not user.last_name:
            user.last_name = last_name
            user.save()

        try:
            profile = Profile.objects.get(user=user)
        except Profile.DoesNotExist:
            profile = Profile(user=user, full_name="%s %s" % (first_name, last_name))
        # if not profile.full_name: overwrite facebook name
        profile.full_name = "%s %s" % (first_name, last_name)
        profile.facebook = facebookid
        profile.save()
        if not u_email:
            u_email = UserEmail(email=email, user=profile, type="subscription")
            u_email.save()
        if request.user:
            auth.logout(request)
            request.session.flush()
        user = auth.authenticate(facebook_user=user, **dict(request=request))
        request.session["logged_through_facebook"] = True
        if user:
            request.session["atg_username"] = user.username
            set_logged_in_user(request, user)
            log.info("FACEBOOK USER LOGGED IN: %s" % user)
            return HttpResponse("OK")
    else:
        return HttpResponse("OK")
    return HttpResponse("FAILED")
开发者ID:,项目名称:,代码行数:55,代码来源:

示例5: add_user

# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import full_name [as 别名]
def add_user(doc):
    if doc['mobile'] in sellers: return

    u = User()
    try:
        u = User.objects.get(username=doc['mobile'])
    except User.DoesNotExist:
        pass
    u.username = doc['mobile']
    if 'timestamp' in doc:
        u.timestamp = doc['timestamp'].strftime('%Y-%m-%d %H:%M:%S')
    else:
        if 'modificationTime' in doc:
            u.timestamp = doc['modificationTime'].strftime('%Y-%m-%d %H:%M:%S')
    u.save()

    p = Profile()
    try:
        p = Profile.objects.get(primary_phone=doc['mobile'])
        if p.id != doc['id']:
            record_duplicate(p.id, doc['id'])
            return
    except Profile.DoesNotExist:
        pass

    p.id = doc['id']
    p.user = u
    p.full_name = doc.get('name','')
    p.gender = doc.get('gender','').lower()
    if len(p.gender) > 1:
        p.gender = p.gender[0]
    if doc.get('dateOfBirth',None):
        p.date_of_birth = doc['dateOfBirth'].strftime('%Y-%m-%d')

    p.primary_phone = doc['mobile']
    p.secondary_phone = doc.get('mobile2','')

    p.primary_email = doc.get('email','').split(',')[0]
    p.secondary_email = doc.get('email2','').split(',')[0]

    p.buyer_or_seller = 'buyer'
    p.type = doc.get('type','individual')

    p.marketing_alerts = doc.get('dealAlerts','neutral')

    p.salt = doc.get('salt','')
    p.passcode = doc.get('passcode','')


    p.created_on = u.timestamp
    p.save()
开发者ID:,项目名称:,代码行数:53,代码来源:

示例6: User

# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import full_name [as 别名]
                except User.DoesNotExist:
                    usr = User(username=username, email=username)
                    if password is None or password == "":
                        usr.set_unusable_password()
                    else:
                        usr.set_password(password)
                if first_name:
                    usr.first_name = first_name
                if last_name:
                    usr.last_name = last_name
                usr.save()
                try:
                    profile = Profile.objects.get(user=usr)
                except Profile.DoesNotExist:
                    profile = Profile(user=usr, created_on=datetime.now())
                    profile.full_name = "%s %s" % (first_name, last_name)
                if first_name and last_name:
                    profile.full_name = "%s %s" % (first_name, last_name)
                profile.save()
                email = Email(user=profile, email=username, type="primary", cleaned_email=clean_username)
                email.save()
        except Exception, e:
            log.exception("Error get_or_create_user %s" % repr(e))
            return None, None
    log.info("get_or_create_user is_type is %s" % is_type)
    return usr, profile


def formatMoney(value):
    try:
        str_value = str(value).split(".")[0]
开发者ID:,项目名称:,代码行数:33,代码来源:


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