This commit is contained in:
parent
b6becfdfb8
commit
c94b92562e
7
jobposting/helpers.py
Normal file
7
jobposting/helpers.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import os
|
||||||
|
from uuid import uuid4
|
||||||
|
|
||||||
|
def rename_file(instance, filename):
|
||||||
|
ext = filename.split(".")[-1]
|
||||||
|
new_filename = f"{uuid4()}.{ext}"
|
||||||
|
return os.path.join('company_logos/', new_filename)
|
||||||
@ -4,7 +4,7 @@ from core.models import MyUser
|
|||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from helpers import rename_file
|
||||||
class JobListing(models.Model):
|
class JobListing(models.Model):
|
||||||
posting_options = [
|
posting_options = [
|
||||||
('M', 'Minimal'),
|
('M', 'Minimal'),
|
||||||
@ -37,7 +37,7 @@ class JobListing(models.Model):
|
|||||||
status_paid = models.CharField(max_length=1, choices=paid_status, default='N')
|
status_paid = models.CharField(max_length=1, choices=paid_status, default='N')
|
||||||
# category = models.CharField(max_length=255, null=True, blank=True)
|
# category = models.CharField(max_length=255, null=True, blank=True)
|
||||||
expiration_date = models.DateField(null=True, blank=True)
|
expiration_date = models.DateField(null=True, blank=True)
|
||||||
company_logo = models.ImageField(upload_to='company_logos/')
|
# company_logo = models.ImageField(upload_to='company_logos/')
|
||||||
experience_level = models.CharField(max_length=255, null=True, blank=True)
|
experience_level = models.CharField(max_length=255, null=True, blank=True)
|
||||||
employmentType = 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)
|
workFromHome = models.CharField(max_length=255)
|
||||||
@ -68,3 +68,7 @@ class SkillLevels(models.Model):
|
|||||||
|
|
||||||
skill_name =models.CharField(max_length=255)
|
skill_name =models.CharField(max_length=255)
|
||||||
skill_level = models.CharField(max_length=1, choices=proficiency_choices,)
|
skill_level = models.CharField(max_length=1, choices=proficiency_choices,)
|
||||||
|
|
||||||
|
class CompanyLogo(models.Model):
|
||||||
|
company_logo = models.ImageField(upload_to=rename_file)
|
||||||
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from jobposting.models import JobListing, SkillLevels
|
from jobposting.models import JobListing, SkillLevels, CompanyLogo
|
||||||
from core.models import MyUser
|
from core.models import MyUser
|
||||||
|
|
||||||
class MyUserSerializer(serializers.ModelSerializer):
|
class MyUserSerializer(serializers.ModelSerializer):
|
||||||
@ -25,3 +25,8 @@ class JobListingSerializer(serializers.ModelSerializer):
|
|||||||
'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',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
class CompanyLogoSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = CompanyLogo
|
||||||
|
fields = ['id', 'company_logo']
|
||||||
@ -1,10 +1,11 @@
|
|||||||
from rest_framework import viewsets, permissions
|
from rest_framework import viewsets, permissions
|
||||||
from jobposting.models import JobListing, SkillLevels
|
from jobposting.models import JobListing, SkillLevels, CompanyLogo
|
||||||
|
|
||||||
from jobposting.serializers import (
|
from jobposting.serializers import (
|
||||||
JobListingSerializer,
|
JobListingSerializer,
|
||||||
SkillLevelsSerializer,
|
SkillLevelsSerializer,
|
||||||
MyUserSerializer,
|
MyUserSerializer,
|
||||||
|
CompanyLogoSerializer
|
||||||
)
|
)
|
||||||
from core.models import MyUser
|
from core.models import MyUser
|
||||||
|
|
||||||
@ -38,3 +39,7 @@ class SkillLevelsViewSet(viewsets.ModelViewSet):
|
|||||||
# permission_classes = [permissions.IsAuthenticatedOrReadOnly]
|
# permission_classes = [permissions.IsAuthenticatedOrReadOnly]
|
||||||
|
|
||||||
# Możesz także chcieć dodać widoki szczegółowe lub niestandardowe akcje.
|
# Możesz także chcieć dodać widoki szczegółowe lub niestandardowe akcje.
|
||||||
|
class CompanyLogoViewSet(viewsets.ModelViewSet):
|
||||||
|
permission_classes = [permissions.AllowAny]
|
||||||
|
queryset = CompanyLogo.objects.all()
|
||||||
|
serializer_class = CompanyLogoSerializer
|
||||||
@ -4,4 +4,5 @@ djangorestframework
|
|||||||
psycopg2-binary
|
psycopg2-binary
|
||||||
django-allauth
|
django-allauth
|
||||||
dj-rest-auth
|
dj-rest-auth
|
||||||
django-cors-headers
|
django-cors-headers
|
||||||
|
Pillow
|
||||||
Loading…
x
Reference in New Issue
Block a user