modyfikacja logiki zapisu - dodanie do zapisu expiration_date = 45 dni od created_at
All checks were successful
continuous-integration/drone Build is passing
All checks were successful
continuous-integration/drone Build is passing
This commit is contained in:
parent
d6bd3adf5c
commit
a12a9b8200
@ -3,7 +3,14 @@ from django.db import models
|
|||||||
from core.models import MyUser
|
from core.models import MyUser
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
class JobListing(models.Model):
|
class JobListing(models.Model):
|
||||||
|
posting_options = [
|
||||||
|
('M', 'Minimal'),
|
||||||
|
('S', 'Standard'),
|
||||||
|
('P', 'Premium'),
|
||||||
|
]
|
||||||
status_choices = [
|
status_choices = [
|
||||||
('A', 'Aktywna'),
|
('A', 'Aktywna'),
|
||||||
('C', 'Zakończona'),
|
('C', 'Zakończona'),
|
||||||
@ -15,6 +22,7 @@ class JobListing(models.Model):
|
|||||||
('N', 'Nieoplacona'),
|
('N', 'Nieoplacona'),
|
||||||
('D', 'Inny status')
|
('D', 'Inny status')
|
||||||
]
|
]
|
||||||
|
posting_option = models.CharField(max_length=1, choices=posting_options)
|
||||||
company_name = models.CharField(max_length=255)
|
company_name = models.CharField(max_length=255)
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
content = models.TextField()
|
content = models.TextField()
|
||||||
@ -40,6 +48,10 @@ class JobListing(models.Model):
|
|||||||
last_name = models.CharField(max_length=255)
|
last_name = models.CharField(max_length=255)
|
||||||
contact_email = models.EmailField(max_length=255, null=True, blank=True)
|
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):
|
def __str__(self):
|
||||||
return f"{self.name} at {self.company_name}"
|
return f"{self.name} at {self.company_name}"
|
||||||
|
|||||||
@ -19,7 +19,8 @@ class JobListingSerializer(serializers.ModelSerializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = JobListing
|
model = JobListing
|
||||||
fields = [
|
fields = [
|
||||||
'id', 'company_name', 'name', 'content', 'minsalary', 'maxsalary',
|
'id', 'posting_option',
|
||||||
|
'company_name', 'name', 'content', 'minsalary', 'maxsalary',
|
||||||
'localization', 'created_by', 'created_at', 'status', 'status_paid',
|
'localization', 'created_by', 'created_at', 'status', 'status_paid',
|
||||||
'expiration_date', 'experience_level', 'employmentType', 'workFromHome',
|
'expiration_date', 'experience_level', 'employmentType', 'workFromHome',
|
||||||
'updated_at', 'job_skills', 'contact_email', 'first_name', 'last_name',
|
'updated_at', 'job_skills', 'contact_email', 'first_name', 'last_name',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user