Fakultas Ilmu Komputer UI

Commit b047f62e authored by Muh Riansyah Tohamba's avatar Muh Riansyah Tohamba 💬
Browse files

Replace Magic Number with Symbolic Constant on Model Class Application

parent 45164e21
......@@ -30,13 +30,13 @@ class StudentSerializer(serializers.ModelSerializer):
@staticmethod
def get_accepted_no(obj):
apps = Application.objects.filter(student=obj, status=4)
apps = Application.objects.filter(student=obj, status=Application.ACCEPTED)
companies = apps.values('vacancy__company').distinct()
return companies.count()
@staticmethod
def get_read_no(obj):
apps = Application.objects.filter(student=obj, status=1)
apps = Application.objects.filter(student=obj, status=Application.READ)
companies = apps.values('vacancy__company').distinct()
return companies.count()
......
......@@ -12,7 +12,7 @@ class VacancySerializer(serializers.ModelSerializer):
total_accepted_applicants = serializers.SerializerMethodField('_get_total_accepted_applicants')
def _get_total_accepted_applicants(self, instance):
return len(Application.objects.filter(vacancy=instance, status=4))
return len(Application.objects.filter(vacancy=instance, status=Application.ACCEPTED))
def _get_app_status(self, instance):
try:
......
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