Fakultas Ilmu Komputer UI

Commit 71595031 authored by Aldo Bima Syahputra's avatar Aldo Bima Syahputra
Browse files

1606833463 31 (Menambah Atribut alamat LinkedIn pada profile mahasiswa)

parent 40183184
......@@ -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">
......
......@@ -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));
......
# -*- 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),
),
]
# -*- 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 = [
]
# -*- 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 = [
]
......@@ -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
......
......@@ -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):
......
......@@ -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")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment