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 = CompanyDetail( 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 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.company_detail: company_detail = user.company_detail else: company_detail = CompanyDetail() company_detail.user_id = user.id self.populate_obj(company_detail) db.session.add(user) db.session.add(company_detail) db.session.commit()
def create_company(self): user = User(name=self.name.data, email=self.email.data, password=self.password.data, role=User.ROLE_COMPANY) db.session.add(user) db.session.commit() company = CompanyDetail(site=self.site.data, logo=self.logo.data, location=self.location.data, description=self.description.data) company.user_id = user.id db.session.add(company) db.session.commit()
def update(self, company): company.name = self.name.data company.email = self.email.data if self.password.data: company.password = self.password.data if company.detail: detail = company.detail else: detail = CompanyDetail() detail.user_id = company.id detail.site = self.site.data detail.description = self.description.data db.session.add(company) db.session.add(detail) 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 = CompanyDetail() detail.user_id = user.id self.populate_obj(detail) db.session.add(user) db.session.add(detail) db.session.commit()
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()