izaac/jobposting/models.py
Jakub K 24aa7f6d18
All checks were successful
continuous-integration/drone Build is passing
new RESTful views
2024-03-08 21:46:56 +01:00

84 lines
3.0 KiB
Python

from django.db import models
from core.models import MyUser, AnonymousUserData
from django.utils import timezone
from datetime import timedelta
from .helpers import rename_file
class JobOffer(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()
min_salary = models.IntegerField()
max_salary = models.IntegerField()
require_salary = models.BooleanField(null=True, default=False)
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.DateTimeField(null=True, blank=True)
image = models.CharField(max_length=255, null=True, blank=True)
experience_level = models.CharField(max_length=255, null=True, blank=True)
employment_type = models.CharField(max_length=255, null=True, blank=True)
work_from_home = models.CharField(max_length=255)
updated_at = models.DateTimeField(auto_now=True)
skill_levels = models.JSONField(null=True, blank=True, default=list)
anonymous_user_data = models.ForeignKey(AnonymousUserData,
null=True,
blank=True,
on_delete=models.SET_NULL)
created_by = models.ForeignKey(MyUser,
null=True,
blank=True,
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 Skill(models.Model):
skill_name = models.CharField(max_length=255)
def __str__(self):
return f"{self.skill_name}"
class CompanyLogo(models.Model):
company_logo = models.ImageField(upload_to=rename_file)
company_name = models.CharField(max_length=255)
def __str__(self):
return f"{self.company_name}"