Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Class Project
Kape
Commits
b047f62e
Commit
b047f62e
authored
Dec 08, 2019
by
Muh Riansyah Tohamba
💬
Browse files
Replace Magic Number with Symbolic Constant on Model Class Application
parent
45164e21
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/serializers/accounts.py
View file @
b047f62e
...
...
@@ -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
()
...
...
core/serializers/vacancies.py
View file @
b047f62e
...
...
@@ -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
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment