From 97ae315e0a9dfea8f7683891aac4afc4d860fa0d Mon Sep 17 00:00:00 2001 From: Aviliani Pramestya <avipramestya14@gmail.com> Date: Sun, 6 Oct 2019 19:45:26 +0700 Subject: [PATCH 1/4] menambahkan test untuk expected salary --- core/tests/test_accounts.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/tests/test_accounts.py b/core/tests/test_accounts.py index d606b626..3313f74f 100644 --- a/core/tests/test_accounts.py +++ b/core/tests/test_accounts.py @@ -168,3 +168,8 @@ class ProfileUpdateTests(APITestCase): response = self.client.patch(url, {'intro': 'Saya tertarik dengan dunia front-end development'}, format='multipart') self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) self.assertEqual(response.data.get('intro'), 'Saya tertarik dengan dunia front-end development') + + url = '/api/students/' + str(student_id) + "/profile/" + response = self.client.patch(url, {'expected_salary': '4000000'}, format='multipart') + self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) + self.assertEqual(response.data.get('expected_salary'), '4000000') -- GitLab From cc83a65505efcf14560068dfef62583250a039b1 Mon Sep 17 00:00:00 2001 From: Aviliani Pramestya <avipramestya14@gmail.com> Date: Sun, 6 Oct 2019 20:01:59 +0700 Subject: [PATCH 2/4] menambahkan expected salary pada models --- .../0020_student_expected_salary.py | 20 +++++++++++++++++++ core/migrations/0021_auto_20191006_1925.py | 20 +++++++++++++++++++ core/models/accounts.py | 1 + 3 files changed, 41 insertions(+) create mode 100644 core/migrations/0020_student_expected_salary.py create mode 100644 core/migrations/0021_auto_20191006_1925.py diff --git a/core/migrations/0020_student_expected_salary.py b/core/migrations/0020_student_expected_salary.py new file mode 100644 index 00000000..d35a357d --- /dev/null +++ b/core/migrations/0020_student_expected_salary.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.17 on 2019-10-06 12:20 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0019_merge_20191006_0852'), + ] + + operations = [ + migrations.AddField( + model_name='student', + name='expected_salary', + field=models.IntegerField(blank=True, null=True), + ), + ] diff --git a/core/migrations/0021_auto_20191006_1925.py b/core/migrations/0021_auto_20191006_1925.py new file mode 100644 index 00000000..4b1cd355 --- /dev/null +++ b/core/migrations/0021_auto_20191006_1925.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.17 on 2019-10-06 12:25 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0020_student_expected_salary'), + ] + + operations = [ + migrations.AlterField( + model_name='student', + name='expected_salary', + field=models.CharField(blank=True, max_length=10, null=True), + ), + ] diff --git a/core/models/accounts.py b/core/models/accounts.py index 2ada2804..f1664179 100644 --- a/core/models/accounts.py +++ b/core/models/accounts.py @@ -69,6 +69,7 @@ class Student(models.Model): region = models.CharField(max_length=30, blank=True, null=True) intro = models.CharField(max_length=50, blank=True, null=True) + expected_salary = models.CharField(max_length=10, blank=True, null=True) @property def name(self): -- GitLab From c5a1fb388c8e41fa3cffcc9a7040b61fa88c1ba3 Mon Sep 17 00:00:00 2001 From: Aviliani Pramestya <avipramestya14@gmail.com> Date: Sun, 6 Oct 2019 20:25:47 +0700 Subject: [PATCH 3/4] expected salary front end and serializers --- assets/js/ProfilePage.jsx | 16 ++++++++++++++++ core/serializers/accounts.py | 6 ++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/assets/js/ProfilePage.jsx b/assets/js/ProfilePage.jsx index a2d40e78..c5435332 100644 --- a/assets/js/ProfilePage.jsx +++ b/assets/js/ProfilePage.jsx @@ -31,6 +31,7 @@ export default class ProfilePage extends React.Component { show_transcript: '', photo: '', intro: '', + expected_salary: '', form: { picture: '', email: '', @@ -78,6 +79,7 @@ export default class ProfilePage extends React.Component { bagikanTranskrip: data.show_transcript, refresh: this.state.refresh + 1, intro: data.intro, + expected_salary: data.expected_salary, linkedin_url: data.linkedin_url, }); if (this.props.route.own) { @@ -175,6 +177,10 @@ export default class ProfilePage extends React.Component { <label htmlFor="resume">Resume</label> <input onChange={this.handleFile} placeholder="Resume" name="resume" type="File" /> </Form.Field> + <Form.Field> + <label htmlFor="phone_number">Expected Salary</label> + <input onChange={this.handleChange} placeholder="2000000" name="expected_salary" /> + </Form.Field> <Form.Field> <label htmlFor="intro">Intro</label> <input onChange={this.handleChange} placeholder="Ceritakan dirimu secara singkat" name="intro" /> @@ -284,6 +290,16 @@ export default class ProfilePage extends React.Component { </Grid> </Segment> + <Segment basic vertical> + <Grid> + <Grid.Column width={2}> + <Icon name="money bill alternate" size="big" /> + </Grid.Column> + <Grid.Column width={13}> + <p> { this.state.expected_salary || 'N/A' } </p> + </Grid.Column> + </Grid> + </Segment> <Segment basic vertical> <Grid> diff --git a/core/serializers/accounts.py b/core/serializers/accounts.py index bc52f316..3f0b5e4e 100644 --- a/core/serializers/accounts.py +++ b/core/serializers/accounts.py @@ -19,7 +19,7 @@ class StudentSerializer(serializers.ModelSerializer): class Meta: model = Student fields = ['id', 'name', 'user', 'npm', 'resume', 'phone_number', 'birth_place', 'birth_date', 'major', 'batch', \ - 'show_transcript', 'photo', 'accepted_no', 'linkedin_url', 'region', 'intro'] + 'show_transcript', 'photo', 'accepted_no', 'linkedin_url', 'region', 'intro', 'expected_salary'] def get_accepted_no(self, obj): apps = Application.objects.filter(student=obj, status=4) @@ -45,6 +45,7 @@ class StudentUpdateSerializer(serializers.ModelSerializer): 'photo': photo, 'show_transcript': instance.show_transcript, 'intro': instance.intro, + 'expected_salary': instance.expected_salary, 'linkedin_url' : instance.linkedin_url, } @@ -56,6 +57,7 @@ class StudentUpdateSerializer(serializers.ModelSerializer): instance.photo = validated_data.get('photo', instance.photo) instance.user.email = validated_data.get('email', instance.user.email) instance.intro = validated_data.get('intro', instance.intro) + instance.expected_salary = validated_data.get('expected_salary', instance.expected_salary) instance.linkedin_url = validated_data.get('linkedin_url', instance.linkedin_url) instance.save() instance.user.save() @@ -63,7 +65,7 @@ class StudentUpdateSerializer(serializers.ModelSerializer): class Meta: model = Student - fields = ['resume', 'email', 'phone_number', 'photo', 'show_transcript', 'linkedin_url', 'region', 'intro'] + fields = ['resume', 'email', 'phone_number', 'photo', 'show_transcript', 'linkedin_url', 'region', 'intro', 'expected_salary'] class CompanyUpdateSerializer(serializers.ModelSerializer): -- GitLab From 60c41c1459493ce053f749e7db4485c90893d999 Mon Sep 17 00:00:00 2001 From: Aviliani Pramestya <avipramestya14@gmail.com> Date: Sun, 6 Oct 2019 22:03:09 +0700 Subject: [PATCH 4/4] merge migrations --- core/migrations/0022_merge_20191006_2154.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 core/migrations/0022_merge_20191006_2154.py diff --git a/core/migrations/0022_merge_20191006_2154.py b/core/migrations/0022_merge_20191006_2154.py new file mode 100644 index 00000000..1b285ce8 --- /dev/null +++ b/core/migrations/0022_merge_20191006_2154.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.17 on 2019-10-06 14:54 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0017_vacancy_amount'), + ('core', '0021_auto_20191006_1925'), + ('core', '0014_auto_20191004_1340'), + ] + + operations = [ + ] -- GitLab