diff --git a/assets/css/custom.css b/assets/css/custom.css index 79273fc0686890dd7c6970a2ffecd8d8bf185252..7759976a116fbf94cdbe70e1fc6f96da2b8fd363 100755 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -100,22 +100,32 @@ font-size: 30px; } .coverLetter{ - margin-top:15px; + margin-top:30px; + } .linkCV{ float: right; - margin-top: 10px; + margin-top: 30px; + margin-bottom: 10px; } .registerForm{ - width: 800px; margin: 0 auto; padding:50px; background-color: #3B8686; } +item{ + color:black; +} + +textarea{ + width: 800px !important; + height: 160px !important; +} + .register{ background-color:#3B8686; @@ -142,4 +152,8 @@ input.active:invalid { card .formRegis{ margin-top: 100px; +} + +itemLowongan{ + color: black; } \ No newline at end of file diff --git a/assets/js/Dashboard.jsx b/assets/js/Dashboard.jsx index f297f54d69d0488114593e8810b001fcd4bd1a7f..513a5b8c12f49ec26f84782485c465c0cfacc59b 100755 --- a/assets/js/Dashboard.jsx +++ b/assets/js/Dashboard.jsx @@ -11,7 +11,7 @@ export default class Dashboard extends React.Component { render = () => ( <div> - <TopMenu color="blue" /> + <TopMenu /> {this.props.children} </div> ) diff --git a/assets/js/components/Lowongan.jsx b/assets/js/components/Lowongan.jsx index 2998b80a7b13fe070028d2e16695fe0e126f951b..37a10d4df785838dee8f2dbc448239e6619e2e1a 100644 --- a/assets/js/components/Lowongan.jsx +++ b/assets/js/components/Lowongan.jsx @@ -16,20 +16,21 @@ export default class Lowongan extends React.Component { <Item > {image} <Item.Content verticalAlign="middle"> - <Item.Header>{this.props.header}</Item.Header> + <Item.Header> + + {this.props.header} + + </Item.Header> <Item.Description>{this.props.content}</Item.Description> - <Item.Extra> + <Item.Content> - <h3>{ this.props.data.data1 }</h3> - <h4>PT. Koding Kuat </h4> - <h5> JL.Kali deres utara no.1 </h5> - <h5> Jakarta Barat, DKI Jakarta</h5> + <h3>{ this.props.data.data1 }</h3> + <h4>PT. Koding Kuat </h4> + <h5> JL.Kali deres utara no.1 Jakarta Barat, DKI Jakarta</h5> - <ModalPendaftaran id={1} data={ { header: 'Deskripsi Lowongan', description: 'Lorem ipsum dolor sit amet, consectetur' + - ' adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim ' + - 'veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.' } } buttonTitle="Daftar" /> + <ModalPendaftaran id={1} data={ { header: 'Deskripsi Lowongan', description: 'Lorem ipsum dolor sit amet'} } buttonTitle="Daftar" /> - </Item.Extra> + </Item.Content> </Item.Content> </Item> diff --git a/assets/js/components/ModalPendaftaran.jsx b/assets/js/components/ModalPendaftaran.jsx index 549dd0e88b10dcd70528754d7c6ca9201c31c94b..ea22f3ac3ad4ff7b97116b73a5571585163c5f1f 100644 --- a/assets/js/components/ModalPendaftaran.jsx +++ b/assets/js/components/ModalPendaftaran.jsx @@ -46,26 +46,28 @@ export default class ModalPendaftaran extends React.Component { > <Modal.Header>{this.props.data.header}</Modal.Header> - <Modal.Content image> - <div className="image"> - <Icon name="right arrow" /> - </div> + + <Modal.Content> + <Modal.Description> <Modal.Header> <h3> Deskripsi Lowongan </h3></Modal.Header> {this.props.data.description} - <div className="linkCV"> + </Modal.Description> + + <div className="coverLetter"> + + <div className="linkCV"> <a> your latest CV </a> </div> - <div className="coverLetter"> <h5> Write your Cover Letter </h5> - <Form> - <TextArea placeholder="Tell us more" onChange={this.handleChange} /> + <Form > + <TextArea placeholder="Tell us more" size='big' /> </Form> + </div> - </Modal.Description> </Modal.Content> <Modal.Actions> <ModalAlert diff --git a/assets/js/components/TopMenu.jsx b/assets/js/components/TopMenu.jsx index 0bf949c91ec7cd34c318a8d9e8ad02e3dedbf227..a08c56eabb0045e8877b4145365ac7478d499976 100644 --- a/assets/js/components/TopMenu.jsx +++ b/assets/js/components/TopMenu.jsx @@ -21,11 +21,11 @@ export default class TopMenu extends React.Component { render() { return ( - <Menu pointing secondary> + <Menu color="blue" pointing secondary> <Image as="a" size="small" src="/assets/img/logo.png" href="/" /> <Menu.Menu position="right"> - <Menu.Item as={Link} to="/lowongan" name="home" /> - <Menu.Item as={Link} to="/profile" name="profil" /> + <Menu.Item as={Link} to="/lowongan" name="home" onClick={this.handleItemClick} /> + <Menu.Item as={Link} to="/profile" name="profil" onClick={this.handleItemClick} /> {Server.isLoggedIn() ? <Menu.Item as={Link} onClick={this.logout} name="logout" /> : <Menu.Item as={Link} to="/login" name="login" /> diff --git a/assets/js/components/VacancyList.jsx b/assets/js/components/VacancyList.jsx index 044af11e0f8955d9d0f9aabd79eadb6e1458a696..4beaf37da3a2649f0d530dc10d8ee70a5ca7cabe 100644 --- a/assets/js/components/VacancyList.jsx +++ b/assets/js/components/VacancyList.jsx @@ -27,6 +27,7 @@ export default class VacancyList extends React.Component { ); } + render = () => { return ( <Item.Group relaxed> diff --git a/core/tests/__init__.py b/core/tests/__init__.py index 98a24c105b053bd36d849c831542573790cc2a51..7f0ec2772e948e4dff5d057986c4226343c82291 100755 --- a/core/tests/__init__.py +++ b/core/tests/__init__.py @@ -1,2 +1,4 @@ # __init__.py -from core.tests.test_login import LoginTests +from core.tests.test_accounts import LoginTests +from core.tests.test_vacancies import ApplicationTests, BookmarkApplicationTests + diff --git a/core/tests/test_accounts.py b/core/tests/test_accounts.py new file mode 100644 index 0000000000000000000000000000000000000000..afd8eb12cd533ad3ffbd48241f15f25b7992b2c5 --- /dev/null +++ b/core/tests/test_accounts.py @@ -0,0 +1,76 @@ +import requests_mock +from rest_framework import status +from rest_framework.test import APITestCase +from django.contrib.auth.models import User +from core.models.accounts import Company + +class LoginTests(APITestCase): + + @requests_mock.Mocker() + def test_succesful_student_login_relogin(self, m): + """ + Ensure we can login + """ + + m.post('https://api.cs.ui.ac.id/authentication/ldap/v2/', json={ + "username": "dummy.mahasiswa", + "nama": "Dummy Mahasiswa", + "state": 1, + "kode_org": "01.00.12.01:mahasiswa", + "kodeidentitas": "1234567890", + "nama_role": "mahasiswa" + }, status_code=200) + + url = '/api/login/' + + response = self.client.post(url, { 'username' : 'dummy.mahasiswa', 'password' : 'lalala', 'login-type' : 'sso-ui'}, format='json') + self.assertEqual(response.status_code, status.HTTP_201_CREATED) + + response = self.client.post(url, {'username': 'dummy.mahasiswa', 'password': 'lalala', 'login-type': 'sso-ui'}, format='json') + self.assertEqual(response.status_code, status.HTTP_200_OK) + + @requests_mock.Mocker() + def test_successful_supervisor_login_relogin(self, m): + m.post('https://api.cs.ui.ac.id/authentication/ldap/v2/', json={ + "username": "dummy.dosen", + "nama": "Dummy Dosen", + "state": 1, + "kode_org": "01.00.12.01:dosen", + "kodeidentitas": "1234567891", + "nama_role": "dosen" + }, status_code=200) + + url = '/api/login/' + response = self.client.post(url, {'username': 'dummy.dosen', 'password': 'lalala', 'login-type': 'sso-ui'}, format='json') + self.assertEqual(response.status_code, status.HTTP_201_CREATED) + + response = self.client.post(url, {'username': 'dummy.dosen', 'password': 'lalala', 'login-type': 'sso-ui'}, format='json') + self.assertEqual(response.status_code, status.HTTP_200_OK) + + @requests_mock.Mocker() + def test_failed_sso_login(self, m): + m.post('https://api.cs.ui.ac.id/authentication/ldap/v2/', json={ + "state": 0 + }, status_code=200) + + url = '/api/login/' + response = self.client.post(url, {'username': 'dummy.salah', 'password': 'lalala', 'login-type': 'sso-ui'}, format='json') + self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) + + def test_failed_company_login(self): + url = '/api/login/' + response = self.client.post(url, {'username': 'dummy.company.failed', 'password': 'lalala', 'login-type': 'company'}, format='json') + self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) + + def test_success_company_login(self): + new_user = User.objects.create_user('dummy.login.company', 'dummy.login.company@company.com', 'lalala123') + new_company = Company.objects.create(user=new_user, description="lalalala", verified=True, logo=None, alamat=None) + + url = '/api/login/' + response = self.client.post(url, {'username': 'dummy.login.company', 'password': 'lalala123', 'login-type': 'company'}, format='json') + self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) + + def test_bad_request(self): + url = '/api/login/' + response = self.client.post(url, {'uesrname': 'lalala'}, format='json') + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) \ No newline at end of file diff --git a/core/tests/test_login.py b/core/tests/test_login.py deleted file mode 100644 index 4ea35329a75e875d64eebc399b4e10d51648aaf1..0000000000000000000000000000000000000000 --- a/core/tests/test_login.py +++ /dev/null @@ -1,53 +0,0 @@ -import requests_mock -from rest_framework import status -from rest_framework.test import APITestCase - -class LoginTests(APITestCase): - - @requests_mock.Mocker() - def test_login(self, m): - """ - Ensure we can login - """ - - m.post('https://api.cs.ui.ac.id/authentication/ldap/v2/', [{'json': { - "username": "dummy.mahasiswa", - "nama": "Dummy Mahasiswa", - "state": 1, - "kode_org": "01.00.12.01:mahasiswa", - "kodeidentitas": "1234567890", - "nama_role": "mahasiswa" - }, 'status_code': 200}, {'json': { - "username": "dummy.mahasiswa", - "nama": "Dummy Mahasiswa", - "state": 1, - "kode_org": "01.00.12.01:mahasiswa", - "kodeidentitas": "1234567890", - "nama_role": "mahasiswa" - }, 'status_code': 200}, {'json': { - "username": "dummy.dosen", - "nama": "Dummy Dosen", - "state": 1, - "kode_org": "01.00.12.01:dosen", - "kodeidentitas": "1234567820", - "nama_role": "dosen" - }, 'status_code': 200}, {'json': { - "state": 0 - }, 'status_code': 200}]) - - url = '/api/login/' - response = self.client.post(url, { 'username' : 'dummy.mahasiswa', 'password' : 'lalala', 'login-type' : 'sso-ui'}, format='json') - self.assertEqual(response.status_code, status.HTTP_201_CREATED) - - response = self.client.post(url, {'username': 'dummy.mahasiswa', 'password': 'lalala', 'login-type': 'sso-ui'}, - format='json') - self.assertEqual(response.status_code, status.HTTP_200_OK) - - response = self.client.post(url, {'username': 'dummy.dosen', 'password': 'lalala', 'login-type': 'sso-ui'}, format='json') - self.assertEqual(response.status_code, status.HTTP_201_CREATED) - - response = self.client.post(url, {'username': 'dummy.salah', 'password': 'lalala', 'login-type': 'sso-ui'}, format='json') - self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) - - response = self.client.post(url, {'username': 'dummy.perusahaan.salah', 'password': 'lalala', 'login-type': 'perusahaan'}, format='json') - self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) diff --git a/core/tests/test_vacancies.py b/core/tests/test_vacancies.py new file mode 100644 index 0000000000000000000000000000000000000000..a8f718e1830b340043de1e009ecd99946a01369d --- /dev/null +++ b/core/tests/test_vacancies.py @@ -0,0 +1,113 @@ +from datetime import datetime +import requests_mock +from rest_framework import status +from rest_framework.test import APITestCase +from django.contrib.auth.models import User +from core.models.accounts import Company +from core.models.vacancies import Vacancy + +class ApplicationTests(APITestCase): + + @requests_mock.Mocker() + def test_application_list(self, m): + m.post('https://api.cs.ui.ac.id/authentication/ldap/v2/', json={ + "username": "dummy.mahasiswa", + "nama": "Dummy Mahasiswa", + "state": 1, + "kode_org": "01.00.12.01:mahasiswa", + "kodeidentitas": "1234567890", + "nama_role": "mahasiswa" + }, status_code=200) + + url = '/api/login/' + + response = self.client.post(url, {'username': 'dummy.mahasiswa', 'password': 'lalala', 'login-type': 'sso-ui'}, format='json') + student_id = response.data.get('student').get('id') + + url = '/api/students/' + str(student_id) + '/applications/' + response = self.client.get(url) + + self.assertEqual(response.status_code, status.HTTP_200_OK) + + + @requests_mock.Mocker() + def test_application_create_and_delete(self, m): + m.post('https://api.cs.ui.ac.id/authentication/ldap/v2/', json={ + "username": "dummy.mahasiswa", + "nama": "Dummy Mahasiswa", + "state": 1, + "kode_org": "01.00.12.01:mahasiswa", + "kodeidentitas": "1234567890", + "nama_role": "mahasiswa" + }, status_code=200) + + url = '/api/login/' + + response = self.client.post(url, {'username': 'dummy.mahasiswa', 'password': 'lalala', 'login-type': 'sso-ui'}, + format='json') + student_id = response.data.get('student').get('id') + + new_user = User.objects.create_user('dummy.company', 'dummy.company@company.com', 'lalala123') + new_company = Company.objects.create(user=new_user, description="lalala",verified=True,logo=None,alamat=None) + new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(0), description="lalala", close_time=datetime.today()) + + url = '/api/students/' + str(student_id) + '/applications/' + response = self.client.post(url, {'vacancy_id' : new_vacancy.pk}, format='json') + self.assertEqual(response.status_code, status.HTTP_200_OK) + + url = '/api/students/' + str(student_id) + '/applications/' + str(new_vacancy.pk) + '/' + response = self.client.delete(url) + self.assertEqual(response.status_code, status.HTTP_200_OK) + +class BookmarkApplicationTests(APITestCase): + + @requests_mock.Mocker() + def test_application_list(self, m): + m.post('https://api.cs.ui.ac.id/authentication/ldap/v2/', json={ + "username": "dummy.mahasiswa", + "nama": "Dummy Mahasiswa", + "state": 1, + "kode_org": "01.00.12.01:mahasiswa", + "kodeidentitas": "1234567890", + "nama_role": "mahasiswa" + }, status_code=200) + + url = '/api/login/' + + response = self.client.post(url, {'username': 'dummy.mahasiswa', 'password': 'lalala', 'login-type': 'sso-ui'}, format='json') + student_id = response.data.get('student').get('id') + + url = '/api/students/' + str(student_id) + '/bookmarked-vacancies/' + response = self.client.get(url) + + self.assertEqual(response.status_code, status.HTTP_200_OK) + + + @requests_mock.Mocker() + def test_application_create_and_delete(self, m): + m.post('https://api.cs.ui.ac.id/authentication/ldap/v2/', json={ + "username": "dummy.mahasiswa", + "nama": "Dummy Mahasiswa", + "state": 1, + "kode_org": "01.00.12.01:mahasiswa", + "kodeidentitas": "1234567890", + "nama_role": "mahasiswa" + }, status_code=200) + + url = '/api/login/' + + response = self.client.post(url, {'username': 'dummy.mahasiswa', 'password': 'lalala', 'login-type': 'sso-ui'}, + format='json') + student_id = response.data.get('student').get('id') + + new_user = User.objects.create_user('dummy.company', 'dummy.company@company.com', 'lalala123') + new_company = Company.objects.create(user=new_user, description="lalala",verified=True,logo=None,alamat=None) + new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(0), description="lalala", close_time=datetime.today()) + + url = '/api/students/' + str(student_id) + '/bookmarked-vacancies/' + response = self.client.post(url, {'vacancy_id' : new_vacancy.pk}, format='json') + self.assertEqual(response.status_code, status.HTTP_200_OK) + + url = '/api/students/' + str(student_id) + '/bookmarked-vacancies/' + str(new_vacancy.pk) + '/' + response = self.client.delete(url) + self.assertEqual(response.status_code, status.HTTP_200_OK)