From 94f1ae4e046c0c538bad7c6682ab49b1f02fe6c0 Mon Sep 17 00:00:00 2001 From: syahbima <syahbimaa@gmail.com> Date: Sat, 5 Oct 2019 17:09:50 +0700 Subject: [PATCH 1/9] create test if entered valid linked url data, should return 200 and model updated --- 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 25281a7c..1d7a1580 100644 --- a/core/tests/test_accounts.py +++ b/core/tests/test_accounts.py @@ -136,6 +136,11 @@ class ProfileUpdateTests(APITestCase): self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) self.assertEqual(response.data.get('phone_number'), '08123123123') + url = '/api/students/' + str(student_id) + "/profile/" + response = self.client.patch(url, {'linkedin_url': 'https://www.linkedin.com/in/jojo/'}, format='multipart') + self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) + self.assertEqual(response.data.get('linkedin_url'), 'https://www.linkedin.com/in/jojo/') + url = '/api/students/' + str(student_id) + "/profile/" response = self.client.patch(url, {'email': 'saasdasd'}, format='multipart') self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) -- GitLab From 73b9017fd6aabdb770bea592066c48cb23aa92f9 Mon Sep 17 00:00:00 2001 From: syahbima <syahbimaa@gmail.com> Date: Sat, 5 Oct 2019 17:15:38 +0700 Subject: [PATCH 2/9] create test if entered invalid linked url data, should return 400 --- core/tests/test_accounts.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/tests/test_accounts.py b/core/tests/test_accounts.py index 1d7a1580..5c2c165b 100644 --- a/core/tests/test_accounts.py +++ b/core/tests/test_accounts.py @@ -149,6 +149,10 @@ class ProfileUpdateTests(APITestCase): response = self.client.patch(url, {'phone_number': '08123123123'}, format='multipart') self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) + url = '/api/students/' + str(student_id) + "/profile/" + response = self.client.patch(url, {'linkedin_url': 'this is not valid url'}, format='multipart') + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + new_user = User.objects.create_user('dummy.student2', 'dummy.student@student.com', 'lalala123') new_student = Student.objects.create(user=new_user, npm="1212121212") -- GitLab From 20fc1d177a05e19b5bac846ade6b8f053c46e9a9 Mon Sep 17 00:00:00 2001 From: syahbima <syahbimaa@gmail.com> Date: Sat, 5 Oct 2019 17:16:16 +0700 Subject: [PATCH 3/9] update model and create new field for url linked in --- core/models/accounts.py | 1 + 1 file changed, 1 insertion(+) diff --git a/core/models/accounts.py b/core/models/accounts.py index 7361aa32..be8d27d9 100644 --- a/core/models/accounts.py +++ b/core/models/accounts.py @@ -65,6 +65,7 @@ class Student(models.Model): batch = models.CharField(max_length=4, blank=True, null=True) show_transcript = models.BooleanField(default=False) photo = models.FileField(upload_to=get_student_photo_file_path, null=True, blank=True, validators=[validate_image_file_extension]) + linkedin_url = models.URLField(max_length=200,blank=True, null=True) @property def name(self): -- GitLab From f206da0da996f5b09273ef10a659648eba72f788 Mon Sep 17 00:00:00 2001 From: syahbima <syahbimaa@gmail.com> Date: Sat, 5 Oct 2019 17:21:07 +0700 Subject: [PATCH 4/9] edit serializer to handle update linked in url on profile --- core/serializers/accounts.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/serializers/accounts.py b/core/serializers/accounts.py index e57747ce..53d21e30 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'] + 'show_transcript', 'photo', 'accepted_no', 'linkedin_url'] def get_accepted_no(self, obj): apps = Application.objects.filter(student=obj, status=4) @@ -42,7 +42,8 @@ class StudentUpdateSerializer(serializers.ModelSerializer): 'email': instance.user.email, 'phone_number': instance.phone_number, 'photo': photo, - 'show_transcript': instance.show_transcript + 'show_transcript': instance.show_transcript, + 'linkedin_url' : instance.linkedin_url, } def update(self, instance, validated_data): @@ -51,13 +52,14 @@ class StudentUpdateSerializer(serializers.ModelSerializer): instance.phone_number = validated_data.get('phone_number', instance.phone_number) instance.photo = validated_data.get('photo', instance.photo) instance.user.email = validated_data.get('email', instance.user.email) + instance.linkedin_url = validated_data.get('linkedin_url', instance.linkedin_url) instance.save() instance.user.save() return instance class Meta: model = Student - fields = ['resume', 'email', 'phone_number', 'photo', 'show_transcript'] + fields = ['resume', 'email', 'phone_number', 'photo', 'show_transcript', 'linkedin_url'] class CompanyUpdateSerializer(serializers.ModelSerializer): -- GitLab From 789190b03ae9ee4c7dc8570429ac7bc1041fb507 Mon Sep 17 00:00:00 2001 From: syahbima <syahbimaa@gmail.com> Date: Sat, 5 Oct 2019 17:23:03 +0700 Subject: [PATCH 5/9] create form field of linked in url and show it on the profile section --- assets/js/ProfilePage.jsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/assets/js/ProfilePage.jsx b/assets/js/ProfilePage.jsx index a9c0fc9f..75539d8d 100644 --- a/assets/js/ProfilePage.jsx +++ b/assets/js/ProfilePage.jsx @@ -40,6 +40,7 @@ export default class ProfilePage extends React.Component { acceptedNo: 0, refresh: 1, loading: false, + linkedin_url: '', }; this.getProfile = this.getProfile.bind(this); this.handleChange = this.handleChange.bind(this); @@ -71,6 +72,7 @@ export default class ProfilePage extends React.Component { acceptedNo: data.accepted_no, bagikanTranskrip: data.show_transcript, refresh: this.state.refresh + 1, + linkedin_url: data.linkedin_url, }); if (this.props.route.own) { const newSession = this.props.user.data; @@ -154,6 +156,10 @@ export default class ProfilePage extends React.Component { <label htmlFor="phone_number">No. Hp</label> <input onChange={this.handleChange} placeholder="08123456789" name="phone_number" /> </Form.Field> + <Form.Field> + <label htmlFor="linkedin_url">URL Profile LinkedIn</label> + <input onChange={this.handleChange} placeholder="https://www.linkedin.com/in/jojo/" name="linkedin_url" /> + </Form.Field> <Form.Field> <label htmlFor="resume">Resume</label> <input onChange={this.handleFile} placeholder="Resume" name="resume" type="File" /> @@ -239,6 +245,17 @@ export default class ProfilePage extends React.Component { </Grid.Column> </Grid> </Segment> + + <Segment basic vertical> + <Grid> + <Grid.Column width={2}> + <Icon name="linkedin" size="big" /> + </Grid.Column> + <Grid.Column width={13}> + <a href={this.state.linkedin_url}> { this.state.linkedin_url || 'N/A' } </a> + </Grid.Column> + </Grid> + </Segment> </div> <Container textAlign="center"> -- GitLab From b6d8a27bdd9263938ccfcd96cfb5025580430674 Mon Sep 17 00:00:00 2001 From: syahbima <syahbimaa@gmail.com> Date: Sat, 5 Oct 2019 17:23:22 +0700 Subject: [PATCH 6/9] migrate database --- core/migrations/0014_student_linkedin_url.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 core/migrations/0014_student_linkedin_url.py diff --git a/core/migrations/0014_student_linkedin_url.py b/core/migrations/0014_student_linkedin_url.py new file mode 100644 index 00000000..b4bbeae2 --- /dev/null +++ b/core/migrations/0014_student_linkedin_url.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2019-10-05 08:48 +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='student', + name='linkedin_url', + field=models.URLField(blank=True, null=True), + ), + ] -- GitLab From 271b7a8c8f907cad971ad9399d05403f273916d6 Mon Sep 17 00:00:00 2001 From: syahbima <syahbimaa@gmail.com> Date: Sat, 5 Oct 2019 18:52:05 +0700 Subject: [PATCH 7/9] modified access due wrong index since i added new input in ProfilePage.jsx --- assets/js/__test__/ProfilePage-test.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/__test__/ProfilePage-test.jsx b/assets/js/__test__/ProfilePage-test.jsx index a98b3452..4a4e39e9 100644 --- a/assets/js/__test__/ProfilePage-test.jsx +++ b/assets/js/__test__/ProfilePage-test.jsx @@ -139,7 +139,7 @@ describe('ProfilePage', () => { const profile = ReactTestUtils.renderIntoDocument( <ProfilePage route={{ own: true, data: studentSession }} user={{ data: studentSession }} params={{ id: 3 }} />); - const checkboxNode = ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Input')[4]; + const checkboxNode = ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Input')[5]; const checkbox = false; checkboxNode.value = checkbox; profile.getProfile().then(()=> expect(profile.state.show_transcript).to.equal(true)); -- GitLab From 6d79fe718e716de704bc53435cf5dacafe3ff87a Mon Sep 17 00:00:00 2001 From: syahbima <syahbimaa@gmail.com> Date: Sat, 5 Oct 2019 23:20:35 +0700 Subject: [PATCH 8/9] fix merge conflict --- assets/js/ProfilePage.jsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/assets/js/ProfilePage.jsx b/assets/js/ProfilePage.jsx index fce296fd..11a3fc86 100644 --- a/assets/js/ProfilePage.jsx +++ b/assets/js/ProfilePage.jsx @@ -255,26 +255,27 @@ export default class ProfilePage extends React.Component { </Segment> <Segment basic vertical> -<<<<<<< HEAD <Grid> <Grid.Column width={2}> <Icon name="linkedin" size="big" /> </Grid.Column> <Grid.Column width={13}> <a href={this.state.linkedin_url}> { this.state.linkedin_url || 'N/A' } </a> -======= + </Grid.Column> + </Grid> + </Segment> + </div> + <Segment basic vertical> <Grid> <Grid.Column width={2}> <Icon name="map pin" size="big" /> </Grid.Column> <Grid.Column width={13}> <p> { this.state.region || 'N/A' } </p> ->>>>>>> e68e63c497b6ecc1b089050bb33d696007ac88b0 </Grid.Column> </Grid> </Segment> - </div> <Container textAlign="center"> <div className="buttonProfile"> -- GitLab From 6a0101a9c45f43d560c53066426b3ae6683c7ee6 Mon Sep 17 00:00:00 2001 From: syahbima <syahbimaa@gmail.com> Date: Sun, 6 Oct 2019 06:12:41 +0700 Subject: [PATCH 9/9] pull from master and fix merge conflict --- core/migrations/0018_merge_20191006_0603.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 core/migrations/0018_merge_20191006_0603.py diff --git a/core/migrations/0018_merge_20191006_0603.py b/core/migrations/0018_merge_20191006_0603.py new file mode 100644 index 00000000..f3a0c377 --- /dev/null +++ b/core/migrations/0018_merge_20191006_0603.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2019-10-05 23:03 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0016_merge_20191005_2256'), + ('core', '0017_merge_20191006_0134'), + ] + + operations = [ + ] -- GitLab