def add_institution(self,data): ed = Entity() ed.name = data['inst_name'] # ed.li_uniq_id = data['inst_uniq_id'] ed.type = 'organization' ed.sub_type = 'ed-institution' ed.li_type = 'school' ed.save() return ed
def add_institution(self,data): ed = Entity() ed.name = data['inst_name'] ed.type = 'organization' ed.subtype = 'ed-institution' ed.li_type = 'school' # ed.li_uniq_id = data['inst_uniq_id'] ## this will always be None ## No it won't.... but we don't need it anyway ed.save() if self.logging: print 'Add Institution: (' + str(ed.id) + ') ' + ed.name return ed
def add_unverified_company(self, data): """ Special case in which no co_uniq_name found, so we can't hit the LI API. Tries to create a stub company. Return: Entity || None """ if data["entity_name"] is not None: co = Entity() co.name = data["entity_name"] co.type = "organization" co.status = "unverified" co.save() return co else: return None
def add_company(self,id=None,name=None): # get company profile from LinkedIn if name is not None: data = self.fetch_co_li_profile(name=name) elif id is not None: data = self.fetch_co_li_profile(co_id=id) # if nothing returned from LI, return None if data is None: # TODO add company if name is not None: print "EDGE CASE: add_company, no data returned from LI: " + name if id is not None: print "EDGE CASE: add_company, no data returned from LI: " + str(id) return None # add to database co = Entity() co.name = data['name'] co.type = 'organization' ## V2 Edit -- make sure we get that id if 'id' in data: co.li_uniq_id = data['id'] if 'universalName' in data: co.li_univ_name = data['universalName'] if 'companyType' in data: # try to convert raw LI code to something more readble try: li_type = self.company_types[data['companyType']['code']] except: li_type = data['companyType']['code'] co.li_type = li_type if 'ticker' in data: co.ticker = data['ticker'] if 'websiteUrl' in data: co.web_url = data['websiteUrl'] # co.domain = data['industries'] # co.li_status = data['status'] if 'blog-url' in data: co.blog_url = data['blog-url'] if 'twitterId' in data: co.twitter_handle = data['twitterId'] if 'employeeCountRange' in data: co.size_range = data['employeeCountRange']['name'] if 'description' in data: co.description = data['description'] if 'stockExchange' in data: co.stock_exchange = data['stockExchange']['code'] co.li_last_scanned = datetime.now() co.save() # add industries # TODO add manager that handles this any time domain is added to co if 'industries' in data: for i in data['industries']['values']: # check to see if industry already exists industry = self.get_industry(i['name'],i['code']) if industry: # add industry to domain of company co.domains.add(industry) if self.logging: print '@addCompany(), found existing industry' else: # create new industry if self.logging: print "@ addCompany(), creating new industry: " + i['name'] + ' - ' + str(i['code']) industry = Industry() industry.name=i['name'] industry.li_code=int(i['code']) if industry.li_code in self.industry_groups: industry.li_group=self.industry_groups[industry.li_code] industry.save() # add to domain of company co.domains.add(industry) # check to see if company has a logo url if 'logoUrl' in data: # get company logo self.save_li_image(co,data['logoUrl']) # check to see if locations in company profile if 'locations' in data: # add offices if 'values' in data['locations']: for l in data['locations']['values']: self.add_office(co,l) if self.logging: print 'Add Company: (' + str(co.id) + ') ' + co.name + ' ' + str(co.li_uniq_id) return co
def add_company(self,id=None,name=None): # get company profile from LinkedIn if name is not None: data = self.get_co_li_profile(name=name) elif id is not None: data = self.get_co_li_profile(co_id=id) # if nothing returned from LI, return None if data is None: # TODO add company return None # add to database co = Entity() co.name = data['name'] co.type = 'organization' co.li_uniq_id = id # coValues = {'li_univ_name':'universalName','li_type':''} if 'universalName' in data: co.li_univ_name = data['universalName'] if 'companyType' in data: co.li_type = data['companyType']['code'] if 'ticker' in data: co.ticker = data['ticker'] if 'websiteUrl' in data: co.web_url = data['websiteUrl'] # co.domain = data['industries'] # co.li_status = data['status'] if 'blog-url' in data: co.blog_url = data['blog-url'] if 'twitterId' in data: co.twitter_handle = data['twitterId'] if 'employeeCountRange' in data: co.size_range = data['employeeCountRange']['name'] if 'description' in data: co.description = data['description'] if 'stockExchange' in data: co.stock_exchange = data['stockExchange']['code'] co.li_last_scanned = datetime.now() co.save() # add industries # TODO add manager that handles this any time domain is added to co if 'industries' in data: for i in data['industries']['values']: # check to see if industry already exists industry = self.get_industry(i['name'],i['code']) if industry: # add industry to domain of company co.domains.add(industry) else: # create new industry industry = Industry() industry.name=i['name'] industry.li_code=i['code'] industry.save() # add to domain of company co.domains.add(industry) # check to see if company has a logo url if 'logoUrl' in data: # get company logo self.save_li_image(co,data['logoUrl']) # check to see if locations in company profile if 'locations' in data: # add offices for l in data['locations']['values']: self.add_office(co,l) return co