Fakultas Ilmu Komputer UI

Commit 3e29b5dd authored by Zamil Majdy's avatar Zamil Majdy
Browse files

[#140652771] [#21] [Green] Implement vacancy list

parent a453f6fd
from rest_framework import serializers
from core.serializers.accounts import CompanySerializer, StudentSerializer
from core.models import Company
from core.models.vacancies import Vacancy, Application
from core.serializers.accounts import StudentSerializer
class VacancySerializer(serializers.ModelSerializer):
company = CompanySerializer()
company = serializers.PrimaryKeyRelatedField(
class Meta:
model = Vacancy
......@@ -11,7 +11,7 @@ from core.serializers.vacancies import VacancySerializer, ApplicationSerializer
class VacancyViewSet(viewsets.ModelViewSet):
queryset = Vacancy.objects.all().filter(verified=True)
queryset = Vacancy.objects.all()
serializer_class = VacancySerializer
permission_classes = [IsAdminOrCompany]
......@@ -20,6 +20,12 @@ class VacancyViewSet(viewsets.ModelViewSet):
return [IsAuthenticated()]
return super(VacancyViewSet, self).get_permissions()
def list(self, request, *args, **kwargs):
vacancies = Vacancy.objects.all()
if not ('verified' in request.query_params) or request.query_params['verified']:
vacancies = vacancies.filter(verified=True)
return Response(VacancySerializer(vacancies, many=True, context={'request': request}).data)
class ApplicationViewSet(viewsets.GenericViewSet):
serializer_class = ApplicationSerializer
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment