def create_table_company(self, user): print(user) company = Company() company.user_id = user.id company.name = user.username db.session.add(company) db.session.commit()
def fake_company(self): for company in self.lagou.company: c = User( name=company['companyShortName'], email=fake.email(), role=User.ROLE_COMPANY ) c.password = '******' db.session.add(c) try: db.session.commit() except: db.session.rollback() continue d = Company( logo='https://static.lagou.com/thumbnail_160x160/' + company['companyLogo'], site='https://shiyanlou.com', location=company['city'], field=company['industryField'], finance_stage=company['financeStage'] ) d.user_id = c.id db.session.add(d) db.session.commit()
def fake_company(self): for company in self.lagou.company: c = User( name=company['companyShortName'], email=fake.email(), role=User.ROLE_COMPANY ) c.password = '******' db.session.add(c) try: db.session.commit() except: db.session.rollback() continue d = Company( name=company['companyShortName'], logo_uri='https://static.lagou.com/thumbnail_160x160/' + company['companyLogo'], website='https://shiyanlou.com', introduction=['companyFeatures'], city=company['city'], domain=company['industryField'], finance=company['financeStage'] ) d.user_id = c.id db.session.add(d) db.session.commit()
def create_company(self): company = Company() company.name = self.company.data db.session.add(company) db.session.commit() self.create_user(company.id) return company
def update_profile(self, user): if user.company: company = user.company else: company = Company() company.user_id = user.id self.populate_obj(company) db.session.add(user) db.session.add(company) db.session.commit()
def updated_profile(self, user): user.username = self.username.data user.email = self.email.data if self.password.data: user.password = self.password.data if user.company_detail: company = user.company_detail else: company = Company() company.user_id = user.id if self.slug.data: company.slug = self.slug.data if self.location.data: company.location = self.location.data if self.site.data: company.site = self.site.data if self.logo.data: company.logo = self.logo.data if self.description.data: company.description = self.description.data if self.about.data: company.about = self.about.data db.session.add(user) db.session.add(company) db.session.commit()
def update(self, company): if self.password.data: company.password = self.password.data if company.company_msg: company_msg = company.company_msg else: company_msg = Company() company_msg.user_id = company.id self.populate_obj(company) self.populate_obj(company_msg) db.session.add(company_msg) db.session.add(company) db.session.commit()
def fake_data(self): for company in self.companies[:]: print(company["name"]) # 创建企业用户 c = User( username=company["name"], email=fake.email(), role=User.ROLE_COMPANY ) c.password = "******" db.session.add(c) try: db.session.commit() except: db.session.rollback() continue # 创建企业信息 d = Company( name=company["name"], email=c.email, logo=company["logo"], site=company["site"], location=company["localtion"], description = company["description"], about = company["about"].strip("0/1000取消保存").strip("关于我们"), tags=company["tags"] ) d.user_id = c.id db.session.add(d) db.session.commit() # 发布企业职位 job_list = self.get_job(company["id"]) for item in job_list: job = Job( name=item["name"], salary_low=int(item["salary_low"].strip("k")) * 1000, salary_high=int(item["salary_high"].strip("k")) * 1000, location=item["location"], tags=item["tags"], experience_requirement=item["experience_requirement"], degree_requirement=item["degree_requirement"], description =item["raw_description"] ) job.company_id = d.id db.session.add(job) db.session.commit()
def update_profile(self, user): user.username = self.username.data user.email = self.email.data if user.detail: detail = user.detail else: detail = Company() detail.user_id = user.id detail.contact = 'x' self.populate_obj(detail) db.session.add(user) db.session.add(detail) db.session.commit()
def updated_profile(self, company): company.name = self.name.data company.email = self.email.data if self.password.data: company.password = self.password.data if company.company_msg: company_msg = company.company_msg else: company_msg = Company() company_msg.user_id = company.id self.populate_obj(company_msg) db.session.add(company_msg) db.session.add(company) db.session.commit()
def update_company(self, user=None): company = Company(name=self.name.data, address=self.address.data, website=self.website.data, url=self.logo.data, description=self.description.data) if user: company.user = user db.session.add(company) db.session.commit() return company
def update_company(self,user): user.username = self.name.data user.email = self.email.data if self.password.data: user.password = self.password.data if user.companies: companies = user.companies else: companies = Company() companies.users_id = user.id self.populate_obj(companies) db.session.add(user) db.session.add(companies) db.session.commit()
def ComupForm(self, user): user.username = self.name.data user.email = self.email.data user.role = 20 if self.password.data: user.password = self.password.data if user.company: company = user.company else: company = Company() company.user_id = user.id self.populate_obj(company) db.session.add(user) db.session.add(company) db.session.commit()
def updated_profile(self, user): user.name = self.name.data user.email = self.email.data if self.password.data: user.password = self.password.data if user.detail: detail = user.detail else: detail = Company() detail.user_id = user.id self.populate_obj(detail) db.session.add(user) db.session.add(detail) db.session.commit()
def iter_companys(): photo = get_photo() for company in company_detail: name = company['name'] user = User.query.filter_by(username=name).first() phone = fake.phone_number() yield Company(user_id=user.id, name=user.username, logo=company['image_urls'], web_url=company['web_url'], found_date=fake.date(), city=company['city'], address=fake.address(), scale=randint(0, 4), industry=company['industry'], email=fake.email(), phone=phone, fax=phone, manager_name=fake.name(), manager_job=fake.job(), manager_photo=next(photo), slogan=company['slogan'], products_display=fake.sentence(), description=company['description'])
def test_com(self,db): assert Company.query.count() == 0 com = Company(name='测试公司',website='测试阿里爷爷网站',description='testing...') db.session.add(com) db.session.commit() assert Company.query.count() == 0
def add_company(self): company = Company() self.populate_obj(company) db.session.add(company) db.session.commit() flash("添加成功", 'success') return user
def update(self, company): company.username = self.username.data company.email = self.email.data company.phone = self.phone.data if self.password.data: company.password = self.password.data if company.detail: detail = company.detail else: detail = Company() detail.user_id = company.id detail.website = self.website.data detail.description = self.description.data db.session.add(company) db.session.add(detail) db.session.commit()
def item_jobs(): with open("jobs.json", 'r', encoding="utf8") as f: jobs = json.load(f) print(jobs) job_list = [] company_list = [] for job in jobs: company = Company(name=job["company"], address=job["address"], net_site=job["net_site"], logo=job["logo"], introduce=faker.sentence(), detail=job["desc"], city=job["city"], financing=job["financing"], company_field=job["company_field"], company_scale=job['company_scale']) jobdata = Job(job_title=job['job_title'], work_experience=job['work_experience'], study_experience=job['study_experience'], salary_range=job['xinshui'], work_tags=job['work_tags'], company_msg=company) job_list.append(jobdata) company_list.append(company) return job_list, company_list
def iter_personal(): for user in User.query: print('user.role',user.role) if user.role == 10: yield Personal( user_id=user.id, name=f.name(), phone=f.phone_number(), jobyear=f.random_int(0,100), ) elif user.role == 20: with open(os.path.join(os.path.dirname(__file__), '..', 'datas', 'datas.json')) as e: companys = json.load(e) for company in companys: yield Company( user_id=user.id, name=company['company_name'], #name=Unicode()+f.company(), address=company['city'], url='https://www.baidu.com', phone=f.phone_number(), summary=f.sentence(), field=company['field'], financing=company['financing'], logo=company['company_image_url'], )
def create_user_and_company(): with open('scripts/data_company.json') as f1, \ open('scripts/data_job.json') as f2: job_name_list = [i['name'] for i in json.load(f2)] experience_list = ['不限', '1-3年', '3-5年', '5-10年'] degree_list = ['不限', '本科', '博士后'] for i in json.load(f1): user = User(username=fake.name(), email=fake.email()) user.password = '******' yield user company = Company( name = i['name'], logo = i['logo'], location = i['location'], description = i['description'], about = i['about'] if len(i['about']) > 9 else \ fake.sentence(nb_words=11), tags = i['tags'], user = user, ) yield company for i in range(randint(1, 5)): job = Job( name = job_name_list[randint(1, len(job_name_list))-1], salary_low = randint(3, 8) * 1000, salary_high = randint(9, 15) * 1000, location = fake.address(), is_fulltime = 1, experience_requirement = experience_list[ randint(1, len(experience_list)) - 1], degree_requirement = degree_list[ randint(1, len(degree_list)) - 1], company = company ) yield job
def iter_personal(): for user in User.query: print('user.role',user.role) if user.role == 10: yield Personal( user_id=user.id, name=f.name(), phone=f.phone_number(), jobyear=f.random_int(0,100), ) elif user.role == 20: name = Unicode()+f.company() print(name) yield Company( user_id=user.id, name=name, #name=Unicode()+f.company(), address=f.address(), url='https://www.baidu.com', phone=f.phone_number(), summary=f.sentence(), field=f.random_element(elements=('医药', '互联网', '金融')), financing=f.random_element(elements=('A轮','B轮','C轮','天使轮')), )
def updated_profile(self, company: Company): company.name = self.name.data company.email = self.email.data company.phone = self.phone.data if self.password.data: company.password = self.password.data if company.detail: detail = company.detail else: detail = CompanyDetail() detail.user_id = company.id self.populate_obj(detail) db.session.add(company) db.session.add(detail) db.session.commit()
def insert_company(company): logo_base_url = 'https://www.lgstatic.com/' # 获取到企业的logo地址,下载后放到项目文件中 logo_url = logo_base_url + company['companyLogo'] file_name = download_img(logo_url) with app.app_context(): company_user = User() company_user.name = company['companyFullName'] company_user.email = random_email() company_user.password = '******' company_user.role = User.ROLE_COMPANY db.session.add(company_user) db.session.commit() print(company_user.id) new_company = Company(lagou_company_id=company['companyId'], name=company['companyFullName'], logo=file_name if file_name else 'avatar.png', short_description=company['companyFeatures'], short_name=company['companyShortName'], welfare=company['otherLabel'], trade=company['industryField'], funding=company['financeStage'], size=company['companySize'], city=company['city'], user_id=company_user.id) db.session.add(new_company) db.session.commit()
def complete(self, id): company = Company() self.populate_obj(company) user = User.query.filter_by(id=id).first() user.company = company db.session.add(company) db.session.add(user) db.session.commit()
def update(self, company): company.name = self.name.data company.email = self.email.data company.phone = self.phone.data if self.password.data: company.password = self.password.data if company.company: companydetail = company.company else: companydetail = Company() companydetail.user_id = company.id companydetail.website = self.website.data companydetail.description = self.description.data self.populate_obj(companydetail) db.session.add(company) db.session.add(companydetail) db.session.commit()
def updated_profile(self, user): """ 更新 """ user.username = self.name.data user.email = self.email.data if self.password.data: user.password = self.password.data if user.company: company = user.company else: company = Company() company.user_id = user.id self.populate_obj(company) db.session.add(user) db.session.add(company) db.session.commit()
def update(self, user): user.name = self.name.data user.email = self.email.data if self.password.data: user.password = self.password.data if user.company_info: company_info = user.company_info else: company_info = Company() company_info.user_id = user.id company_info.website = self.site.data company_info.short_description = self.description.data db.session.add(user) db.session.add(company_info) db.session.commit()
def update_profile(self, user): user.name = self.name.data user.email = self.email.data #如果密码填写了就要改变密码 if self.password.data: user.password = self.password.data #先判断公司数据是否是第一次建立 if user.company: company = user.company else: company = Company() company.user_id = user.id self.populate_obj(obj=company) db.session.add(user) db.session.add(company) db.session.commit()
def register(self): user = User(email=self.email.data, password=self.password.data, role=User.ROLE_COMPANY) company = Company(user=user, name=self.name.data) db.session.add(user) db.session.add(company) db.session.commit()