diff --git a/assets/js/CreateVacancy.jsx b/assets/js/CreateVacancy.jsx index b2bff53ad3e244bb0938cd1755f190b0b875f070..1d5122fe45a612bbbdbe6e6b6ba292be14ffbc6e 100644 --- a/assets/js/CreateVacancy.jsx +++ b/assets/js/CreateVacancy.jsx @@ -32,6 +32,7 @@ export default class CreateVacancy extends React.Component { close_time: moment(), name: '', description: '', + salary: 0, }; if (this.state.vacancyId) { @@ -39,6 +40,7 @@ export default class CreateVacancy extends React.Component { this.setState({ description: r.description, name: r.name, + salary: r.salary, open_time: moment(r.open_time), close_time: moment(r.close_time), loading: false, @@ -70,6 +72,7 @@ export default class CreateVacancy extends React.Component { const data = {}; data.name = this.state.name; data.description = this.state.description; + data.salary = this.state.salary; data.open_time = this.state.open_time.format(); data.close_time = this.state.close_time.format(); if (!this.state.vacancyId) { @@ -104,6 +107,7 @@ export default class CreateVacancy extends React.Component { <CKEditor value={this.state.description} onChange={this.handleEditor} /> } <script>CKEDITOR.replace( 'description' );</script> <br /> + <Form.Field label="Gaji / Insentif (Rupiah per bulan)" type="number" min="0" name="salary" control={Input} onChange={this.handleChange} value={this.state.salary} /> <Form.Group widths="equal"> <Form.Field className="open-time-field" diff --git a/assets/js/__test__/components/Vacancy-test.jsx b/assets/js/__test__/components/Vacancy-test.jsx index 9f1e253be4d99c08928d497fd48ffa00f183b6c3..31986e0f87ee8d55aeeb388685b4d33fd916befc 100644 --- a/assets/js/__test__/components/Vacancy-test.jsx +++ b/assets/js/__test__/components/Vacancy-test.jsx @@ -7,6 +7,7 @@ import Storage from '../../lib/Storage'; describe('Vacancy', () => { const fetchMock = require('fetch-mock'); const response = { + salary: '1', close_time: '2019-03-28T05:55:42Z', company: { address: 'kebayoran baru', @@ -24,6 +25,7 @@ describe('Vacancy', () => { }; const response2 = { + salary: '1', close_time: '2019-03-28T05:55:42Z', company: { address: 'kebayoran baru', diff --git a/assets/js/__test__/components/VacancyList-test.jsx b/assets/js/__test__/components/VacancyList-test.jsx index 0ac2b46c3132983fe241dd3c7567ba7b3949b9e5..a3e4d51fdac11fab65e013cba72fbcf1d855e78f 100644 --- a/assets/js/__test__/components/VacancyList-test.jsx +++ b/assets/js/__test__/components/VacancyList-test.jsx @@ -135,6 +135,7 @@ describe('VacancyList', () => { verified: true, open_time: '2017-04-26T03:39:11Z', description: 'deskripsi', + salary: '1', close_time: '2017-04-30T03:39:11Z', created: '2017-04-26T03:39:39.916758Z', updated: '2017-04-26T03:41:07.157634Z', @@ -163,6 +164,7 @@ describe('VacancyList', () => { verified: true, open_time: '2017-04-26T03:39:11Z', description: 'deskripsi', + salary: '1', close_time: '2017-04-30T03:39:11Z', created: '2017-04-26T03:39:39.916758Z', updated: '2017-04-26T03:41:07.157634Z', @@ -191,6 +193,7 @@ describe('VacancyList', () => { verified: true, open_time: '2017-04-26T03:39:11Z', description: 'deskripsi', + salary: '1', close_time: '2017-04-30T03:39:11Z', created: '2017-04-26T03:39:39.916758Z', updated: '2017-04-26T03:41:07.157634Z', @@ -219,6 +222,7 @@ describe('VacancyList', () => { verified: true, open_time: '2017-04-26T03:39:11Z', description: 'deskripsi', + salary: '1', close_time: '2017-04-30T03:39:11Z', created: '2017-04-26T03:39:39.916758Z', updated: '2017-04-26T03:41:07.157634Z', @@ -247,6 +251,7 @@ describe('VacancyList', () => { verified: true, open_time: '2017-04-26T03:39:11Z', description: 'deskripsi', + salary: '1', close_time: '2017-04-30T03:39:11Z', created: '2017-04-26T03:39:39.916758Z', updated: '2017-04-26T03:41:07.157634Z', @@ -258,6 +263,7 @@ describe('VacancyList', () => { ]; const response = [{ + salary: '1', close_time: '2019-03-28T05:55:42Z', company: { address: 'kebayoran baru', @@ -273,6 +279,7 @@ describe('VacancyList', () => { updated: '2017-03-28T07:34:13.122093Z', verified: true, }, { + salary: '1', close_time: '2019-03-28T05:55:42Z', company: { address: 'kebayoran baru', @@ -290,6 +297,7 @@ describe('VacancyList', () => { }]; const response2 = [{ + salary: '1', close_time: '2019-03-28T05:55:42Z', company: { address: 'kebayoran baru', diff --git a/assets/js/components/Vacancy.jsx b/assets/js/components/Vacancy.jsx index a755cca4af553ec413c1e6dd5eb80bd977b7811f..283bc462efff0e79a0d6d2c8d6a4fc3cec3d2181 100644 --- a/assets/js/components/Vacancy.jsx +++ b/assets/js/components/Vacancy.jsx @@ -124,7 +124,8 @@ export default class Vacancy extends React.Component { <Grid.Column floated="left"> <h4>{ this.props.data.name }</h4> { this.props.data.company.name }<br /> - { this.props.data.company.address }<br /><br /> + { this.props.data.company.address }<br /> + Rp. { this.props.data.salary } <br /> <br /> <b>{`Ditutup ${moment(moment(this.props.data.close_time)).fromNow()}`}</b> </Grid.Column> <Grid.Column floated="right" > diff --git a/assets/js/components/VacancyList.jsx b/assets/js/components/VacancyList.jsx index 56efd84c7b8b7d143524d6cfd78780939a4f79a6..654baa06f3c83dc875db55fdc7a7577ff7bd9231 100644 --- a/assets/js/components/VacancyList.jsx +++ b/assets/js/components/VacancyList.jsx @@ -70,6 +70,7 @@ export default class VacancyList extends React.Component { bookmarked={vacancy.bookmarked ? 1 : 0} data={vacancy} studentId={this.props.userId} + salary={this.props.salary} /> ), ); diff --git a/core/migrations/0020_merge_20191006_1406.py b/core/migrations/0020_merge_20191006_1406.py new file mode 100644 index 0000000000000000000000000000000000000000..12d371c21048e36fd9b1dd6201ea591debb1c68f --- /dev/null +++ b/core/migrations/0020_merge_20191006_1406.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2019-10-06 07:06 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0017_vacancy_amount'), + ('core', '0019_merge_20191006_0852'), + ] + + operations = [ + ] diff --git a/core/migrations/0021_vacancy_salary.py b/core/migrations/0021_vacancy_salary.py new file mode 100644 index 0000000000000000000000000000000000000000..94f1f06a6e544638903ddf50b8ad270c775ac7a4 --- /dev/null +++ b/core/migrations/0021_vacancy_salary.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2019-10-06 07:07 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0020_merge_20191006_1406'), + ] + + operations = [ + migrations.AddField( + model_name='vacancy', + name='salary', + field=models.IntegerField(default=0), + ), + ] diff --git a/core/models/vacancies.py b/core/models/vacancies.py index bdb75cd2c3d097c2168a8cfcd2fee32f4c9fbb9b..93faa692fa5a53b15b57802dd6056c63224bb293 100644 --- a/core/models/vacancies.py +++ b/core/models/vacancies.py @@ -13,6 +13,8 @@ class Vacancy(models.Model): updated = models.DateTimeField(auto_now=True) name = models.CharField(max_length=100, null=False) amount = models.IntegerField(null=True) + salary = models.IntegerField(default=0) + class Meta: ordering = ['-updated'] diff --git a/core/serializers/vacancies.py b/core/serializers/vacancies.py index 5938e5f9e3ba25099069d7eba381af9cb0ae9b84..c519a4d2f3ddb7f8bb2c394e66bebee471a70e76 100644 --- a/core/serializers/vacancies.py +++ b/core/serializers/vacancies.py @@ -33,7 +33,7 @@ class VacancySerializer(serializers.ModelSerializer): class Meta: model = Vacancy fields = ['company', 'verified', 'open_time', 'description', 'close_time', 'created', 'updated', 'name', \ - 'status', 'bookmarked', 'id'] + 'status', 'bookmarked', 'id', 'salary'] class PostVacancySerializer(serializers.ModelSerializer): diff --git a/core/tests/test_create_vacancies.py b/core/tests/test_create_vacancies.py index 9d8cd65b9c9c0ef2e7c8aff63e20a19435aecc9a..dba96d2046fd00208d686313b56f9f537d84365a 100644 --- a/core/tests/test_create_vacancies.py +++ b/core/tests/test_create_vacancies.py @@ -23,7 +23,7 @@ class CreateAndUpdateVacancyTest(APITestCase): vacancies = Vacancy.objects.count() self.assertEqual(vacancies,1) - def test_new_vacancy_with_amount_success(self): + def test_new_vacancy_with_amount_salary_success(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) @@ -37,6 +37,7 @@ class CreateAndUpdateVacancyTest(APITestCase): vacancy = Vacancy.objects.first() self.assertEqual(vacancy.amount, 10) + self.assertEqual(vacancy.salary, 0) def test_new_vacancy_failed(self): superuser = User.objects.create_superuser('dummy.company', 'dummy.company@company.com', 'lalala123') @@ -61,7 +62,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 ', 'amount': 'sepuluh'}, format='json') + 'description': 'new_vacancy ', 'amount': 'sepuluh', 'salary':'dua juta'}, format='json') self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) vacancies_count = Vacancy.objects.count() @@ -81,7 +82,7 @@ class CreateAndUpdateVacancyTest(APITestCase): 'name': 'new_vacancy2', 'description': 'new_vacancy2'}, format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) - def test_update_vacancy_with_amount_success(self): + def test_update_vacancy_with_amount_salary_success(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) @@ -92,7 +93,7 @@ class CreateAndUpdateVacancyTest(APITestCase): url = '/api/vacancies/' + str(new_vacancy.pk) + '/' response = self.client.patch(url, {'open_time': datetime.fromtimestamp(0), 'close_time': datetime.today(), - 'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 10}, format='json') + 'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 10, 'salary': 2}, format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) vacancy = Vacancy.objects.first() @@ -112,7 +113,7 @@ class CreateAndUpdateVacancyTest(APITestCase): 'name': 'new_vacancy2', 'description': 'new_vacancy2'}, format='json') self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) - def test_update_vacancy_with_amount_failed(self): + def test_update_vacancy_with_amount_salary_string_failed(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) @@ -123,7 +124,7 @@ class CreateAndUpdateVacancyTest(APITestCase): url = '/api/vacancies/' + str(new_vacancy.pk) + '/' response = self.client.patch(url, {'open_time': datetime.fromtimestamp(0), 'close_time': datetime.today(), - 'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 'sepuluh'}, format='json') + 'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 'sepuluh', 'salary': 'dua juta'}, format='json') self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) vacancy = Vacancy.objects.first() diff --git a/core/views/vacancies.py b/core/views/vacancies.py index f51cfd3ae9064cbee6c8f97c29071d8541bc1845..93b38f89a708cc9ebaceb1e1e8f30aae83fa517d 100644 --- a/core/views/vacancies.py +++ b/core/views/vacancies.py @@ -56,10 +56,11 @@ class VacancyViewSet(MultiSerializerViewSetMixin, viewsets.ModelViewSet): open_time = data['open_time'] close_time = data['close_time'] name = data['name'] + salary = data.get('salary') or 0 description = data['description'] if close_time < open_time: raise ValidationError('Waktu tutup lowongan harus lebih dari waktu buka lowongan!') - vacancy = Vacancy(company=company, open_time=open_time, close_time=close_time, name=name, description=description) + vacancy = Vacancy(company=company, open_time=open_time, close_time=close_time, name=name, description=description, salary=salary) if 'amount' in data: if isinstance(data['amount'], int): vacancy.amount = data['amount'] @@ -72,6 +73,7 @@ class VacancyViewSet(MultiSerializerViewSetMixin, viewsets.ModelViewSet): data = request.data vacancy = Vacancy.objects.get(pk=pk) open_time = data['open_time'] + salary = data.get('salary') or 0 close_time = data['close_time'] name = data['name'] description = data['description'] @@ -80,6 +82,7 @@ class VacancyViewSet(MultiSerializerViewSetMixin, viewsets.ModelViewSet): vacancy.open_time = open_time vacancy.close_time = close_time vacancy.name = name + vacancy.salary = salary vacancy.description = description if 'amount' in data: if isinstance(data['amount'], int):