Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Class Project
Kape
Commits
79ae3176
Commit
79ae3176
authored
Oct 06, 2019
by
root
Browse files
implementasi fitur and testing
parent
e68e63c4
Changes
7
Hide whitespace changes
Inline
Side-by-side
assets/js/__test__/components/Vacancy-test.jsx
View file @
79ae3176
...
...
@@ -8,6 +8,7 @@ describe('Vacancy', () => {
const
fetchMock
=
require
(
'
fetch-mock
'
);
const
response
=
{
close_time
:
'
2019-03-28T05:55:42Z
'
,
apply_before
:
'
28 March 2019
'
company
:
{
address
:
'
kebayoran baru
'
,
id
:
1
,
...
...
@@ -17,7 +18,7 @@ describe('Vacancy', () => {
created
:
'
2017-03-28T07:05:47.128672Z
'
,
description
:
'
Lorem ipsum dolbh.
'
,
id
:
3
,
name
:
'
Software Engineer
'
,
name
:
'
Software Engineer
'
,
open_time
:
'
2017-03-28T05:55:38Z
'
,
updated
:
'
2017-03-28T07:34:13.122093Z
'
,
verified
:
true
,
...
...
@@ -25,6 +26,7 @@ describe('Vacancy', () => {
const
response2
=
{
close_time
:
'
2019-03-28T05:55:42Z
'
,
apply_before
:
'
28 March 2019
'
company
:
{
address
:
'
kebayoran baru
'
,
id
:
1
,
...
...
@@ -44,6 +46,7 @@ describe('Vacancy', () => {
role
:
'
company
'
,
data
:
{
url
:
'
http://localhost:8001/api/users/8/
'
,
username
:
'
Tutuplapak
'
,
email
:
''
,
is_staff
:
false
,
...
...
assets/js/components/Vacancy.jsx
View file @
79ae3176
...
...
@@ -125,7 +125,7 @@ export default class Vacancy extends React.Component {
<
h4
>
{
this
.
props
.
data
.
name
}
</
h4
>
{
this
.
props
.
data
.
company
.
name
}
<
br
/>
{
this
.
props
.
data
.
company
.
address
}
<
br
/><
br
/>
<
b
>
{
`Ditutup
${
moment
(
moment
(
this
.
props
.
data
.
close_time
)).
fromNow
()}
`
}
</
b
>
<
b
>
{
this
.
props
.
data
.
apply_before
}
</
b
>
</
Grid
.
Column
>
<
Grid
.
Column
floated
=
"right"
>
<
Grid
.
Row
textAlign
=
"center"
>
...
...
core/models/vacancies.py
View file @
79ae3176
from
django.db
import
models
from
core.models.accounts
import
Company
,
Student
import
datetime
from
django.utils
import
timezone
class
Vacancy
(
models
.
Model
):
company
=
models
.
ForeignKey
(
Company
,
related_name
=
"vacancies"
,
null
=
False
)
...
...
@@ -13,6 +14,12 @@ class Vacancy(models.Model):
updated
=
models
.
DateTimeField
(
auto_now
=
True
)
name
=
models
.
CharField
(
max_length
=
100
,
null
=
False
)
@
property
def
apply_before
(
self
):
if
(
self
.
close_time
<
timezone
.
now
()):
return
"Pendaftaran ditutup"
return
"Daftar sebelum "
+
self
.
close_time
.
strftime
(
'%d'
)
+
" "
+
self
.
close_time
.
strftime
(
'%B'
)
+
" "
+
self
.
close_time
.
strftime
(
'%Y'
)
class
Meta
:
ordering
=
[
'-updated'
]
...
...
@@ -32,3 +39,4 @@ class Application(models.Model):
class
Meta
:
unique_together
=
((
"student"
,
"vacancy"
),)
core/serializers/vacancies.py
View file @
79ae3176
...
...
@@ -32,7 +32,7 @@ class VacancySerializer(serializers.ModelSerializer):
class
Meta
:
model
=
Vacancy
fields
=
[
'company'
,
'verified'
,
'open_time'
,
'description'
,
'close_time'
,
'created'
,
'updated'
,
'name'
,
\
fields
=
[
'company'
,
'verified'
,
'open_time'
,
'description'
,
'close_time'
,
'created'
,
'apply_before'
,
'updated'
,
'name'
,
\
'status'
,
'bookmarked'
,
'id'
]
...
...
core/tests/__init__.py
View file @
79ae3176
# __init__.py
from
core.tests.test_accounts
import
LoginTests
,
RegisterTests
from
core.tests.test_vacancies
import
ApplicationTests
,
BookmarkApplicationTests
,
CompanyListsTests
from
core.tests.test_vacancies
import
ApplicationTests
,
BookmarkApplicationTests
,
CompanyListsTests
,
VacancyTest
from
core.tests.test_feedbacks
import
FeedbacksTests
core/tests/test_vacancies.py
View file @
79ae3176
...
...
@@ -7,6 +7,8 @@ from rest_framework.test import APITestCase
from
core.models.accounts
import
Company
,
Student
,
Supervisor
from
core.models.vacancies
import
Vacancy
,
Application
from
datetime
import
timedelta
from
django.utils
import
timezone
class
ApplicationTests
(
APITestCase
):
...
...
@@ -165,6 +167,7 @@ class VacancyTest(APITestCase):
response
=
self
.
client
.
get
(
url
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
def
test_unverified_vacancy_list
(
self
):
superuser
=
User
.
objects
.
create_superuser
(
'dummy.company'
,
'dummy.company@company.com'
,
'lalala123'
)
self
.
client
.
force_authenticate
(
user
=
superuser
)
...
...
@@ -173,12 +176,42 @@ class VacancyTest(APITestCase):
response
=
self
.
client
.
get
(
url
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
def
test_fail_on_unverified_user_vacancy_list
(
self
):
url
=
'/api/vacancies/'
response
=
self
.
client
.
post
(
url
,
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
def
test_vacancy_is_closed
(
self
):
superuser
=
User
.
objects
.
create_superuser
(
'dummy.company'
,
'dummy.company@company.com'
,
'lalala123'
)
new_company
=
Company
.
objects
.
create
(
user
=
superuser
,
description
=
"lalalaz"
,
status
=
Company
.
VERIFIED
,
logo
=
None
,
address
=
None
)
new_vacancy
=
Vacancy
.
objects
.
create
(
company
=
new_company
,
verified
=
True
,
open_time
=
datetime
.
fromtimestamp
(
0
),
description
=
"lalala"
,
close_time
=
timezone
.
now
()
-
timedelta
(
minutes
=
10
))
self
.
client
.
force_authenticate
(
user
=
superuser
)
response
=
new_vacancy
.
apply_before
self
.
assertEqual
(
response
,
"Pendaftaran ditutup"
)
def
test_vacancy_is_closed
(
self
):
superuser
=
User
.
objects
.
create_superuser
(
'dummy.company'
,
'dummy.company@company.com'
,
'lalala123'
)
new_company
=
Company
.
objects
.
create
(
user
=
superuser
,
description
=
"lalalaz"
,
status
=
Company
.
VERIFIED
,
logo
=
None
,
address
=
None
)
new_vacancy
=
Vacancy
.
objects
.
create
(
company
=
new_company
,
verified
=
True
,
open_time
=
datetime
.
fromtimestamp
(
0
),
description
=
"lalala"
,
close_time
=
timezone
.
now
()
+
timedelta
(
minutes
=
10
))
self
.
client
.
force_authenticate
(
user
=
superuser
)
response
=
new_vacancy
.
apply_before
self
.
assertNotEqual
(
response
,
"Pendaftaran ditutup"
)
class
CompanyListsTests
(
APITestCase
):
def
test_company_vacancy_list
(
self
):
new_user
=
User
.
objects
.
create_user
(
'dummy.company3'
,
'dummy.company3@company.com'
,
'lalala123'
)
...
...
core/views/vacancies.py
View file @
79ae3176
...
...
@@ -40,6 +40,8 @@ class VacancyViewSet(MultiSerializerViewSetMixin, viewsets.ModelViewSet):
if
verified
.
lower
()
in
{
"no"
,
"false"
,
"f"
,
"0"
}:
vacancies
=
vacancies
.
filter
(
verified
=
False
)
page
=
self
.
paginate_queryset
(
vacancies
)
print
(
vacancies
)
print
(
request
)
if
page
is
not
None
:
return
self
.
get_paginated_response
(
VacancySerializer
(
page
,
many
=
True
,
context
=
{
'request'
:
request
}).
data
)
return
Response
(
VacancySerializer
(
vacancies
,
many
=
True
,
context
=
{
'request'
:
request
}).
data
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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