Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
    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