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


Python Account.status方法代码示例

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


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

示例1: process_connection_and_finish_user

# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import status [as 别名]
	def process_connection_and_finish_user(self, user, user_info):
		"""
		Delegates to helpers to process rest of User, adds Account, maps positions
		Return: User
		"""

		## add LI account
		acct = Account()
		acct.owner = user
		acct.service = 'linkedin'
		acct.uniq_id = user_info['id']
		if 'publicProfileUrl' in user_info:
			acct.public_url = user_info['publicProfileUrl']
		acct.status = 'unlinked'
		acct.save()

		## Edge case that showed up in production
		if 'publicProfileUrl' not in user_info:
			return user
		
		## parse public page
		self.process_public_page_existing(user_info['publicProfileUrl'], user)

		## Map Positions
		# match all positions to ideals
		for p in user.positions.all():
			careerlib.match_position_to_ideals(p)
		# process first_ideal_position
		user.profile.set_first_ideal_job()

		return user
开发者ID:tchaymore,项目名称:prosperime,代码行数:33,代码来源:lilib.py

示例2: add_dormant_user

# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import status [as 别名]
	def add_dormant_user(self,user_info):

		# create dormant user account
		temp_username = user_info['firstName'] + user_info['lastName'] + user_info['id']
		temp_username = temp_username[:30]
		# self.stdout.write(temp_username)
		user = User()
		user.username = temp_username
		user.save()

		# create user profile
		user.profile.first_name = user_info['firstName']
		user.profile.last_name = user_info['lastName']
		if 'headline' in user_info:
			user.profile.headline = user_info['headline']		
		user.profile.status = "dormant"
		user.profile.save()

		# add pofile picture
		if 'pictureUrl' in user_info:
			self.add_profile_pic(user,user_info['pictureUrl'])

		# create LinkedIn account
		acct = Account()
		acct.owner = user
		acct.service = 'linkedin'
		acct.uniq_id = user_info['id']
		if 'publicProfileUrl' in user_info:
			acct.public_url = user_info['publicProfileUrl']
		acct.status = "unlinked"
		acct.save()

		return user
开发者ID:tchaymore,项目名称:prosperime,代码行数:35,代码来源:liparse.py

示例3: add_dormant_user

# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import status [as 别名]
	def add_dormant_user(self,user_info):

		# compile temporary user name
		temp_username = user_info['firstName'] + user_info['lastName'] + user_info['id']
		temp_username = temp_username[:30]
		
		# check to see if user already exists
		try:
			user = User.objects.get(username=temp_username)
		except ObjectDoesNotExist:
			# create dormant user account
			user = User()
			user.username = temp_username
			user.is_active = False
			user.save()

		# create user profile
		user.profile.first_name = user_info['firstName']
		user.profile.last_name = user_info['lastName']
		if 'headline' in user_info:
			user.profile.headline = user_info['headline']		
		user.profile.status = "dormant"
		user.profile.save()

		# add pofile picture
		if 'pictureUrl' in user_info:
			self.add_profile_pic(user,user_info['pictureUrl'])

		# create LinkedIn account
		
		acct = Account()
		acct.owner = user
		acct.service = 'linkedin'
		acct.uniq_id = user_info['id']
		if 'publicProfileUrl' in user_info:
			acct.public_url = user_info['publicProfileUrl']
		acct.status = "unlinked"
		acct.save()

		if self.logging:
			print 'Add Dormant User: ' + user_info['firstName'] + ' ' + user_info['lastName']

		return user
开发者ID:tchaymore,项目名称:prosperime,代码行数:45,代码来源:lilib.py

示例4: process_connection_and_create_user

# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import status [as 别名]
	def process_connection_and_create_user(self, user_info):
		"""
		Delegates to helpers to try and create User object. If successful, creates Account object, maps positions.
		Return: User || None
		"""

		## Edge case that showed up in production
		if 'publicProfileUrl' not in user_info:
			return None
		
		## go to purl, parse, create user, profile, return user
		user = self.process_public_page_full(user_info['publicProfileUrl'], user_info['id'])
		
		if user is not None:
			## Add picture url from user_info b/c not crawlable
			if 'pictureUrl' in user_info:
				self.add_profile_pic(user, user_info['pictureUrl'])

			## Create account
			acct = Account()
			acct.owner = user
			acct.service = 'linkedin'
			acct.uniq_id = user_info['id']
			if 'publicProfileUrl' in user_info:
				acct.public_url = user_info['publicProfileUrl']
			acct.status = "unlinked"
			acct.save()

			## Match Positions
			# match all positions to ideals
			for p in user.positions.all():
				careerlib.match_position_to_ideals(p)
			# process first_ideal_position
			user.profile.set_first_ideal_job()

			return user
		else:
			return None
开发者ID:tchaymore,项目名称:prosperime,代码行数:40,代码来源:lilib.py

示例5: finish_login

# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import status [as 别名]
def finish_login(request):
	# TODO: redirect if not not authenticated through LinkedIn already
	
	# if request.POST:
	if request.method == "POST":
		# form submitted
		form = FinishAuthForm(request.POST)
		if form.is_valid():
			from accounts.models import Pref
			import accounts.emaillib as emaillib
			# grab cleaned values from form
			username = form.cleaned_data['username']
			email = form.cleaned_data['email']
			# location = form.cleaned_data['location']
			# headline = form.cleaned_data['headline']
			password = form.cleaned_data['password']

			# fetch LI data
			linkedin_user_info = request.session['linkedin_user_info']
			access_token = request.session['access_token']

			# check to see if dormant user already exists
			try: 
				print '@ accounts.finish -- checking for dormant user'
				user = User.objects.get(profile__status="dormant",account__uniq_id=linkedin_user_info['id'])
				existing = True
				user.profile.status = "active"
				user.profile.save()
				user.set_password(password)
				user.username = username
				user.is_active = True
				user.save()
				print "@ accounts.finish -- user already exists"
			except:
				print '@ accounts.finish -- new user'
				# create user
				user = User.objects.create_user(username,email,password)
				user.save()
				
				existing = False
				user.profile.status = "active"
				user.profile.save()
				print "@ accounts.finish -- created new user"
			# send welcome email
			welcome = emaillib.WelcomeEmail(user)
			welcome.send_email()
			# add email prefs
			if form.cleaned_data['notification']:
				pref = Pref(user=user,name="notification",value=1)
				pref.save()
			else:
				pref = Pref(user=user,name="notification",value=0)
				pref.save()
			# make sure using right backend
			request.session['_auth_user_backend'] = 'django.contrib.auth.backends.ModelBackend'
			# log user in
			user = authenticate(username=username,password=password)
			
			# make sure authentication worked
			if user is not None:
				print 'in to auth login'
				auth_login(request,user)
			else:
				# try logging in now with LinkedIn
				request.session['_auth_user_backend'] = 'prosperime.accounts.backends.LinkedinBackend'
				try:
					user = authenticate(acct_id=linkedin_user_info['id'])
					if user is not None:
						auth_login(request,user)	
				except:
					# somehow authentication failed, redirect with error message
					messages.error(request, 'Something went wrong. Please try again.')
					return render_to_response('accounts/finish_login.html',{'form':form},context_instance=RequestContext(request))



			# update user profile
			# user.profile.full_name = request.session['linkedin_user_info']['firstName'] + " " + request.session['linkedin_user_info']['lastName']		
			user.profile.first_name = linkedin_user_info['firstName']
			user.profile.last_name = linkedin_user_info['lastName']
			# user.profile.location = location
			# check to see if user provided a headline
			# if headline:
			# 	user.profile.headline = headline
			# else:
			user.profile.headline = linkedin_user_info['headline']
			user.profile.save()

			# add pofile picture
			# if 'pictureUrl' in linkedin_user_info:
			# 	# _add_profile_pic(user,linkedin_user_info['pictureUrl'])
			# 	li_parser = LIProfile()
			# 	li_parser.add_profile_pic(user,linkedin_user_info['pictureUrl'])

			if 'pictureUrls' in linkedin_user_info:
				li_parser = LIProfile()
				li_parser.add_profile_pic(user,linkedin_user_info['pictureUrls']['values'][0])


			if existing:
#.........这里部分代码省略.........
开发者ID:tchaymore,项目名称:prosperime,代码行数:103,代码来源:views.py

示例6: finish_registration_old

# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import status [as 别名]
def finish_registration_old(request):

	import accounts.emaillib as emaillib
	# get linkedin info from session
	linkedin_user_info = request.session['linkedin_user_info']
	access_token = request.session['access_token']

	# check for dormant user
	try: 
		user = User.objects.get(profile__status="dormant",account__uniq_id=linkedin_user_info['id'])
		user.email=linkedin_user_info['emailAddress']
		logger.info("activated dormant user "+linkedin_user_info['emailAddress'])
		existing = True
	except:
		# create user
		user = User.objects.create_user(linkedin_user_info['emailAddress'],linkedin_user_info['emailAddress'])
		logger.info("created new user "+linkedin_user_info['emailAddress'])
		user.save()
		existing = False
		
	# set user properties
	password = User.objects.make_random_password()
	user.set_password(password)
	user.save()	
	# set profile status
	user.profile.status = "active"
	user.profile.first_name = linkedin_user_info['firstName']
	user.profile.last_name = linkedin_user_info['lastName']
	user.profile.save()
	user.username = linkedin_user_info['emailAddress']
	user.is_active = True
	user.save()	
	
	# send welcome email
	welcome = emaillib.WelcomeEmail(user)
	welcome.send_email()
	logger.info("sent welcome email to user: "+linkedin_user_info['emailAddress'])
	
	# check to see if user provided a headline
	if 'headline' in linkedin_user_info:
		user.profile.headline = linkedin_user_info['headline']
		user.profile.save()
	# check to see if user has a linkedin picture
	if 'pictureUrls' in linkedin_user_info:
		li_parser = LIProfile()
		li_parser.add_profile_pic(user,linkedin_user_info['pictureUrls']['values'][0])

	# update LI account
	if existing:
		# get existing LI account
		acct = Account.objects.get(owner=user,service="linkedin")
	else:
		# create LinkedIn account
		acct = Account()
	
	acct.owner = user
	acct.access_token = access_token['oauth_token']
	acct.token_secret = access_token['oauth_token_secret']
	acct.service = 'linkedin'
	acct.expires_on = datetime.now() + timedelta(seconds=int(access_token['oauth_authorization_expires_in']))
	acct.uniq_id = linkedin_user_info['id']
	acct.status = "active"
	acct.save()
		
	# finish processing LI profile
	profile_task = process_li_profile.delay(user.id,acct.id)

	# start processing connections
	connections_task = process_li_connections.delay(user.id,acct.id)

	# save task ids to session
	request.session['tasks'] = {
		'profile': profile_task.id,
		'connections': connections_task.id
	}

	request.session['_auth_user_backend'] = 'prosperime.accounts.backends.LinkedinBackend'
	
	user = authenticate(acct_id=linkedin_user_info['id'])
	
	if user is not None:
	
		auth_login(request,user)

		if 'next' not in request.session:
			return HttpResponseRedirect('/majors/')
		else:
			return HttpResponseRedirect(request.session['next'])
开发者ID:tchaymore,项目名称:prosperime,代码行数:90,代码来源:views.py


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