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


Python Profile.user方法代码示例

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


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

示例1: registrar_usuario

# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import user [as 别名]
def registrar_usuario(request):
    if request.POST:
        f=RegistrationForm(request.POST)
        if f.errors:
            messages.error(request, 'El formulario contiene errores')
            return render_to_response("registro_caja.html", {'form':f}, RequestContext(request))
        else:
            data = f.cleaned_data
            user=User()
            user.username=data["username"]
            passwd=get_pronounceable_password(1,2)
            user.set_password(passwd)
            user.email = data['email']
            user.first_name = data['first_name']
            user.last_name = data['last_name']
            user.save()

            profile = Profile()
            profile.user=user
            profile.telefono = data['phone_number']
            profile.celular = data['cellphone']
            profile.direccion = data['address']
            profile.tipo = CLIENTE
            profile.save()
            
            messages.success(request, 'Usuario creado con exito')

            return render_to_response('mostrar_usuario.html', {'user':user,'passwd':passwd}, RequestContext(request))

    else:
        f=RegistrationForm()

    return render_to_response("registro_caja.html", {'form':f}, RequestContext(request))
开发者ID:job-s,项目名称:n-mat,代码行数:35,代码来源:views.py

示例2: register

# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import user [as 别名]
def register(request):
	if request.method == 'POST' and not request.user.is_authenticated():
		username = request.POST.get('username')
		email = request.POST.get('email')
		password = request.POST.get('password')
		confirm = request.POST.get('confirm')
		
		try:
			existing_user = User.objects.get(username=username)
			context = RequestContext(request, {'register_message': 'Username {} already exists.'.format(username)})
			return render(request, 'home.html', context)
		except ObjectDoesNotExist:
			pass
		
		try:
			existing_user = User.objects.get(email=email)
			context = RequestContext(request, {'register_message': 'E-mail {} already exists.'.format(email)})
			return render(request, 'home.html', context)
		except ObjectDoesNotExist:
			pass
			
		if password == confirm:
			new_user = User.objects.create_user(username, email=email, password=password)
			new_profile = Profile()
			new_profile.user = new_user
			new_profile.save()
			
			return redirect('home')
		else:
			context = RequestContext(request, {'register_message': 'Passwords do not match.'.format(email)})
			return render(request, 'home.html', context)
			
	else:
		return redirect('home')
开发者ID:adzierzanowski,项目名称:pinboard,代码行数:36,代码来源:views.py

示例3: add_agents

# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import user [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,代码来源:

示例4: form_valid

# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import user [as 别名]
 def form_valid(self, form):
     # profile 따로 저장해줌
     # 꼼수인데 방법이 되네요
     user = form.save()
     p = Profile()
     p.user = user
     p.save()
     messages.success(self.request, '계정이 생성되었습니다')
     return super(CreateUser, self).form_valid(form)
开发者ID:sebatyler,项目名称:django-bookmark,代码行数:11,代码来源:views.py

示例5: add_user

# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import user [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: register

# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import user [as 别名]
 def register(self, request, **cleaned_data):
     """Custom registration view.
     """
     print('Starting registration')
     print(cleaned_data)
     u = User.objects.create_user(
         cleaned_data['username'],
         '',
         cleaned_data['password1'])
     p = Profile()
     p.user = u
     p.save()
     messages.success(self.request,
                      'Thank you for registering. Now you can login.')
开发者ID:timbarnes,项目名称:QandAWeb,代码行数:16,代码来源:views.py

示例7: User

# 需要导入模块: from users.models import Profile [as 别名]
# 或者: from users.models.Profile import user [as 别名]
    except AtgUserMigrationMap.DoesNotExist:
        pass

    # Create a new profile
    try:
        auth_user = User()
        auth_user.username = safe_convert(atg_user.login, 40)
        auth_user.email = ''
        auth_user.password = '%s$%s$%s' % ('md5', '', atg_user.password)
        auth_user.save()
    except Exception, e:
        log.exception('Error creating auth_user for %s' % atg_user.login)
        return

    p = Profile()
    p.user = auth_user
    p.full_name = '%s %s %s' % (safe_convert(atg_user.first_name, 40, ''),
        safe_convert(atg_user.middle_name, 40, ''),
        safe_convert(atg_user.last_name, 40, ''))
    p.full_name = re.sub(' +', ' ', p.full_name) # Remove multiple spaces
    p.atg_login = safe_convert(atg_user.login, 40) 
    p.atg_password = safe_convert(atg_user.password, 35)
    p.save() # Save the profile

    map_entry = AtgUserMigrationMap(profile = p,
        atg_login = safe_convert(atg_user.login, 40))
    map_entry.save()

    if phone:
        phone.user = p
        phone.save()
开发者ID:,项目名称:,代码行数:33,代码来源:


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