Fakultas Ilmu Komputer UI

Commit 719313f2 authored by Joshua Casey's avatar Joshua Casey
Browse files

[#140655219] #24 Added new data to student model and revised login to accommodate the change

parent 04a682ea
# -*- 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),
),
]
# -*- 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),
),
]
......@@ -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):
......
......@@ -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:
......
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