90 lines
3.1 KiB
Python
90 lines
3.1 KiB
Python
from django.db import models
|
|
from tenants.models import Tenant
|
|
from users.models import User
|
|
|
|
|
|
class JobCategory(models.Model):
|
|
"""
|
|
Job category for organizing job postings.
|
|
"""
|
|
name = models.CharField(max_length=100)
|
|
description = models.TextField(blank=True)
|
|
tenant = models.ForeignKey(Tenant, on_delete=models.CASCADE)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
|
|
class Job(models.Model):
|
|
"""
|
|
Job posting model for the recruiting platform.
|
|
"""
|
|
STATUS_CHOICES = [
|
|
('draft', 'Draft'),
|
|
('published', 'Published'),
|
|
('closed', 'Closed'),
|
|
('archived', 'Archived'),
|
|
]
|
|
|
|
title = models.CharField(max_length=200)
|
|
description = models.TextField()
|
|
requirements = models.TextField()
|
|
responsibilities = models.TextField()
|
|
tenant = models.ForeignKey(Tenant, on_delete=models.CASCADE)
|
|
posted_by = models.ForeignKey(User, on_delete=models.CASCADE, related_name='jobs_posted')
|
|
|
|
category = models.ForeignKey(JobCategory, on_delete=models.SET_NULL, null=True, blank=True)
|
|
location = models.CharField(max_length=200)
|
|
employment_type = models.CharField(max_length=50, choices=[
|
|
('full-time', 'Full-time'),
|
|
('part-time', 'Part-time'),
|
|
('contract', 'Contract'),
|
|
('temporary', 'Temporary'),
|
|
('internship', 'Internship'),
|
|
('remote', 'Remote'),
|
|
])
|
|
|
|
salary_min = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True)
|
|
salary_max = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True)
|
|
|
|
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='draft')
|
|
is_remote = models.BooleanField(default=False)
|
|
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
published_at = models.DateTimeField(null=True, blank=True)
|
|
expires_at = models.DateTimeField(null=True, blank=True)
|
|
|
|
def __str__(self):
|
|
return f"{self.title} - {self.tenant.name}"
|
|
|
|
@property
|
|
def is_active(self):
|
|
return self.status == 'published' and self.expires_at and self.expires_at > self.created_at
|
|
|
|
|
|
class Application(models.Model):
|
|
"""
|
|
Job application model to track candidate applications.
|
|
"""
|
|
STATUS_CHOICES = [
|
|
('submitted', 'Submitted'),
|
|
('reviewed', 'Reviewed'),
|
|
('shortlisted', 'Shortlisted'),
|
|
('interviewed', 'Interviewed'),
|
|
('offered', 'Offered'),
|
|
('rejected', 'Rejected'),
|
|
('withdrawn', 'Withdrawn'),
|
|
]
|
|
|
|
job = models.ForeignKey(Job, on_delete=models.CASCADE, related_name='applications')
|
|
applicant = models.ForeignKey(User, on_delete=models.CASCADE, related_name='applications')
|
|
cover_letter = models.TextField(blank=True)
|
|
status = models.CharField(max_length=20, choices=STATUS_CHOICES, default='submitted')
|
|
|
|
applied_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
def __str__(self):
|
|
return f"{self.applicant.username} - {self.job.title}" |