Fakultas Ilmu Komputer UI

Commit e68e63c4 authored by PRIAMBUDI LINTANG BAGASKARA's avatar PRIAMBUDI LINTANG BAGASKARA 🎱
Browse files

Merge branch '1606895171-41' into 'master'

1606895171 41

See merge request pmpl/class-project/kape!12
parents 3044ed89 dd0cd45e
Pipeline #21838 passed with stages
in 42 minutes and 45 seconds
File added
......@@ -23,6 +23,7 @@ export default class ProfilePage extends React.Component {
major: '',
batch: '',
email: '',
region: '',
cityOfBirth: '',
dateOfBirth: '',
resume: '',
......@@ -33,6 +34,7 @@ export default class ProfilePage extends React.Component {
picture: '',
email: '',
phone_number: '',
region: '',
resume: '',
show_transcript: '',
},
......@@ -63,6 +65,7 @@ export default class ProfilePage extends React.Component {
major: data.major,
batch: data.batch,
email: data.user.email,
region: data.region,
cityOfBirth: data.birth_place,
dateOfBirth: data.birth_date,
phone_number: data.phone_number,
......@@ -154,6 +157,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="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" />
......@@ -239,6 +246,18 @@ export default class ProfilePage extends React.Component {
</Grid.Column>
</Grid>
</Segment>
<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>
</Grid.Column>
</Grid>
</Segment>
</div>
<Container textAlign="center">
......
......@@ -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));
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2019-10-05 10:07
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='region',
field=models.CharField(blank=True, max_length=30, null=True),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2019-10-05 12:57
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('core', '0014_feedback'),
('core', '0014_company_category'),
('core', '0014_student_region'),
]
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])
region = models.CharField(max_length=30, blank=True, null=True)
@property
def name(self):
......
......@@ -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', 'region']
def get_accepted_no(self, obj):
apps = Application.objects.filter(student=obj, status=4)
......@@ -41,6 +41,7 @@ class StudentUpdateSerializer(serializers.ModelSerializer):
'resume': resume,
'email': instance.user.email,
'phone_number': instance.phone_number,
'region': instance.region,
'photo': photo,
'show_transcript': instance.show_transcript
}
......@@ -49,6 +50,7 @@ class StudentUpdateSerializer(serializers.ModelSerializer):
instance.resume = validated_data.get('resume', instance.resume)
instance.show_transcript = validated_data.get('show_transcript', instance.show_transcript)
instance.phone_number = validated_data.get('phone_number', instance.phone_number)
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.save()
......@@ -57,7 +59,7 @@ class StudentUpdateSerializer(serializers.ModelSerializer):
class Meta:
model = Student
fields = ['resume', 'email', 'phone_number', 'photo', 'show_transcript']
fields = ['resume', 'email', 'phone_number', 'region', 'photo', 'show_transcript']
class CompanyUpdateSerializer(serializers.ModelSerializer):
......
......@@ -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, {'region': 'Indonesia'}, format='multipart')
self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
self.assertEqual(response.data.get('region'), 'Indonesia')
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)
......
This diff is collapsed.
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