diff --git a/assets/js/ProfilePage.jsx b/assets/js/ProfilePage.jsx index 3b130dd5dd1d33ed8d9271847c13b1add4673343..11a3fc86ab9b7a2a808b10f5c972fe38ae36068a 100644 --- a/assets/js/ProfilePage.jsx +++ b/assets/js/ProfilePage.jsx @@ -42,6 +42,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); @@ -74,6 +75,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; @@ -157,10 +159,15 @@ 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="region">Region</label> <input onChange={this.handleChange} placeholder="Indonesia" name="region" /> </Form.Field> + <Form.Field> <label htmlFor="resume">Resume</label> <input onChange={this.handleFile} placeholder="Resume" name="resume" type="File" /> @@ -248,7 +255,18 @@ export default class ProfilePage extends React.Component { </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> + <Segment basic vertical> <Grid> <Grid.Column width={2}> <Icon name="map pin" size="big" /> @@ -258,7 +276,6 @@ export default class ProfilePage extends React.Component { </Grid.Column> </Grid> </Segment> - </div> <Container textAlign="center"> <div className="buttonProfile"> diff --git a/assets/js/__test__/ProfilePage-test.jsx b/assets/js/__test__/ProfilePage-test.jsx index 1adcf18e4327ad672da469006eb09dec57ed8612..77b9c51e45bbb5cfe7978cf6a92714725803d614 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')[5]; + const checkboxNode = ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Input')[6]; const checkbox = false; checkboxNode.value = checkbox; profile.getProfile().then(()=> expect(profile.state.show_transcript).to.equal(true)); diff --git a/core/migrations/0014_student_linkedin_url.py b/core/migrations/0014_student_linkedin_url.py new file mode 100644 index 0000000000000000000000000000000000000000..b4bbeae203130252637196ff0635d7121ee762b1 --- /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), + ), + ] diff --git a/core/migrations/0016_merge_20191005_2256.py b/core/migrations/0016_merge_20191005_2256.py new file mode 100644 index 0000000000000000000000000000000000000000..e8b0c6ba54df1b9d4a18c05f88dd01840cde75a1 --- /dev/null +++ b/core/migrations/0016_merge_20191005_2256.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2019-10-05 15:56 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0015_merge_20191005_1957'), + ('core', '0014_student_linkedin_url'), + ] + + operations = [ + ] diff --git a/core/migrations/0018_merge_20191006_0603.py b/core/migrations/0018_merge_20191006_0603.py new file mode 100644 index 0000000000000000000000000000000000000000..f3a0c37717d5f523f8c12c8541d45803ff45386d --- /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 = [ + ] diff --git a/core/models/accounts.py b/core/models/accounts.py index a118168b5c22c28f5f35886760e0ca880c96cdb6..cf677710fabaf361b92d5809c2bff67ba88361e9 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) region = models.CharField(max_length=30, blank=True, null=True) @property diff --git a/core/serializers/accounts.py b/core/serializers/accounts.py index 5f3e8d17b04d9344df275fca84855836dd610717..3dc36c251e36cb5df553b70070ce4b3531ffd92d 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', 'region'] + 'show_transcript', 'photo', 'accepted_no', 'linkedin_url', 'region'] def get_accepted_no(self, obj): apps = Application.objects.filter(student=obj, status=4) @@ -43,7 +43,8 @@ class StudentUpdateSerializer(serializers.ModelSerializer): 'phone_number': instance.phone_number, 'region': instance.region, 'photo': photo, - 'show_transcript': instance.show_transcript + 'show_transcript': instance.show_transcript, + 'linkedin_url' : instance.linkedin_url, } def update(self, instance, validated_data): @@ -53,13 +54,14 @@ class StudentUpdateSerializer(serializers.ModelSerializer): instance.region = validated_data.get('region', instance.region) 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', 'region', 'photo', 'show_transcript'] + fields = ['resume', 'email', 'phone_number', 'photo', 'show_transcript', 'linkedin_url', 'region'] class CompanyUpdateSerializer(serializers.ModelSerializer): diff --git a/core/tests/test_accounts.py b/core/tests/test_accounts.py index d1ee00da203fec13ef76018d6cffb3a99dd31b34..22c9dc7f336127c51ae5f8ab6023c602e465c994 100644 --- a/core/tests/test_accounts.py +++ b/core/tests/test_accounts.py @@ -137,6 +137,10 @@ class ProfileUpdateTests(APITestCase): 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/') + response = self.client.patch(url, {'region': 'Indonesia'}, format='multipart') self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) self.assertEqual(response.data.get('region'), 'Indonesia') @@ -149,6 +153,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")