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 create_user(self): user = User() #这里是添加企业用户的普通信息 user.name = self.name.data user.email = self.email.data user.password = self.password.data user.logo_img = self.image.data user.role = 20 #企业用户的权限是20 db.session.add(user) new_user = User.query.filter_by(name=user.name).first() company = Company() #下面是添加企业用户的详细信息 company.user = new_user company.website = self.web.data company.oneword = self.oneword.data company.description = self.description.data db.session.commit() return user
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 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()