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


Python Profile.user方法代码示例

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


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

示例1: thanks

# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import user [as 别名]
def thanks(request, redirect_url=settings.LOGIN_REDIRECT_URL):

    # Now that we've got the magic tokens back from Twitter, we need to exchange
    # for permanent ones and store them...
    oauth_token = request.session['request_token']['oauth_token']
    oauth_token_secret = request.session['request_token']['oauth_token_secret']
    twitter = Twython(settings.TWITTER_KEY, settings.TWITTER_SECRET,
                      oauth_token, oauth_token_secret)

    # Retrieve the tokens we want...
    authorized_tokens = twitter.get_authorized_tokens(request.GET['oauth_verifier'])

    # If they already exist, grab them, login and redirect to a page displaying stuff.
    try:
        user = User.objects.get(username=authorized_tokens['screen_name'])

    except User.DoesNotExist:

        # We mock a creation here; no email, password is just the token, etc.
        user = User.objects.create_user(authorized_tokens['screen_name'], "[email protected]", authorized_tokens['oauth_token_secret'])
        profile = Profile()
        profile.user = user
        profile.oauth_token = authorized_tokens['oauth_token']
        profile.oauth_secret = authorized_tokens['oauth_token_secret']
        profile.save()


    user = authenticate(
        username=authorized_tokens['screen_name'],
        password=authorized_tokens['oauth_token_secret']
    )
    login(request, user)
    redirect_url = request.session.get('next_url', redirect_url)

    return HttpResponseRedirect("/")
开发者ID:jparicka,项目名称:twitter-tools,代码行数:37,代码来源:views.py

示例2: create_profile

# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import user [as 别名]
def create_profile(user, gender=None, lname=None):

    if gender is None:
        gender = get_random_gender()


    fname = get_random_fname(gender)

    if lname is None:
        lname = get_random_lname()

    zc = get_random_zip()
    photo = adult_photo(gender)

    profile = Profile()        
    profile.user = user
    profile.first_name = fname
    profile.last_name = lname
    profile.zip_code = zc
    profile.gender = gender

    profile.save()

    f = open(photo, 'r')
    np = Photo(album=profile.album, caption="Profile", original_image=File(f))
    np.save()

    profile.set_profile_pic(np)

    return profile 
开发者ID:braskin,项目名称:pd,代码行数:32,代码来源:fake.py

示例3: create_profile

# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import user [as 别名]
def create_profile(user, fname, lname, zip):

    profile = Profile()        
    profile.user = user
    profile.first_name = fname
    profile.last_name = lname
    profile.zip_code = zip

    profile.save()
    
    return profile 
开发者ID:braskin,项目名称:pd,代码行数:13,代码来源:management.py

示例4: save

# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import user [as 别名]
    def save(self, commit=True):
        user = super(RegistrationForm, self).save(commit=False)

        if commit:
            user.backend='django.contrib.auth.backends.ModelBackend'
            user.save()
            
            user_profile = Profile()
            user_profile.user = user
            user_profile.phone = self.cleaned_data["phone"]
            user_profile.save()
        
        return user
开发者ID:kenansubasi,项目名称:foodsecrets,代码行数:15,代码来源:forms.py

示例5: activate_account

# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import user [as 别名]
def activate_account(request,account_activation_key = None):
    csrfContext = RequestContext(request)
    try:
	key = ConfirmationKey.objects.get(key = account_activation_key,function = 'signup')
    except ConfirmationKey.DoesNotExist:
	request.flash["error"] = _(u"The supplied key does not exist.")
	raise Http404
    if not key.is_valid:
		return render_to_response('information.html',{'title':_(u"User account already activated"),'text':_(u"It seems that your user account has already been activated.")},csrfContext)
    if User.objects.filter(email = key.email,profile__isnull = False).count():
	return render_to_response('information.html',{'title':_(u"A user with this e-mail address already exists."),'text':_(u"We are sorry, but the e-mail address you have chosen is already associated to a user account.")},csrfContext)
    else:
	data = key.get_data()
	user = User()
	profile = Profile()

	obsolete_users = User.objects.filter(email = key.email)

	for obsolete_user in obsolete_users:
	    obsolete_user.email = ''
	    obsolete_user.save()

	user.username = generate_random_key()
	user.email = key.email
	user.set_password(data["password"])

	notify_staff({'title':'New user account','text':"Somebody with email %s has created a new user account." % key.email},notification_object = user)

	user.save()

	profile.user = user
	profile.has_verified_email = True
	profile.is_active = True
	profile.has_beta_key = True

	profile.save()
	
	#We remove the sensitive password from the key's data.
	del data["password"]
	key.set_data(data)
	key.invalidate()
	

	_directly_login_user(request,profile.user)

	csrfContext = RequestContext(request)
	next_url = None
	if 'next_url' in data:
	    next_url = data['next_url']
	return render_to_response('profiles/activate_account.html', {'next_url':next_url},csrfContext)
开发者ID:slangwald,项目名称:goritly-old,代码行数:52,代码来源:views.py

示例6: create_profile

# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import user [as 别名]
    def create_profile(self, user, commit=True):
        community = Community.objects.get(pk=self.cleaned_data["community"])
        disease = Disease.objects.get(pk=self.cleaned_data["disease"].id)
        gender = self.cleaned_data["gender"]

        profile = Profile()
        profile.disease = disease
        profile.community = community
        profile.gender = gender
        profile.birth_date = self.cleaned_data["birth_date"]

        profile.user = user
        if commit:
            profile.save()
        return profile
开发者ID:fmaj7,项目名称:mymd,代码行数:17,代码来源:forms.py

示例7: create_profile

# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import user [as 别名]
 def create_profile(self, user=None, profile_data=None, commit=True):
     profile = Profile()
     if user is None:
         raise NotImplementedError("SignupForm.create_profile requires a valid user")
         
     profile.user = user
     profile.first_name = profile_data["first_name"]
     profile.last_name = profile_data["last_name"]
     profile.zip_code = profile_data["zip_code"]
     profile.gender = profile_data["gender"]
     profile.source = profile_data["source"]
     
     profile.save()
     
     return profile 
开发者ID:braskin,项目名称:pd,代码行数:17,代码来源:forms.py

示例8: save

# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import user [as 别名]
    def save(self, commit=True):
        user = super(RegistrationForm, self).save(commit=False)


        if commit:
            user.backend='django.contrib.auth.backends.ModelBackend'
            user.save()
            user_profile = Profile()
            user_profile.user = user
            user_profile.save()


            department = Department.objects.get(department_Name=self.cleaned_data['department_name'])
            department.department_Members.add(user)
        
        return user
开发者ID:tolgahanuzun,项目名称:Document-Share,代码行数:18,代码来源:forms.py

示例9: create_profile

# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import user [as 别名]
def create_profile(user, profile_data, commit=True):
    profile = Profile()
    if user is None:
        raise NotImplementedError("SignupForm.create_profile requires a valid user")

    profile.user = user
    profile.first_name = profile_data["first_name"]
    profile.last_name = profile_data["last_name"]
    profile.fb_account_linked = profile_data["fb_account_linked"]
    profile.fb_id = profile_data["fb_id"]
    profile.fb_stream_publish = profile_data["fb_stream_publish"]
    profile.source = profile_data["source"]
    profile.gender = profile_data["gender"]
    profile.fb_login = profile_data["fb_login"]
    profile.zip_code = profile_data["zip_code"]

    profile.save()

    return profile
开发者ID:braskin,项目名称:pd,代码行数:21,代码来源:views.py

示例10: setUp

# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import user [as 别名]
    def setUp(self):
        ### USERS ###
        self.password = '123'

        ferromet = User()
        ferromet.username = 'ferromet'
        ferromet.first_name = 'FERROMET'
        ferromet.set_password(self.password)
        ferromet.save()

        admin = User()
        admin.username = 'admin'
        admin.first_name = 'Главный куратор'
        admin.set_password(self.password)
        admin.save()

        ### PROFILES ###

        profile1 = Profile()
        profile1.user = admin
        profile1.is_company = False
        profile1.is_report = True
        profile1.is_super_user = True
        profile1.telefon = '+7 921 622 22 50'
        profile1.save()

        profile2 = Profile()
        profile2.user = ferromet
        profile2.save()

        ### COMPANYS ###


        fer_com = Company()
        fer_com.com_user = ferromet
        fer_com.save()


        ### DEPS ###

        dep1 = Departments()
        dep1.pk = 1
        dep1.company = fer_com
        dep1.name = u'Основной'
        dep1.save()

        ### PC ###

        pc1 = CompanyPC()
        pc1.id = 1
        pc1.company = fer_com
        pc1.departament = dep1
        pc1.pc_nameId = '1'
        pc1.pc_name = 'buh'
        pc1.save()

        ### PC_OPTIONS ###

        option1 = PcOptions()
        option1.id = 1
        option1.name = u'Процессор'
        option1.save()
开发者ID:Alexandrov-Michael,项目名称:helpdesk,代码行数:64,代码来源:tests.py


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