diff --git a/jobposting/models.py b/jobposting/models.py index 6c79dbd..c7e238a 100644 --- a/jobposting/models.py +++ b/jobposting/models.py @@ -3,7 +3,14 @@ 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'), @@ -15,6 +22,7 @@ class JobListing(models.Model): ('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() @@ -40,6 +48,10 @@ class JobListing(models.Model): 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}" diff --git a/jobposting/serializers.py b/jobposting/serializers.py index eadd4bf..6924153 100644 --- a/jobposting/serializers.py +++ b/jobposting/serializers.py @@ -19,7 +19,8 @@ class JobListingSerializer(serializers.ModelSerializer): class Meta: model = JobListing 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', 'expiration_date', 'experience_level', 'employmentType', 'workFromHome', 'updated_at', 'job_skills', 'contact_email', 'first_name', 'last_name',