Fakultas Ilmu Komputer UI

Commit 5fe653a4 authored by Joshua Casey's avatar Joshua Casey
Browse files

[REFACTOR] changed student's applied-vacancies list to also return the application

parent ca128936
......@@ -29,3 +29,11 @@ class ApplicationStatusSerializer(serializers.ModelSerializer):
class Meta:
model = Application
fields = ['status']
class VacancyApplicationSerializer(serializers.ModelSerializer):
vacancy = VacancySerializer()
class Meta:
model = Application
fields = ['cover_letter', 'vacancy', 'status']
......@@ -8,7 +8,8 @@ from rest_framework.decorators import detail_route
from core.lib.permissions import IsAdminOrStudent, IsAdminOrCompany, IsAdminOrVacancyOwner
from core.models import Student, Company
from core.models.vacancies import Vacancy, Application
from core.serializers.vacancies import VacancySerializer, ApplicationSerializer, ApplicationStatusSerializer
from core.serializers.vacancies import VacancySerializer, ApplicationSerializer, ApplicationStatusSerializer, \
VacancyApplicationSerializer
class VacancyViewSet(viewsets.ModelViewSet):
......@@ -43,12 +44,12 @@ class ApplicationViewSet(viewsets.GenericViewSet):
def list(self, request, student_id):
"""
Get list of a student {student_id}'s application
Get list of a student {student_id}'s applications
---
"""
student = get_object_or_404(Student.objects.all(), pk=student_id)
vacancies = student.applied_vacancies
return Response(VacancySerializer(vacancies, many=True, context={'request': request}).data)
applications = Application.objects.filter(student=student)
return Response(VacancyApplicationSerializer(applications, many=True, context={'request': request}).data)
def create(self, request, student_id):
"""
......
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