48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
import os
|
|
import random
|
|
from django.core.management.base import BaseCommand
|
|
from faker import Faker
|
|
from recruitment.models import Job, Candidate
|
|
|
|
fake = Faker()
|
|
|
|
class Command(BaseCommand):
|
|
help = 'Generate 20 fake jobs and 50 fake candidates'
|
|
|
|
def handle(self, *args, **kwargs):
|
|
# Clear existing fake data (optional)
|
|
Job.objects.filter(title__startswith='Fake Job').delete()
|
|
Candidate.objects.filter(name__startswith='Candidate ').delete()
|
|
|
|
self.stdout.write("Creating fake jobs...")
|
|
jobs = []
|
|
for i in range(20):
|
|
job = Job.objects.create(
|
|
title=f"Fake Job {i+1}",
|
|
description_en=fake.paragraph(nb_sentences=5),
|
|
description_ar=fake.text(max_nb_chars=200),
|
|
is_published=True,
|
|
posted_to_linkedin=random.choice([True, False])
|
|
)
|
|
jobs.append(job)
|
|
|
|
self.stdout.write("Creating fake candidates...")
|
|
for i in range(50):
|
|
job = random.choice(jobs)
|
|
resume_path = f"resumes/fake_resume_{i+1}.pdf"
|
|
parsed = {
|
|
'name': fake.name(),
|
|
'skills': [fake.job() for _ in range(5)],
|
|
'summary': fake.text(max_nb_chars=300)
|
|
}
|
|
|
|
Candidate.objects.create(
|
|
job=job,
|
|
name=f"Candidate {i+1}",
|
|
email=fake.email(),
|
|
resume=resume_path, # You can create dummy files if needed
|
|
parsed_summary=str(parsed),
|
|
applied=random.choice([True, False])
|
|
)
|
|
|
|
self.stdout.write(self.style.SUCCESS("✔️ Successfully generated 20 jobs and 50 candidates")) |