Fakultas Ilmu Komputer UI

Commit ea57ef2a authored by INDRA SEPTAMA's avatar INDRA SEPTAMA
Browse files

1606892296 61

parent 1a3108b4
......@@ -30,6 +30,8 @@ export default class ProfilePage extends React.Component {
phone_number: '',
show_transcript: '',
photo: '',
age: '',
intro: '',
volunteer: '',
form: {
picture: '',
......@@ -84,6 +86,8 @@ export default class ProfilePage extends React.Component {
readNo: data.read_no,
bagikanTranskrip: data.show_transcript,
refresh: this.state.refresh + 1,
age : data.age,
intro: data.intro,
volunteer: data.volunteer,
linkedin_url: data.linkedin_url,
latest_work: data.latest_work,
......@@ -341,6 +345,17 @@ export default class ProfilePage extends React.Component {
</Grid>
</Segment>
<Segment basic vertical>
<Grid>
<Grid.Column width={2}>
<h3>Age</h3>
</Grid.Column>
<Grid.Column width={13}>
<p> { this.state.age + ' years' || 'N/A' } </p>
</Grid.Column>
</Grid>
</Segment>
</div>
<Segment basic vertical>
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2019-10-06 05:59
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('core', '0017_vacancy_amount'),
('core', '0019_merge_20191006_0852'),
]
operations = [
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2019-10-06 06:14
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0020_merge_20191006_1259'),
]
operations = [
migrations.AddField(
model_name='student',
name='age',
field=models.PositiveIntegerField(default=0),
),
migrations.AlterField(
model_name='company',
name='category',
field=models.CharField(default='Belum ada kategori perusahaan', max_length=140),
),
migrations.AlterField(
model_name='feedback',
name='title',
field=models.CharField(blank=True, default='', max_length=100),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2019-10-06 06:55
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('core', '0021_auto_20191006_1314'),
]
operations = [
migrations.RemoveField(
model_name='student',
name='age',
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2019-10-06 15:20
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('core', '0014_auto_20191004_1340'),
('core', '0022_remove_student_age'),
]
operations = [
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2019-10-10 01:33
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('core', '0023_merge_20191006_2220'),
('core', '0038_merge_20191009_2309'),
]
operations = [
]
import os
import uuid
from datetime import date
from django.utils import timezone
from django.contrib.auth.models import User
from django.core.validators import MinValueValidator, MaxValueValidator, RegexValidator
from django.db import models
......@@ -25,6 +27,9 @@ def get_company_logo_file_path(instance, filename):
filename = "%s.%s" % (uuid.uuid4(), extension)
return os.path.join("company-logo/", filename)
def get_current_age(born):
today = date.today()
return today.year - born.year - ((today.month, today.day) < (born.month, born.day))
def get_student_ui_ux_portofolio_file_path(instance, filename):
extension = filename.split('.')[-1].lower()
filename = "%s.%s" % (uuid.uuid4(), extension)
......@@ -87,6 +92,10 @@ class Student(models.Model):
def full_name(self):
return get_display_name(self.user, full_name=True)
@property
def age(self):
return get_current_age(self.birth_date)
def __unicode__(self):
return u"Student {}".format(get_display_name(self.user))
......
......@@ -20,7 +20,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', 'linkedin_url', 'region', 'intro', 'recommendations',
'show_transcript', 'photo', 'accepted_no', 'linkedin_url', 'region', 'intro', 'age','recommendations',
'latest_work', 'latest_work_desc','read_no', 'volunteer']
def get_accepted_no(self, obj):
......
import requests_mock
from datetime import date, timedelta
from rest_framework import status
from rest_framework.test import APIClient, APITestCase
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from core.models.accounts import Company, Supervisor, Student
from core.models.accounts import Company, Supervisor, Student, get_current_age
class LoginTests(APITestCase):
......@@ -87,6 +88,11 @@ class LoginTests(APITestCase):
response = self.client.post(url, {'username': 'lalala', 'password': 'lalalala', 'login-type' : 'lalala'}, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_return_age(self):
birth_day = (date.today() -timedelta(days = 700))
self.assertEqual(1, get_current_age(birth_day))
class RegisterTests(APITestCase):
......
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