diff --git a/assets/js/ProfilePage.jsx b/assets/js/ProfilePage.jsx index 915307f7a95076d765f24f47fb606721f5082ecc..aaa38b31d81c0d639168abd390f1b03d11292e4d 100644 --- a/assets/js/ProfilePage.jsx +++ b/assets/js/ProfilePage.jsx @@ -54,6 +54,7 @@ export default class ProfilePage extends React.Component { latest_work: '', latest_work_desc: '', github_url: '', + awards: '', }, bagikanTranskrip: '', acceptedNo: 0, @@ -68,6 +69,7 @@ export default class ProfilePage extends React.Component { latest_work: '', latest_work_desc: '', github_url: '', + awards: '', }; this.getProfile = this.getProfile.bind(this); this.handleChange = this.handleChange.bind(this); @@ -117,6 +119,7 @@ export default class ProfilePage extends React.Component { latest_work_desc: data.latest_work_desc, skills: data.skills, github_url: data.github_url, + awards: data.awards, }); if (this.props.route.own) { const newSession = this.props.user.data; @@ -344,6 +347,15 @@ export default class ProfilePage extends React.Component { name="latest_work_desc" /> </Form.Field> + <Form.Field> + <label htmlFor="awards">Awards and Achievements</label> + <input + onChange={this.handleChange} + placeholder={this.state.awards === null ? 'Juara 2 UIUX Gemastik 2019' : this.state.awards} + defaultValue={this.state.awards === null ? null : this.state.awards} + name="awards" + /> + </Form.Field> <Form.Field> <label htmlFor="resume">Resume</label> <input onChange={this.handleFile} placeholder="Resume" name="resume" type="File" /> @@ -618,6 +630,17 @@ export default class ProfilePage extends React.Component { </Grid> </Segment> + <Segment basic vertical> + <Grid> + <Grid.Column width={2}> + <Icon name="trophy" size="big" /> + </Grid.Column> + <Grid.Column width={13}> + <p> {this.state.awards || 'Awards belum ditambahkan'} </p> + </Grid.Column> + </Grid> + </Segment> + <Segment basic vertical> <Grid> <Grid.Column width={2}> diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py index 15111ee48a7bf85401f0d09cf7bad2854c44de73..b694188823f8f1eeb5f8473ffdef1963a5a3bb19 100644 --- a/core/migrations/0001_initial.py +++ b/core/migrations/0001_initial.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.11.17 on 2019-10-12 17:16 +# Generated by Django 1.11.17 on 2019-11-12 06:21 from __future__ import unicode_literals import core.lib.validators @@ -103,7 +103,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created', models.DateTimeField(auto_now_add=True)), ('updated', models.DateTimeField(auto_now=True)), - ('nip', models.IntegerField(unique=True, validators=[django.core.validators.MinValueValidator(100000000), django.core.validators.MaxValueValidator(9999999999)])), + ('nip', models.IntegerField(unique=True, validators=[django.core.validators.MinValueValidator(100000000), django.core.validators.MaxValueValidator(9999999999L)])), ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], options={ diff --git a/core/migrations/0002_student_awards.py b/core/migrations/0002_student_awards.py new file mode 100644 index 0000000000000000000000000000000000000000..cd3fcd71186fb9fb3982e4ca6e17961a314732a6 --- /dev/null +++ b/core/migrations/0002_student_awards.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.17 on 2019-11-12 15:00 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='student', + name='awards', + field=models.CharField(blank=True, max_length=100, null=True), + ), + ] diff --git a/core/models/accounts.py b/core/models/accounts.py index 2aeee60e60f64703f9a0662407aea2414bf81555..0fee4f2feab49dd2389772034d30c56ce5ddaaa2 100644 --- a/core/models/accounts.py +++ b/core/models/accounts.py @@ -100,6 +100,7 @@ class Student(models.Model): job_seeking_status = models.CharField(max_length=30, blank=True, null=True) student_gpa = models.FloatField(db_column='student_gpa', default=1.0, blank=True, null=True) volunteer = models.CharField(max_length=100, blank=True, null=True) + awards = models.CharField(max_length=100, blank=True, null=True) @property def name(self): diff --git a/core/serializers/accounts.py b/core/serializers/accounts.py index 1ce6e3e2c77aab575c4e0dcd5a0d8443681ede6e..c3ed7fd182f6bd74897afd76306541e6411ff04a 100644 --- a/core/serializers/accounts.py +++ b/core/serializers/accounts.py @@ -22,7 +22,7 @@ class StudentSerializer(serializers.ModelSerializer): fields = ['id', 'name', 'user', 'npm', 'resume', 'phone_number', 'gender', 'birth_place', 'birth_date', 'major', 'batch', 'show_transcript', 'photo', 'accepted_no', 'linkedin_url', 'hackerrank_url', 'region', 'intro', 'portfolio_link', 'website_url', 'student_gpa', 'age', 'recommendations', 'work_experience', 'latest_work', 'latest_work_desc', 'read_no', 'volunteer', 'job_seeking_status', 'skills', 'expected_salary', - 'self_description', 'github_url'] + 'self_description', 'github_url', 'awards'] def get_accepted_no(self, obj): apps = Application.objects.filter(student=obj, status=4) @@ -68,7 +68,8 @@ class StudentUpdateSerializer(serializers.ModelSerializer): 'latest_work': instance.latest_work, 'latest_work_desc': instance.latest_work_desc, 'skills': instance.skills, - 'github_url': instance.github_url + 'github_url': instance.github_url, + 'awards' : instance.awards } def update(self, instance, validated_data): @@ -111,6 +112,8 @@ class StudentUpdateSerializer(serializers.ModelSerializer): 'latest_work_desc', instance.latest_work_desc) instance.github_url = validated_data.get( 'github_url', instance.github_url) + instance.awards = validated_data.get( + 'awards', instance.awards) instance.save() instance.user.save() return instance @@ -119,7 +122,7 @@ class StudentUpdateSerializer(serializers.ModelSerializer): model = Student fields = ['resume', 'email', 'phone_number', 'gender', 'photo', 'show_transcript', 'linkedin_url', 'hackerrank_url', 'region', 'intro', 'portfolio_link', 'website_url', 'student_gpa', 'recommendations', 'work_experience', 'latest_work', 'latest_work_desc', 'volunteer', 'job_seeking_status', 'skills', 'expected_salary', - 'self_description', 'github_url'] + 'self_description', 'github_url', 'awards'] class CompanyUpdateSerializer(serializers.ModelSerializer): diff --git a/core/tests/test_accounts.py b/core/tests/test_accounts.py index 2e893235886cde7ab4959cf194eed79c2d2bd00e..a674f6c7294a9a388ff4feeba12037adfe7de281 100644 --- a/core/tests/test_accounts.py +++ b/core/tests/test_accounts.py @@ -245,6 +245,11 @@ class ProfileUpdateTests(APITestCase): 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, {'awards': 'Juara 2 UIUX Gemastik 2019'}, format='multipart') + self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) + self.assertEqual(response.data.get('awards'), 'Juara 2 UIUX Gemastik 2019') + @requests_mock.Mocker() def test_student_profile_update_filetype_validation(self, m): m.get('https://akun.cs.ui.ac.id/oauth/token/verify/?client_id=X3zNkFmepkdA47ASNMDZRX3Z9gqSU1Lwywu5WepG', json={"username": 'dummy.mahasiswa', "role": 'mahasiswa', "identity_number": '1234567890'}, status_code=200)