From 719313f2bdcd7236d434558a8a1c2399d708476d Mon Sep 17 00:00:00 2001 From: Joshua Casey <joshua.caseyd@gmail.com> Date: Mon, 24 Apr 2017 15:05:00 +0700 Subject: [PATCH] [#140655219] #24 Added new data to student model and revised login to accommodate the change --- core/migrations/0007_auto_20170424_0720.py | 40 ++++++++++++++++++++++ core/migrations/0008_auto_20170424_0725.py | 25 ++++++++++++++ core/models/accounts.py | 5 +++ core/views/accounts.py | 8 +++-- 4 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 core/migrations/0007_auto_20170424_0720.py create mode 100644 core/migrations/0008_auto_20170424_0725.py diff --git a/core/migrations/0007_auto_20170424_0720.py b/core/migrations/0007_auto_20170424_0720.py new file mode 100644 index 00000000..23313a73 --- /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 00000000..bacc0ebe --- /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 29685159..afb37d7c 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 4afa426a..dfb24c3e 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: -- GitLab