roo roo roo down the river we go...
This commit is contained in:
40
jobs/serializers.py
Normal file
40
jobs/serializers.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from rest_framework import serializers
|
||||
from .models import Job, Application, JobCategory
|
||||
from users.serializers import UserSerializer
|
||||
from tenants.serializers import TenantSerializer
|
||||
|
||||
|
||||
class JobCategorySerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
Serializer for the JobCategory model.
|
||||
"""
|
||||
class Meta:
|
||||
model = JobCategory
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class JobSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
Serializer for the Job model.
|
||||
"""
|
||||
posted_by = UserSerializer(read_only=True)
|
||||
tenant = TenantSerializer(read_only=True)
|
||||
category = JobCategorySerializer(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = Job
|
||||
fields = '__all__'
|
||||
read_only_fields = ('posted_by', 'tenant', 'created_at', 'updated_at', 'published_at')
|
||||
|
||||
|
||||
class ApplicationSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
Serializer for the Application model.
|
||||
"""
|
||||
job = JobSerializer(read_only=True)
|
||||
applicant = UserSerializer(read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = Application
|
||||
fields = '__all__'
|
||||
read_only_fields = ('job', 'applicant', 'applied_at', 'updated_at')
|
||||
Reference in New Issue
Block a user