Пример #1
0
    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()
Пример #2
0
 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()
Пример #3
0
 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()
Пример #4
0
 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()
Пример #5
0
 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()
Пример #6
0
    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()
Пример #7
0
    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()
Пример #8
0
def iter_companydetail():
    for u, d in zip(l, data_company):
        yield CompanyDetail(user=u,
                            image_url=d['image_url'],
                            finance=d['finance'],
                            staff_num=d['staff_num'],
                            type=d['type'],
                            about=d['about'])
Пример #9
0
def iter_company():
    for user in User.query.filter_by(role=20):
        yield CompanyDetail(logo=fake.url(),
                            site=fake.url(),
                            location=fake.address(),
                            description=fake.word(),
                            about=fake.word(),
                            tags=fake.word(),
                            stack=fake.word(),
                            team_introduction=fake.word(),
                            welfares=fake.word(),
                            field=fake.word(),
                            finance_stage=fake.word(),
                            user_id=user.id)