Fakultas Ilmu Komputer UI

Commit 6a05ed1e authored by Dwi Nanda Susanto's avatar Dwi Nanda Susanto
Browse files

1506722720 219

parent c567f5ad
......@@ -78,6 +78,7 @@ export default class EditProfile extends ProfileHandler {
interests: '',
dependants: '',
related_course: '',
ielts: 1.0,
};
this.getProfile = this.getProfile.bind(this);
this.handleChange = this.handleChange.bind(this);
......@@ -120,6 +121,7 @@ export default class EditProfile extends ProfileHandler {
seminar: data.seminar,
interests: data.interests,
related_course: data.related_course,
ielts: data.ielts,
});
if (this.props.route.own) {
const newSession = this.props.user.data;
......@@ -611,6 +613,23 @@ export default class EditProfile extends ProfileHandler {
type="File"
/>
</Form.Field>
<Form.Field>
<label htmlFor="ielts">IELTS</label>
<input
onChange={this.handleChange}
placeholder={
this.state.ielts === null
? '400'
: this.state.ielts
}
defaultValue={
this.state.ielts === null
? null
: this.state.ielts
}
name="ielts"
/>
</Form.Field>
</Form>
</Segment>
......
......@@ -102,6 +102,7 @@ export default class ProfilePage extends ProfileHandler {
interests: '',
dependants: '',
related_course: '',
ielts: 1.0,
};
this.getProfile = this.getProfile.bind(this);
this.handleChange = this.handleChange.bind(this);
......@@ -172,6 +173,7 @@ export default class ProfilePage extends ProfileHandler {
interests: data.interests,
dependants: data.dependants,
related_course: data.related_course,
ielts: data.ielts,
});
if (this.props.route.own) {
const newSession = this.props.user.data;
......@@ -825,6 +827,20 @@ export default class ProfilePage extends ProfileHandler {
</Grid.Column>
</Grid>
</Segment>
<Segment basic vertical>
<Grid>
<Grid.Column width={2}>
<Icon name="pencil alternate" size="big" />
</Grid.Column>
<Grid.Column width={13}>
<p href={this.state.ielts}>
{' '}
{this.state.ielts || 'N/A'}
{' '}
</p>
</Grid.Column>
</Grid>
</Segment>
</Grid.Column>
</Grid>
</Segment>
......
# Generated by Django 2.2.8 on 2019-12-05 15:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='student',
name='ielts',
field=models.FloatField(blank=True, db_column='ielts', default=1.0, null=True),
),
]
......@@ -128,7 +128,8 @@ class Student(models.Model):
interests = models.CharField(max_length=100, blank=True, null=True)
dependants = models.IntegerField(db_column='dependants', default=0, blank=True, null=True)
related_course = models.CharField(max_length=200, blank=True, null=True)
ielts = models.FloatField(db_column='ielts', default=1.0, blank=True, null=True)
@property
def name(self):
return get_display_name(self.user)
......
......@@ -26,7 +26,7 @@ class StudentSerializer(serializers.ModelSerializer):
'work_experience', 'latest_work', 'latest_work_desc', 'read_no', 'volunteer', 'job_seeking_status',
'skills', 'expected_salary',
'self_description', 'github_url', 'gitlab_url', 'awards', 'certification', 'languages', 'seminar',
'interests', 'alamat', 'projects', 'dependants', 'student_toefl', 'student_toefl_file', 'related_course']
'interests', 'alamat', 'projects', 'dependants', 'student_toefl', 'student_toefl_file', 'related_course', 'ielts']
@staticmethod
def get_accepted_no(obj):
......@@ -89,6 +89,7 @@ class StudentUpdateSerializer(serializers.ModelSerializer):
'interests': instance.interests,
'dependants': instance.dependants,
'related_course':instance.related_course,
'ielts':instance.ielts,
}
def update(self, instance, validated_data):
......@@ -154,6 +155,7 @@ class StudentUpdateSerializer(serializers.ModelSerializer):
instance.dependants = validated_data.get('dependants', instance.dependants)
instance.related_course = validated_data.get(
'related_course', instance.related_course)
instance.ielts = validated_data.get('ielts', instance.ielts)
instance.save()
instance.user.save()
return instance
......@@ -165,7 +167,7 @@ class StudentUpdateSerializer(serializers.ModelSerializer):
'work_experience', 'latest_work', 'latest_work_desc', 'volunteer', 'job_seeking_status', 'skills',
'expected_salary',
'self_description', 'github_url', 'gitlab_url', 'awards', 'certification', 'languages', 'seminar',
'interests', 'alamat', 'projects', 'dependants', 'student_toefl', 'student_toefl_file', 'related_course']
'interests', 'alamat', 'projects', 'dependants', 'student_toefl', 'student_toefl_file', 'related_course', 'ielts']
class CompanyUpdateSerializer(serializers.ModelSerializer):
......
......@@ -451,6 +451,16 @@ class ProfileUpdateTests(APITestCase):
response = self.client.patch(url, {'dependants': 'this is not valid dependants input'}, format='multipart')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
url = '/api/students/' + str(student_id) + "/profile/"
response = self.client.patch(url, {'ielts': 6.0}, format='multipart')
self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
self.assertEqual(response.data.get('ielts'), 6.0)
url = '/api/students/' + str(student_id) + "/profile/"
response = self.client.patch(url, {'ielts': 'invalid input'}, format='multipart')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def _create_test_file(self, path):
f = open(path, 'rb')
return {'pdf_file': f}
......
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