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
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
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: '******'firstName'] + ' ' + user_info['lastName'] return user
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