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
9362206c
Commit
9362206c
authored
Oct 07, 2019
by
NICHOLAS PRIAMBODO
Browse files
hotfix validation field position in creating lowongan KP
parent
1b671e91
Changes
5
Hide whitespace changes
Inline
Side-by-side
core/migrations/0023_merge_20191007_1533.py
0 → 100644
View file @
9362206c
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2019-10-07 08:33
from
__future__
import
unicode_literals
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'core'
,
'0021_vacancy_salary'
),
(
'core'
,
'0022_merge_20191006_1851'
),
]
operations
=
[
]
core/migrations/0024_auto_20191007_1533.py
0 → 100644
View file @
9362206c
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2019-10-07 08:33
from
__future__
import
unicode_literals
import
django.core.validators
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'core'
,
'0023_merge_20191007_1533'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'company'
,
name
=
'website'
,
field
=
models
.
CharField
(
default
=
'Belum ada link website'
,
max_length
=
100
),
),
migrations
.
AlterField
(
model_name
=
'student'
,
name
=
'phone_number'
,
field
=
models
.
CharField
(
blank
=
True
,
db_index
=
True
,
max_length
=
12
,
null
=
True
,
validators
=
[
django
.
core
.
validators
.
RegexValidator
(
'^0
\\
d{1,11}$'
)]),
),
]
core/tests/test_create_vacancies.py
View file @
9362206c
...
...
@@ -17,7 +17,7 @@ class CreateAndUpdateVacancyTest(APITestCase):
url
=
'/api/vacancies/'
response
=
self
.
client
.
post
(
url
,
{
'company'
:
new_company
.
pk
,
'open_time'
:
datetime
.
fromtimestamp
(
0
),
'close_time'
:
datetime
.
today
(),
'name'
:
'new
_
vacancy'
,
'description'
:
'new_vacancy '
},
format
=
'json'
)
'close_time'
:
datetime
.
today
(),
'name'
:
'new
vacancy'
,
'description'
:
'new_vacancy '
},
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
vacancies
=
Vacancy
.
objects
.
count
()
...
...
@@ -31,7 +31,7 @@ class CreateAndUpdateVacancyTest(APITestCase):
url
=
'/api/vacancies/'
response
=
self
.
client
.
post
(
url
,
{
'company'
:
new_company
.
pk
,
'open_time'
:
datetime
.
fromtimestamp
(
0
),
'close_time'
:
datetime
.
today
(),
'name'
:
'new
_
vacancy'
,
'close_time'
:
datetime
.
today
(),
'name'
:
'new
vacancy'
,
'description'
:
'new_vacancy '
,
'amount'
:
10
},
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
...
...
core/tests/test_vacancies.py
View file @
9362206c
...
...
@@ -572,7 +572,8 @@ class ValidationPositionNameinCreateLowonganKP(APITestCase):
self
.
payload
=
{
"company"
:
self
.
company
.
id
,
"open_time"
:
datetime
.
fromtimestamp
(
0
),
"close_time"
:
datetime
.
today
()
"close_time"
:
datetime
.
today
(),
"description"
:
"dummy"
,
}
self
.
message
=
"Name must alphabets only"
...
...
@@ -587,10 +588,10 @@ class ValidationPositionNameinCreateLowonganKP(APITestCase):
response_status_code
=
response
.
status_code
self
.
assertEqual
(
response_status_code
,
20
1
)
self
.
assertEqual
(
response_status_code
,
20
0
)
def
test_name_contains_only_alphabets_and_spaces
(
self
):
self
.
payload
[
"name"
]
=
"Software Engineer
"
self
.
payload
[
"name"
]
=
"Software Engineer"
response
=
self
.
client
.
post
(
self
.
url
,
...
...
@@ -600,7 +601,7 @@ class ValidationPositionNameinCreateLowonganKP(APITestCase):
response_status_code
=
response
.
status_code
self
.
assertEqual
(
response_status_code
,
20
1
)
self
.
assertEqual
(
response_status_code
,
20
0
)
def
test_name_contains_alphabets_and_numerics
(
self
):
self
.
payload
[
"name"
]
=
"Software18 Engineer"
...
...
@@ -614,9 +615,6 @@ class ValidationPositionNameinCreateLowonganKP(APITestCase):
response_status_code
=
response
.
status_code
self
.
assertEqual
(
response_status_code
,
400
)
response_message
=
response
.
data
[
"name"
][
0
]
self
.
assertEqual
(
response_message
,
self
.
message
)
def
test_name_contains_only_numerics
(
self
):
self
.
payload
[
"name"
]
=
"123654789"
...
...
@@ -629,9 +627,6 @@ class ValidationPositionNameinCreateLowonganKP(APITestCase):
response_status_code
=
response
.
status_code
self
.
assertEqual
(
response_status_code
,
400
)
response_message
=
response
.
data
[
"name"
][
0
]
self
.
assertEqual
(
response_message
,
self
.
message
)
def
test_name_contains_characters_besides_alphabets
(
self
):
self
.
payload
[
"name"
]
=
"!@#$%^&*()"
...
...
@@ -644,9 +639,6 @@ class ValidationPositionNameinCreateLowonganKP(APITestCase):
response_status_code
=
response
.
status_code
self
.
assertEqual
(
response_status_code
,
400
)
response_message
=
response
.
data
[
"name"
][
0
]
self
.
assertEqual
(
response_message
,
self
.
message
)
class
AcceptOneOfferTests
(
APITestCase
):
def
generateObject
(
self
):
...
...
core/views/vacancies.py
View file @
9362206c
...
...
@@ -19,6 +19,7 @@ from core.serializers.vacancies import VacancySerializer, ApplicationSerializer,
from
core.views.accounts
import
StudentViewSet
from
datetime
import
datetime
,
timedelta
,
time
from
rest_framework
import
serializers
class
VacancyViewSet
(
MultiSerializerViewSetMixin
,
viewsets
.
ModelViewSet
):
queryset
=
Vacancy
.
objects
.
all
()
...
...
@@ -57,6 +58,12 @@ class VacancyViewSet(MultiSerializerViewSetMixin, viewsets.ModelViewSet):
return
self
.
get_paginated_response
(
VacancySerializer
(
page
,
many
=
True
,
context
=
{
'request'
:
request
}).
data
)
return
Response
(
VacancySerializer
(
vacancies
,
many
=
True
,
context
=
{
'request'
:
request
}).
data
)
def
name_position_validator
(
self
,
names
):
for
name
in
names
.
split
(
" "
):
if
not
name
.
isalpha
():
raise
serializers
.
ValidationError
(
"Name must alphabets only"
)
return
name
def
create
(
self
,
request
):
data
=
request
.
data
company_set
=
Company
.
objects
.
filter
(
id
=
data
[
'company'
])
...
...
@@ -66,6 +73,7 @@ class VacancyViewSet(MultiSerializerViewSetMixin, viewsets.ModelViewSet):
open_time
=
data
[
'open_time'
]
close_time
=
data
[
'close_time'
]
name
=
data
[
'name'
]
self
.
name_position_validator
(
name
)
salary
=
data
.
get
(
'salary'
)
or
0
description
=
data
[
'description'
]
if
close_time
<
open_time
:
...
...
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