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 add_company_profile(self, user_id, username): """添加企业用户信息到 Company 数据库表 Args: user_id (int) : 注册用户ID """ company = Company() logo = self.logo.data manager_img = self.manager_img.data logo_filename = self.change_img(logo, user_id) manager_img_filename = self.change_img(manager_img, user_id) company.user_id = user_id company.name = username company.logo = logo_filename company.web_url = self.web_url.data company.found_date = self.found_date.data company.city = self.city.data company.address = self.address.data company.scale = self.scale.data company.industry = self.industry.data company.email = self.email.data company.phone = self.phone.data company.fax = self.fax.data company.manager_name = self.manager_name.data company.manager_job = self.manager_job.data company.manager_photo = manager_img_filename company.slogan = self.slogan.data company.products_display = self.products_display.data company.description = self.description.data db.session.add(company) db.session.commit()
def create_company(self): company = Company() company.user_id = current_user.id company.company_name = self.company_name.data company.offical_websit = self.offical_websit.data company.address = self.offical_websit.data company.company_TEL = self.company_TEL.data company.description = self.description.data db.session.add(company) db.session.commit() return company
def update_user_info(self): """ 更新企业用户信息 :return: User 模型实例 """ user = self.user user.email = self.email.data user.role = User.ROLE_COMPANY if self.is_new_user: user.password = self.password.data user.username = self.username.data else: if self.password.data: user.password = self.password.data db.session.add(user) db.session.commit() if self.is_new_user: company = Company(user=user) else: company = user.company_info # logo = self.logo.data # manager_img = self.manager_img.data # if logo: # company.logo = self.change_img(logo, user.id) # if manager_img: # company.manager_photo = self.change_img(manager_img, user.id) company.name = self.name.data company.web_url = self.web_url.data company.found_date = self.found_date.data company.city = self.city.data company.address = self.address.data company.scale = self.scale.data company.industry = self.industry.data company.email = self.resume_email.data company.phone = self.phone.data company.fax = self.fax.data company.manager_name = self.manager_name.data company.manager_job = self.manager_job.data company.slogan = self.slogan.data company.products_display = self.products_display.data company.description = self.description.data db.session.add(company) db.session.commit() 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 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, company): company.name = self.name.data company.email = self.email.data company.mobile = self.mobile.data if self.password.data: company.password = self.password.data if company.company_detail: company_detail = company.company_detail else: company_detail = Company() company_detail.user_id = company.id company_detail.site = self.site.data company_detail.description = self.description.data db.session.add(company) db.session.add(company_detail) db.session.commit()