izaac/jobposting/models.py
Jakub K b6becfdfb8
All checks were successful
continuous-integration/drone Build is passing
media
2023-12-22 21:42:02 +01:00

71 lines
2.6 KiB
Python

from django.db import models
from core.models import MyUser
from django.utils import timezone
from datetime import timedelta
class JobListing(models.Model):
posting_options = [
('M', 'Minimal'),
('S', 'Standard'),
('P', 'Premium'),
]
status_choices = [
('A', 'Aktywna'),
('C', 'Zakończona'),
('W', 'Oczekująca na sprawdzenie'),
('R', 'Zarchiwizowana'),
]
paid_status = [
('P', 'Oplacona'),
('N', 'Nieoplacona'),
('D', 'Inny status')
]
posting_option = models.CharField(max_length=1, choices=posting_options)
company_name = models.CharField(max_length=255)
name = models.CharField(max_length=255)
content = models.TextField()
minsalary = models.IntegerField()
maxsalary = models.IntegerField()
requiresalary = models.BooleanField()
webpage = models.CharField(max_length=255)
localization = models.CharField(max_length=255)
vat_number = models.CharField(max_length=10)
created_at = models.DateTimeField(default=timezone.now)
status = models.CharField(max_length=1, choices=status_choices, default='W')
status_paid = models.CharField(max_length=1, choices=paid_status, default='N')
# category = models.CharField(max_length=255, null=True, blank=True)
expiration_date = models.DateField(null=True, blank=True)
company_logo = models.ImageField(upload_to='company_logos/')
experience_level = models.CharField(max_length=255, null=True, blank=True)
employmentType = models.CharField(max_length=255, null=True, blank=True)
workFromHome = models.CharField(max_length=255)
updated_at = models.DateTimeField(auto_now=True)
job_skills = models.ManyToManyField('SkillLevels', blank=True)
created_by = models.ForeignKey(MyUser, on_delete=models.CASCADE)
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
contact_email = models.EmailField(max_length=255, null=True, blank=True)
def save(self, *args, **kwargs):
if not self.id:
self.expiration_date = self.created_at + timedelta(days=45)
super().save(*args, **kwargs)
def __str__(self):
return f"{self.name} at {self.company_name}"
class SkillLevels(models.Model):
proficiency_choices = [
('N', 'Nice to have'),
('B', 'Podstawowy'),
('M', 'Średnio zaawansowany'),
('A', 'Zaawansowany'),
('E', 'Ekspert'),
]
skill_name =models.CharField(max_length=255)
skill_level = models.CharField(max_length=1, choices=proficiency_choices,)