示例#1
0
    def handle(self, *args, **options):
        start_time = time.time()
        r = 0
        for i in range(options['count']):
            name = fake.company()
            c = Company(name=name,
                        location=f'{fake.city()}, {fake.state_abbr()}',
                        url=name.lower().replace(' ', '-') + '.com',
                        logo=Company.objects.get(pk=1).logo)
            c.save()
            r += 1

            j = Job(
                title=fake.job() + ' Intern',
                company=c,
                hours_per_week=fake.pyint(min_value=10, max_value=40, step=5),
                application_link='scoretwo.com',
                category=random.choice(Category.objects.all()),
                description=fake.text(max_nb_chars=1500, ext_word_list=None),
                qualifications=fake.text(max_nb_chars=1500,
                                         ext_word_list=None),
            )
            j.save()
            r += 1

            sys.stdout.write(
                f"\rCreating Company/Job {i} of {options['count']}")
            sys.stdout.flush()

        end_time = time.time()
        print(
            f'\rDone. Created {r} records in {round(end_time-start_time, 2)} seconds.'
        )
示例#2
0
    def test_auto_assignment_of_name_slug_on_save(self):
        data = {
            'name': 'Test Company',
            'industry': 'Services',
            'vacancies_url': 'http://test-company.com/jobs',
            'last_updated': '2020-08-16',
        }
        company = Company(**data)
        self.assertIsNone(company.id)
        self.assertIn(company.name_slug, ('', None))

        company.save()
        self.assertTrue(company.id != 0)
        self.assertNotIn(company.name_slug, ('', None))
示例#3
0
 def save_user_profile(self, user):
     company_name = self.cleaned_data['company_name']
     user_profile = UserProfile(user=user,
                                is_review=True,
                                ip=self.request.environ['REMOTE_ADDR'],
                                user_email=self.cleaned_data['user_email'],
                                phone=self.cleaned_data['phone'],
                                company_name=company_name,
                                name=self.cleaned_data['name'])
     company = Company(
         company_name=company_name,
         user=user,
     )
     company.save()
     return user_profile
示例#4
0
 def save_user_profile(self, user):
     company_name = self.cleaned_data['company_name']
     user_profile = UserProfile(
         user=user,
         is_review=True,
         ip=self.request.environ['REMOTE_ADDR'],
         user_email=self.cleaned_data['user_email'],
         phone=self.cleaned_data['phone'],
         company_name=company_name,
         name=self.cleaned_data['name']
     )
     company = Company(
         company_name=company_name,
         user=user,
     )
     company.save()
     return user_profile
示例#5
0
 def save_user_profile(self, user):
     company_name = self.cleaned_data['company_name']
     phone = self.cleaned_data['phone']
     user_profile = UserProfile(
         user=user,
         is_review=True,
         ip=self.request.environ['REMOTE_ADDR'],
         user_email=self.cleaned_data['user_email'],
         name=self.cleaned_data['name'],
         phone=phone,
         qq=self.cleaned_data['qq'],
         company_name=company_name,
     )
     company = Company(
         company_name=company_name,
         user=user,
     )
     company.save()
     company.category.add(*self.cleaned_data['select_fields'])
     company.save()
     SmsCode.delete_cache_code(phone, 'AccountReg')
     return user_profile
示例#6
0
    def handle(self, *args, **options):
        if not User.objects.first():
            User.objects.create_user('user', '*****@*****.**', 'userpass')
            user=User.objects.first()
            for specialty in specialties:
                picture_name = '/specty_' + specialty['code'] + '.png'
                picture_path = MEDIA_SPECIALITY_IMAGE_DIR + picture_name
                Specialty(code=specialty['code'], title=specialty['title'], picture=picture_path).save()

            for company in companies:
                logo_name = company['title'] + '.png'
                logo_path = MEDIA_COMPANY_IMAGE_DIR + '/' + logo_name
                Company(name=company['title'], user_id=user.id, employee_count=random.randint(10, 50), logo=logo_path).save()

            for job in jobs:
                specialty = Specialty.objects.filter(code=job['cat'])[0]
                company = Company.objects.filter(name=job['company'])[0]
                Vacancy(title=job['title'], specialty=specialty, company=company,
                        description=job['desc'], published_at=timezone.now(),
                        salary_min=int(job['salary_from']), salary_max=int(job['salary_to'])).save()
示例#7
0
 def save_user_profile(self, user):
     company_name = self.cleaned_data['company_name']
     phone = self.cleaned_data['phone']
     user_profile = UserProfile(
         user=user,
         is_review=True,
         ip=self.request.environ['REMOTE_ADDR'],
         user_email=self.cleaned_data['user_email'],
         name=self.cleaned_data['name'],
         phone=phone,
         qq=self.cleaned_data['qq'],
         company_name=company_name,
     )
     company = Company(
         company_name=company_name,
         user=user,
     )
     company.save()
     company.category.add(*self.cleaned_data['select_fields'])
     company.save()
     SmsCode.delete_cache_code(phone, 'AccountReg')
     return user_profile
示例#8
0
    {"code": "backend", "title": "Бэкенд"},
    {"code": "gamedev", "title": "Геймдев"},
    {"code": "devops", "title": "Девопс"},
    {"code": "design", "title": "Дизайн"},
    {"code": "products", "title": "Продукты"},
    {"code": "management", "title": "Менеджмент"},
    {"code": "testing", "title": "Тестирование"}

]


if __name__ == '__main__':
    Company.objects.bulk_create(
        [
            Company(
                name=company['title'],
                # logo="https://place-hold.it/100x60",
            )
            for company in companies
        ]
    )

    Specialty.objects.bulk_create(
        [
            Specialty(
                code=spec['code'],
                title=spec['title'],
                # picture="https://place-hold.it/100x60"
            )
            for spec in specialties
        ]
    )