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
d0923615
Commit
d0923615
authored
Oct 05, 2019
by
Fajrin Kingwijati
Browse files
1606837631-10 Sebagai perusahaan, saya ingin menyimpan kategori perusahaan
#10
parent
cba2c305
Changes
7
Hide whitespace changes
Inline
Side-by-side
assets/js/CompanyProfile.jsx
View file @
d0923615
...
...
@@ -21,7 +21,7 @@ export default class CompanyProfile extends React.Component {
<
div
className
=
"biodataCompany"
>
<
h2
>
{
data
.
name
}
</
h2
>
<
h3
>
{
data
.
address
}
t
</
h3
>
<
p
>
{
data
.
description
}
</
p
>
<
p
>
{
data
.
category
}
-
{
data
.
description
}
</
p
>
</
div
>
</
Container
>
</
Segment
>
...
...
assets/js/__test__/CompanyProfile-test.jsx
View file @
d0923615
...
...
@@ -24,6 +24,7 @@ const companyUser = {
verified
:
true
,
logo
:
'
http://localhost:8001/files/company-logo/8a258a48-3bce-4873-b5d1-538b360d0059.png
'
,
address
:
'
Jl. Kebayoran Baru nomor 13, Jakarta Barat
'
,
category
:
'
Belum ada kategori perusahaan
'
,
},
supervisor
:
null
,
student
:
null
,
...
...
assets/js/components/CompanyRegisterModal.jsx
View file @
d0923615
import
React
from
'
react
'
;
import
{
browserHistory
}
from
'
react-router
'
;
import
{
Modal
,
Button
,
Form
,
Input
,
TextArea
,
Header
,
Icon
}
from
'
semantic-ui-react
'
;
import
{
Modal
,
Button
,
Form
,
Input
,
TextArea
,
Header
,
Icon
,
Dropdown
}
from
'
semantic-ui-react
'
;
import
ModalAlert
from
'
./../components/ModalAlert
'
;
import
Server
from
'
./../lib/Server
'
;
import
Storage
from
'
./../lib/Storage
'
;
...
...
@@ -17,6 +17,26 @@ export default class CompanyRegisterModal extends React.Component {
this
.
handleSubmit
=
this
.
handleSubmit
.
bind
(
this
);
}
categoryOptions
=
[
{
value
:
'
Perusahaan Asuransi
'
,
text
:
'
Perusahaan Asuransi
'
},
{
value
:
'
Perusahaan Bioteknologi
'
,
text
:
'
Perusahaan Bioteknologi
'
},
{
value
:
'
Perusahaan Elektronik
'
,
text
:
'
Perusahaan Elektronik
'
},
{
value
:
'
Perusahaan Energi
'
,
text
:
'
Perusahaan Energi
'
},
{
value
:
'
Perusahaan Farmasi
'
,
text
:
'
Perusahaan Farmasi
'
},
{
value
:
'
Firma Akuntansi
'
,
text
:
'
Firma Akuntansi
'
},
{
value
:
'
Agen Periklanan
'
,
text
:
'
Agen Periklanan
'
},
{
value
:
'
Perusahaan Internet
'
,
text
:
'
Perusahaan Internet
'
},
{
value
:
'
Perusahaan Jasa
'
,
text
:
'
Perusahaan Jasa
'
},
{
value
:
'
Perusahaan Komputer
'
,
text
:
'
Perusahaan Komputer
'
},
{
value
:
'
Perusahaan Konsultansi
'
,
text
:
'
Perusahaan Konsultansi
'
},
{
value
:
'
Perusahaan Logistik
'
,
text
:
'
Perusahaan Logistik
'
},
{
value
:
'
Perusahaan Media
'
,
text
:
'
Perusahaan Media
'
},
{
value
:
'
Perusahaan Perangkat Keras
'
,
text
:
'
Perusahaan Perangkat Keras
'
},
{
value
:
'
Perusahaan Perangkat Lunak
'
,
text
:
'
Perusahaan Perangkat Lunak
'
},
{
value
:
'
Perusahaan Teknologi
'
,
text
:
'
Perusahaan Teknologi
'
},
{
value
:
'
Perusahaan Telekomunikasi
'
,
text
:
'
Perusahaan Telekomunikasi
'
},
]
componentWillUpdate
()
{
this
.
fixBody
();
}
...
...
@@ -34,6 +54,10 @@ export default class CompanyRegisterModal extends React.Component {
this
.
setState
({
[
e
.
target
.
name
]:
e
.
target
.
value
});
};
handleSelectChange
=
(
e
,
data
)
=>
{
this
.
setState
({
[
data
.
name
]:
data
.
value
});
}
handleFile
=
(
e
)
=>
{
this
.
setState
({
[
e
.
target
.
name
]:
e
.
target
.
files
[
0
]
});
};
...
...
@@ -99,6 +123,19 @@ export default class CompanyRegisterModal extends React.Component {
<
label
htmlFor
=
"name"
>
Nama Perusahaan
</
label
>
<
Input
onChange
=
{
this
.
handleChange
}
placeholder
=
"Nama Perusahaan"
name
=
"name"
required
/>
</
Form
.
Field
>
<
Form
.
Field
required
>
<
label
htmlFor
=
"name"
>
Kategori Perusahaan
</
label
>
<
Dropdown
placeholder
=
'Kategori Perusahaan'
fluid
name
=
"category"
onChange
=
{
this
.
handleSelectChange
}
search
selection
options
=
{
this
.
categoryOptions
}
/>
</
Form
.
Field
>
<
Form
.
Field
required
></
Form
.
Field
>
<
Form
.
Field
required
>
<
label
htmlFor
=
"logo"
>
Logo
</
label
>
<
Input
...
...
core/migrations/0014_company_category.py
0 → 100644
View file @
d0923615
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2019-10-05 04:52
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'core'
,
'0013_auto_20170602_1130'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'company'
,
name
=
'category'
,
field
=
models
.
CharField
(
default
=
b
'Belum ada kategori perusahaan'
,
max_length
=
140
),
),
]
core/models/accounts.py
View file @
d0923615
...
...
@@ -96,6 +96,7 @@ class Company(models.Model):
status
=
models
.
IntegerField
(
default
=
NEW
)
logo
=
models
.
FileField
(
upload_to
=
get_company_logo_file_path
,
null
=
True
,
blank
=
True
,
validators
=
[
validate_image_file_extension
])
address
=
models
.
CharField
(
max_length
=
1000
,
blank
=
True
,
null
=
True
)
category
=
models
.
CharField
(
max_length
=
140
,
default
=
"Belum ada kategori perusahaan"
)
@
property
def
name
(
self
):
...
...
core/tests/test_accounts.py
View file @
d0923615
...
...
@@ -91,7 +91,7 @@ class RegisterTests(APITestCase):
def
test_create_and_recreate
(
self
):
url
=
'/api/register/'
tc_post
=
{
'password'
:
'corporatepass'
,
'name'
:
'tutuplapak'
,
'description'
:
'menutup lapak'
,
'email'
:
'email@email.com'
,
'logo'
:
'lalala'
,
'address'
:
'alamat'
}
tc_post
=
{
'password'
:
'corporatepass'
,
'name'
:
'tutuplapak'
,
'description'
:
'menutup lapak'
,
'email'
:
'email@email.com'
,
'logo'
:
'lalala'
,
'address'
:
'alamat'
,
'category'
:
'Perusahaan Jasa'
}
response
=
self
.
client
.
post
(
url
,
tc_post
,
format
=
'multipart'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
...
...
core/views/accounts.py
View file @
d0923615
...
...
@@ -240,7 +240,7 @@ class CompanyRegisterViewSet(viewsets.GenericViewSet):
type: string
"""
data
=
{}
for
attr
in
[
'password'
,
'email'
,
'name'
,
'description'
,
'logo'
,
'address'
]:
for
attr
in
[
'password'
,
'email'
,
'name'
,
'description'
,
'logo'
,
'address'
,
'category'
]:
data
[
attr
]
=
request
.
data
.
get
(
attr
)
if
data
[
attr
]
is
None
:
return
Response
({
'error'
:
attr
+
' is required'
},
status
=
status
.
HTTP_400_BAD_REQUEST
)
...
...
@@ -257,7 +257,8 @@ class CompanyRegisterViewSet(viewsets.GenericViewSet):
user
=
user
,
description
=
data
[
'description'
],
logo
=
data
[
'logo'
],
address
=
data
[
'address'
]
address
=
data
[
'address'
],
category
=
data
[
'category'
]
)
user
.
save
()
company
.
save
()
...
...
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