diff --git a/core/migrations/0007_auto_20170424_0720.py b/core/migrations/0007_auto_20170424_0720.py new file mode 100644 index 0000000000000000000000000000000000000000..23313a738e6ba8ff5cae98f8c9863bd17693eb6a --- /dev/null +++ b/core/migrations/0007_auto_20170424_0720.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-04-24 07:20 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0006_auto_20170328_1950'), + ] + + operations = [ + migrations.AddField( + model_name='student', + name='batch', + field=models.CharField(blank=True, max_length=4, null=True), + ), + migrations.AddField( + model_name='student', + name='birth_date', + field=models.DateField(blank=True, null=True), + ), + migrations.AddField( + model_name='student', + name='birth_place', + field=models.TextField(blank=True, max_length=100, null=True), + ), + migrations.AddField( + model_name='student', + name='major', + field=models.CharField(blank=True, max_length=100, null=True), + ), + migrations.AddField( + model_name='student', + name='show_resume', + field=models.BooleanField(default=False), + ), + ] diff --git a/core/migrations/0008_auto_20170424_0725.py b/core/migrations/0008_auto_20170424_0725.py new file mode 100644 index 0000000000000000000000000000000000000000..bacc0ebe121ce7f5e5151b5c9b807c42d3de2d34 --- /dev/null +++ b/core/migrations/0008_auto_20170424_0725.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-04-24 07:25 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0007_auto_20170424_0720'), + ] + + operations = [ + migrations.AlterField( + model_name='student', + name='birth_place', + field=models.CharField(blank=True, max_length=30, null=True), + ), + migrations.AlterField( + model_name='student', + name='major', + field=models.CharField(blank=True, max_length=30, null=True), + ), + ] diff --git a/core/models/accounts.py b/core/models/accounts.py index 296851594da3f3abaad2c1f59f9201e9e9de2c47..afb37d7c61b7f83f1801e472bba3b1309fb172e4 100644 --- a/core/models/accounts.py +++ b/core/models/accounts.py @@ -51,6 +51,11 @@ class Student(models.Model): bookmarked_vacancies = models.ManyToManyField('core.Vacancy', related_name="bookmarked_vacancies", blank=True) applied_vacancies = models.ManyToManyField('core.Vacancy', related_name="applied_vacancies", blank=True, through='core.Application') + birth_place = models.CharField(max_length=30, blank=True, null=True) + birth_date = models.DateField(blank=True, null=True) + major = models.CharField(max_length=30, blank=True, null=True) + batch = models.CharField(max_length=4, blank=True, null=True) + show_resume = models.BooleanField(default=False) @property def name(self): diff --git a/core/views/accounts.py b/core/views/accounts.py index 4afa426a8311f069eeb2fe3e8b9cad4b5a56f146..dfb24c3ee873a9fbf16dcf6be957904d12fb55f4 100644 --- a/core/views/accounts.py +++ b/core/views/accounts.py @@ -102,11 +102,15 @@ class LoginViewSet(viewsets.GenericViewSet): login(request, user) if created: if resp.get('nama_role') == "mahasiswa": + student_detail = requests.get('https://api.cs.ui.ac.id/siakngcs/mahasiswa/{}/'.format(resp.get("kodeidentitas"))) + resp_student_detail = student_detail.json() student = Student.objects.create( user=user, npm=resp.get("kodeidentitas"), - resume=None, - phone_number=None + birth_place=resp_student_detail.get('kota_lahir'), + birth_date=resp_student_detail.get('tgl_lahir'), + major=resp_student_detail.get('program')[0].get('nm_org'), + batch=resp_student_detail.get('program')[0].get('angkatan') ) student.save() else: