Fakultas Ilmu Komputer UI

Commit 2966d120 authored by emil farisan's avatar emil farisan
Browse files

add hackerrank field, update models and added the test

parent e8b42ca5
Pipeline #23043 passed with stages
in 6 minutes and 9 seconds
......@@ -61,6 +61,7 @@ export default class ProfilePage extends React.Component {
refresh: 1,
loading: false,
linkedin_url: '',
hackerrank_url: '',
self_description: '',
student_gpa: 0.0,
website_url: '',
......@@ -108,6 +109,7 @@ export default class ProfilePage extends React.Component {
job_seeking_status: data.job_seeking_status,
volunteer: data.volunteer,
linkedin_url: data.linkedin_url,
hackerrank_url: data.hackerrank_url,
self_description: data.self_description,
student_gpa: data.student_gpa,
website_url: data.website_url,
......@@ -279,6 +281,15 @@ export default class ProfilePage extends React.Component {
name="linkedin_url"
/>
</Form.Field>
<Form.Field>
<label htmlFor="hackerrank_url">URL Profile Hackerrank</label>
<input
onChange={this.handleChange}
placeholder={this.state.hackerrank_url === null ? 'https://www.hackerrank.com/james' : this.state.hackerrank_url}
defaultValue={this.state.hackerrank_url === null ? null : this.state.hackerrank_url}
name="hackerrank_url"
/>
</Form.Field>
<Form.Field>
<label htmlFor="portfolio_link">Portfolio Link</label>
<input
......@@ -504,6 +515,17 @@ export default class ProfilePage extends React.Component {
</Grid>
</Segment>
<Segment basic vertical>
<Grid>
<Grid.Column width={2}>
<Icon name="hackerrank" size="big" />
</Grid.Column>
<Grid.Column width={13}>
<a href={this.state.hackerrank_url}> {this.state.hackerrank_url || 'N/A'} </a>
</Grid.Column>
</Grid>
</Segment>
<Segment basic vertical>
<Grid>
<Grid.Column width={2}>
......
......@@ -79,6 +79,7 @@ class Student(models.Model):
photo = models.FileField(upload_to=get_student_photo_file_path, null=True, blank=True, validators=[validate_image_file_extension])
portfolio_link = models.URLField(blank=True, null=True)
linkedin_url = models.URLField(max_length=200,blank=True, null=True)
hackerrank_url = models.URLField(max_length=200,blank=True, null=True)
website_url = models.URLField(max_length=200,blank=True, null=True)
work_experience = models.CharField(max_length=500, blank=True, null=True)
region = models.CharField(max_length=30, blank=True, null=True)
......
......@@ -20,7 +20,7 @@ class StudentSerializer(serializers.ModelSerializer):
class Meta:
model = Student
fields = ['id', 'name', 'user', 'npm', 'resume', 'phone_number', 'gender','birth_place', 'birth_date', 'major', 'batch', \
'show_transcript', 'photo', 'accepted_no', 'linkedin_url', 'region', 'intro', 'portfolio_link', 'website_url', 'student_gpa', 'age','recommendations',
'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']
......@@ -62,6 +62,7 @@ class StudentUpdateSerializer(serializers.ModelSerializer):
'student_gpa' : instance.student_gpa,
'volunteer': instance.volunteer,
'linkedin_url': instance.linkedin_url,
'hackerrank_url': instance.hackerrank_url,
'recommendations': instance.recommendations,
'work_experience': instance.work_experience,
'latest_work': instance.latest_work,
......@@ -84,6 +85,7 @@ class StudentUpdateSerializer(serializers.ModelSerializer):
instance.expected_salary = validated_data.get('expected_salary', instance.expected_salary)
instance.volunteer = validated_data.get('volunteer', instance.volunteer)
instance.linkedin_url = validated_data.get('linkedin_url', instance.linkedin_url)
instance.hackerrank_url = validated_data.get('hackerrank_url', instance.hackerrank_url)
instance.job_seeking_status = validated_data.get('job_seeking_status', instance.job_seeking_status)
instance.student_gpa = validated_data.get('student_gpa', instance.student_gpa)
instance.website_url = validated_data.get('website_url', instance.website_url)
......@@ -99,7 +101,7 @@ class StudentUpdateSerializer(serializers.ModelSerializer):
class Meta:
model = Student
fields = ['resume', 'email', 'phone_number', 'gender','photo', 'show_transcript', 'linkedin_url', 'region', 'intro', 'portfolio_link', 'website_url', 'student_gpa',
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']
......
......@@ -170,6 +170,10 @@ class ProfileUpdateTests(APITestCase):
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, {'hackerrank_url': 'https://www.hackerrank.com/james'}, format='multipart')
self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
self.assertEqual(response.data.get('hackerrank_url'), 'https://www.hackerrank.com/james')
url = '/api/students/' + str(student_id) + "/profile/"
response = self.client.patch(url, {'recommendations': 'mantap kak'}, format='multipart')
self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
......@@ -205,6 +209,10 @@ class ProfileUpdateTests(APITestCase):
response = self.client.patch(url, {'linkedin_url': 'this is not valid url'}, format='multipart')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
url = '/api/students/' + str(student_id) + "/profile/"
response = self.client.patch(url, {'hackerrank_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