diff --git a/assets/js/ProfilePage.jsx b/assets/js/ProfilePage.jsx index 11a3fc86ab9b7a2a808b10f5c972fe38ae36068a..a2d40e789cce345172dcb0905fc06e58451bbd3f 100644 --- a/assets/js/ProfilePage.jsx +++ b/assets/js/ProfilePage.jsx @@ -30,6 +30,7 @@ export default class ProfilePage extends React.Component { phone_number: '', show_transcript: '', photo: '', + intro: '', form: { picture: '', email: '', @@ -37,6 +38,7 @@ export default class ProfilePage extends React.Component { region: '', resume: '', show_transcript: '', + intro: '', }, bagikanTranskrip: '', acceptedNo: 0, @@ -75,6 +77,7 @@ export default class ProfilePage extends React.Component { acceptedNo: data.accepted_no, bagikanTranskrip: data.show_transcript, refresh: this.state.refresh + 1, + intro: data.intro, linkedin_url: data.linkedin_url, }); if (this.props.route.own) { @@ -172,6 +175,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="intro">Intro</label> + <input onChange={this.handleChange} placeholder="Ceritakan dirimu secara singkat" name="intro" /> + </Form.Field> <Form.Field> <Checkbox onChange={this.handleCheckbox} @@ -277,6 +284,20 @@ export default class ProfilePage extends React.Component { </Grid> </Segment> + + <Segment basic vertical> + <Grid> + <Grid.Column width={2}> + <h3>Intro</h3> + </Grid.Column> + <Grid.Column width={13}> + <p> { this.state.intro || 'N/A' } </p> + </Grid.Column> + </Grid> + </Segment> + + + <Container textAlign="center"> <div className="buttonProfile"> <Button onClick={this.gotoStudentResume} disabled={!this.state.resume} primary size="small">Resume</Button> diff --git a/core/migrations/0018_student_intro.py b/core/migrations/0018_student_intro.py new file mode 100644 index 0000000000000000000000000000000000000000..fa1b78c446becf1d1ebe426a78ef92a7dd6586c1 --- /dev/null +++ b/core/migrations/0018_student_intro.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.17 on 2019-10-05 22:59 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0017_merge_20191006_0134'), + ] + + operations = [ + migrations.AddField( + model_name='student', + name='intro', + field=models.CharField(blank=True, max_length=50, null=True), + ), + ] diff --git a/core/migrations/0019_merge_20191006_0852.py b/core/migrations/0019_merge_20191006_0852.py new file mode 100644 index 0000000000000000000000000000000000000000..38ac5faf42fbdb7d560c24bbe4aa466a08fdc786 --- /dev/null +++ b/core/migrations/0019_merge_20191006_0852.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.17 on 2019-10-06 01:52 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0018_student_intro'), + ('core', '0018_merge_20191006_0603'), + ] + + operations = [ + ] diff --git a/core/models/accounts.py b/core/models/accounts.py index cf677710fabaf361b92d5809c2bff67ba88361e9..2ada280445adfac8a17cb142fcaf8e1fa9fcef3b 100644 --- a/core/models/accounts.py +++ b/core/models/accounts.py @@ -67,6 +67,8 @@ class Student(models.Model): 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) + + intro = models.CharField(max_length=50, blank=True, null=True) @property def name(self): diff --git a/core/serializers/accounts.py b/core/serializers/accounts.py index 3dc36c251e36cb5df553b70070ce4b3531ffd92d..bc52f3161aaf0463a7bfd85b3993b4e421c3f20a 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'] + 'show_transcript', 'photo', 'accepted_no', 'linkedin_url', 'region', 'intro'] def get_accepted_no(self, obj): apps = Application.objects.filter(student=obj, status=4) @@ -44,6 +44,7 @@ class StudentUpdateSerializer(serializers.ModelSerializer): 'region': instance.region, 'photo': photo, 'show_transcript': instance.show_transcript, + 'intro': instance.intro, 'linkedin_url' : instance.linkedin_url, } @@ -54,6 +55,7 @@ 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.intro = validated_data.get('intro', instance.intro) instance.linkedin_url = validated_data.get('linkedin_url', instance.linkedin_url) instance.save() instance.user.save() @@ -61,7 +63,7 @@ class StudentUpdateSerializer(serializers.ModelSerializer): class Meta: model = Student - fields = ['resume', 'email', 'phone_number', 'photo', 'show_transcript', 'linkedin_url', 'region'] + fields = ['resume', 'email', 'phone_number', 'photo', 'show_transcript', 'linkedin_url', 'region', 'intro'] class CompanyUpdateSerializer(serializers.ModelSerializer): diff --git a/core/tests/test_accounts.py b/core/tests/test_accounts.py index 22c9dc7f336127c51ae5f8ab6023c602e465c994..d606b626bb15e85c16ca9afbc34447a767bd283f 100644 --- a/core/tests/test_accounts.py +++ b/core/tests/test_accounts.py @@ -163,3 +163,8 @@ class ProfileUpdateTests(APITestCase): url = '/api/students/' + str(new_student.pk) + "/profile/" response = self.client.patch(url, {'phone_number': '08123123123'}, format='multipart') self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) + + url = '/api/students/' + str(student_id) + '/profile/' + 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')