예제 #1
0
 def create_table_company(self, user):
     print(user)
     company = Company()
     company.user_id = user.id
     company.name = user.username
     db.session.add(company)
     db.session.commit()
예제 #2
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 = Company(
                 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()
예제 #3
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 = Company(
                name=company['companyShortName'],
                logo_uri='https://static.lagou.com/thumbnail_160x160/' + company['companyLogo'],
                website='https://shiyanlou.com',
                introduction=['companyFeatures'],
                city=company['city'],
                domain=company['industryField'],
                finance=company['financeStage']
            )
            d.user_id = c.id
            db.session.add(d)
            db.session.commit()
예제 #4
0
    def create_company(self):
        company = Company()
        company.name = self.company.data
        db.session.add(company)
        db.session.commit()
        self.create_user(company.id)

        return company
예제 #5
0
 def update_profile(self, user):
     if user.company:
         company = user.company
     else:
         company = Company()
         company.user_id = user.id
     self.populate_obj(company)
     db.session.add(user)
     db.session.add(company)
     db.session.commit()
예제 #6
0
파일: forms.py 프로젝트: xxqhh/jobplus7-12
    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()
예제 #7
0
 def update(self, company):
     if self.password.data:
         company.password = self.password.data
     if company.company_msg:
         company_msg = company.company_msg
     else:
         company_msg = Company()
         company_msg.user_id = company.id
     self.populate_obj(company)
     self.populate_obj(company_msg)
     db.session.add(company_msg)
     db.session.add(company)
     db.session.commit()
예제 #8
0
    def fake_data(self):

        for company in self.companies[:]:
            print(company["name"])
            # 创建企业用户
            c = User(
                username=company["name"],
                email=fake.email(),
                role=User.ROLE_COMPANY
            )
            c.password = "******"
            db.session.add(c)
            try:
                db.session.commit()
            except:
                db.session.rollback()
                continue

            # 创建企业信息
            d = Company(
                name=company["name"],
                email=c.email,
                logo=company["logo"],
                site=company["site"],
                location=company["localtion"],
                description = company["description"],
                about = company["about"].strip("0/1000取消保存").strip("关于我们"),
                tags=company["tags"]
            )
            d.user_id = c.id
            db.session.add(d)
            db.session.commit()

            # 发布企业职位
            job_list = self.get_job(company["id"])
            for item in job_list:
                job = Job(
                    name=item["name"],
                    salary_low=int(item["salary_low"].strip("k")) * 1000,
                    salary_high=int(item["salary_high"].strip("k")) * 1000,
                    location=item["location"],
                    tags=item["tags"],
                    experience_requirement=item["experience_requirement"],
                    degree_requirement=item["degree_requirement"],
                    description =item["raw_description"]
                )

                job.company_id = d.id

                db.session.add(job)
                db.session.commit()
예제 #9
0
    def update_profile(self, user):
        user.username = self.username.data
        user.email = self.email.data

        if user.detail:
            detail = user.detail
        else:
            detail = Company()
            detail.user_id = user.id
            detail.contact = 'x'
        self.populate_obj(detail)
        db.session.add(user)
        db.session.add(detail)
        db.session.commit()
예제 #10
0
 def updated_profile(self, company):
     company.name = self.name.data
     company.email = self.email.data
     if self.password.data:
         company.password = self.password.data
     if company.company_msg:
         company_msg = company.company_msg
     else:
         company_msg = Company()
         company_msg.user_id = company.id
     self.populate_obj(company_msg)
     db.session.add(company_msg)
     db.session.add(company)
     db.session.commit()
예제 #11
0
    def update_company(self, user=None):

        company = Company(name=self.name.data,
                          address=self.address.data,
                          website=self.website.data,
                          url=self.logo.data,
                          description=self.description.data)

        if user:
            company.user = user

        db.session.add(company)
        db.session.commit()
        return company
예제 #12
0
 def update_company(self,user):
     user.username = self.name.data
     user.email = self.email.data
     if self.password.data:
         user.password = self.password.data
     if user.companies:
         companies = user.companies
     else:
         companies = Company()
         companies.users_id = user.id
     self.populate_obj(companies)
     db.session.add(user)
     db.session.add(companies)
     db.session.commit()
예제 #13
0
 def ComupForm(self, user):
     user.username = self.name.data
     user.email = self.email.data
     user.role = 20
     if self.password.data:
         user.password = self.password.data
     if user.company:
         company = user.company
     else:
         company = Company()
         company.user_id = user.id
     self.populate_obj(company)
     db.session.add(user)
     db.session.add(company)
     db.session.commit()
예제 #14
0
파일: forms.py 프로젝트: nttzl/jobplus8-10
    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 = Company()
            detail.user_id = user.id
        self.populate_obj(detail)
        db.session.add(user)
        db.session.add(detail)
        db.session.commit()
예제 #15
0
def iter_companys():
    photo = get_photo()

    for company in company_detail:
        name = company['name']
        user = User.query.filter_by(username=name).first()
        phone = fake.phone_number()
        yield Company(user_id=user.id,
                      name=user.username,
                      logo=company['image_urls'],
                      web_url=company['web_url'],
                      found_date=fake.date(),
                      city=company['city'],
                      address=fake.address(),
                      scale=randint(0, 4),
                      industry=company['industry'],
                      email=fake.email(),
                      phone=phone,
                      fax=phone,
                      manager_name=fake.name(),
                      manager_job=fake.job(),
                      manager_photo=next(photo),
                      slogan=company['slogan'],
                      products_display=fake.sentence(),
                      description=company['description'])
예제 #16
0
    def test_com(self,db):
        assert Company.query.count() == 0
        com = Company(name='测试公司',website='测试阿里爷爷网站',description='testing...')
        db.session.add(com)
        db.session.commit()

        assert Company.query.count() == 0
예제 #17
0
 def add_company(self):
     company = Company()
     self.populate_obj(company)
     db.session.add(company)
     db.session.commit()
     flash("添加成功", 'success')
     return user
예제 #18
0
 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()
예제 #19
0
def item_jobs():
    with open("jobs.json", 'r', encoding="utf8") as f:
        jobs = json.load(f)
        print(jobs)
        job_list = []
        company_list = []
        for job in jobs:
            company = Company(name=job["company"],
                              address=job["address"],
                              net_site=job["net_site"],
                              logo=job["logo"],
                              introduce=faker.sentence(),
                              detail=job["desc"],
                              city=job["city"],
                              financing=job["financing"],
                              company_field=job["company_field"],
                              company_scale=job['company_scale'])
            jobdata = Job(job_title=job['job_title'],
                          work_experience=job['work_experience'],
                          study_experience=job['study_experience'],
                          salary_range=job['xinshui'],
                          work_tags=job['work_tags'],
                          company_msg=company)
            job_list.append(jobdata)
            company_list.append(company)

        return job_list, company_list
예제 #20
0
def iter_personal():
    for user in User.query:
        print('user.role',user.role)
        if user.role == 10:
            yield Personal(
                    user_id=user.id,
                    name=f.name(),
                    phone=f.phone_number(),
                    jobyear=f.random_int(0,100),
                    )
        elif user.role == 20:

            with open(os.path.join(os.path.dirname(__file__), '..', 'datas', 'datas.json')) as e:
                companys = json.load(e)
                for company in companys:
                    yield Company(
                        user_id=user.id,
                        name=company['company_name'],
                        #name=Unicode()+f.company(),
                        address=company['city'],
                        url='https://www.baidu.com',
                        phone=f.phone_number(),
                        summary=f.sentence(),
                        field=company['field'],
                        financing=company['financing'],
                        logo=company['company_image_url'],
                    )
예제 #21
0
def create_user_and_company():
    with open('scripts/data_company.json') as f1, \
            open('scripts/data_job.json') as f2:
        job_name_list = [i['name'] for i in json.load(f2)]
        experience_list = ['不限', '1-3年', '3-5年', '5-10年']
        degree_list = ['不限', '本科', '博士后']
        for i in json.load(f1):
            user = User(username=fake.name(), email=fake.email())
            user.password = '******'
            yield user
            company = Company(
                    name = i['name'],
                    logo = i['logo'],
                    location = i['location'],
                    description = i['description'],
                    about = i['about'] if len(i['about']) > 9 else \
                            fake.sentence(nb_words=11),
                    tags = i['tags'],
                    user = user,
            )
            yield company
            for i in range(randint(1, 5)):
                job = Job(
                    name = job_name_list[randint(1, len(job_name_list))-1],
                    salary_low = randint(3, 8) * 1000,
                    salary_high = randint(9, 15) * 1000,
                    location = fake.address(),
                    is_fulltime = 1,
                    experience_requirement = experience_list[
                            randint(1, len(experience_list)) - 1],
                    degree_requirement = degree_list[
                            randint(1, len(degree_list)) - 1],
                    company = company
                )
                yield job
예제 #22
0
def iter_personal():
    for user in User.query:
        print('user.role',user.role)
        if user.role == 10:
            yield Personal(
                    user_id=user.id,
                    name=f.name(),
                    phone=f.phone_number(),
                    jobyear=f.random_int(0,100),
                    )
        elif user.role == 20:

            name = Unicode()+f.company()
            print(name)
            yield Company(
                    user_id=user.id,
                    name=name,
                    #name=Unicode()+f.company(),
                    address=f.address(),
                    url='https://www.baidu.com',
                    phone=f.phone_number(),
                    summary=f.sentence(),
                    field=f.random_element(elements=('医药', '互联网', '金融')),
                    financing=f.random_element(elements=('A轮','B轮','C轮','天使轮')),
                    )
예제 #23
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()
예제 #24
0
def insert_company(company):
    logo_base_url = 'https://www.lgstatic.com/'
    # 获取到企业的logo地址,下载后放到项目文件中
    logo_url = logo_base_url + company['companyLogo']
    file_name = download_img(logo_url)
    with app.app_context():
        company_user = User()
        company_user.name = company['companyFullName']
        company_user.email = random_email()
        company_user.password = '******'
        company_user.role = User.ROLE_COMPANY
        db.session.add(company_user)
        db.session.commit()
        print(company_user.id)

        new_company = Company(lagou_company_id=company['companyId'],
                              name=company['companyFullName'],
                              logo=file_name if file_name else 'avatar.png',
                              short_description=company['companyFeatures'],
                              short_name=company['companyShortName'],
                              welfare=company['otherLabel'],
                              trade=company['industryField'],
                              funding=company['financeStage'],
                              size=company['companySize'],
                              city=company['city'],
                              user_id=company_user.id)
        db.session.add(new_company)
        db.session.commit()
예제 #25
0
 def complete(self, id):
     company = Company()
     self.populate_obj(company)
     user = User.query.filter_by(id=id).first()
     user.company = company
     db.session.add(company)
     db.session.add(user)
     db.session.commit()
예제 #26
0
 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()
예제 #27
0
 def updated_profile(self, user):
     """
     更新
     """
     user.username = self.name.data
     user.email = self.email.data
     if self.password.data:
         user.password = self.password.data
     if user.company:
         company = user.company
     else:
         company = Company()
         company.user_id = user.id
     self.populate_obj(company)
     db.session.add(user)
     db.session.add(company)
     db.session.commit()
예제 #28
0
    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()
예제 #29
0
    def update_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:
            company = user.company
        else:
            company = Company()
            company.user_id = user.id
        self.populate_obj(obj=company)
        db.session.add(user)
        db.session.add(company)
        db.session.commit()
예제 #30
0
    def register(self):
        user = User(email=self.email.data,
                    password=self.password.data,
                    role=User.ROLE_COMPANY)

        company = Company(user=user, name=self.name.data)
        db.session.add(user)
        db.session.add(company)
        db.session.commit()