diff --git a/assets/js/ProfilePage.jsx b/assets/js/ProfilePage.jsx index 4c446236d281095a8ab206398c53ca5f776b7818..9453cf7592849897610a26dbeeb1d82b4ce0433d 100755 --- a/assets/js/ProfilePage.jsx +++ b/assets/js/ProfilePage.jsx @@ -138,6 +138,7 @@ export default class ProfilePage extends React.Component { job_seeking_status: data.job_seeking_status, volunteer: data.volunteer, linkedin_url: data.linkedin_url, + lastLoggedIn: this.convertDateTime(data.user.last_login), hackerrank_url: data.hackerrank_url, self_description: data.self_description, student_gpa: data.student_gpa, @@ -175,6 +176,29 @@ export default class ProfilePage extends React.Component { return github_link.includes('https://github.com/'); }; + convertDateTime = (dateTime) => { + const monthNameIndex = { + '01': 'Januari', + '02': 'Februari', + '03': 'Maret', + '04': 'April', + '05': 'Mei', + '06': 'Juni', + '07': 'Juli', + '08': 'Agustus', + '09': 'September', + '10': 'Oktober', + '11': 'November', + '12': 'Desember', + }; + + let timeSt = dateTime.split('T'); + let dayMonthYear = timeSt[0].split('-'); + let newTime = `${dayMonthYear[2]} ${monthNameIndex[dayMonthYear[1]]} ${dayMonthYear[0]} | ${timeSt[1].substr(0, 5)}`; + console.log(newTime); + return newTime; + }; + parseIndonesianDateFormat(dateIndex) { const monthNameIndex = { '01': 'Januari', @@ -283,403 +307,403 @@ export default class ProfilePage extends React.Component { </Header> <ModalAlert ref={(modal) => { this.modalAlert = modal; }} /> <Form.Field ref={(input) => { this.form = input; }} key={this.state.refresh} size="small" onSubmit={this.handleSubmit}> - <ModalAlert - ref={(modal) => { - this.modalAlert = modal; - }} - /> - <Form - ref={(input) => { - this.form = input; - }} - key={this.state.refresh} - size="small" - onSubmit={this.handleSubmit} - > - <Form.Field> - <label htmlFor="photo">Profile Picture</label> - <input - onChange={this.handleFile} - placeholder="Profile Photo.jpg" - name="photo" - type="File" - /> - </Form.Field> - <Form.Field> - <label htmlFor="email">Email</label> - <input - onChange={this.handleChange} - placeholder={ - this.state.email === null - ? 'jojon@email.com' - : this.state.email - } - defaultValue={ - this.state.email === null ? null : this.state.email - } - name="email" - /> - </Form.Field> - <Form.Field> - <label htmlFor="phone_number">No. Hp</label> - <input - onChange={this.handleChange} - placeholder={ - this.state.phone_number === null - ? '08123456789' - : this.state.phone_number - } - defaultValue={ - this.state.phone_number === null - ? null - : this.state.phone_number - } - name="phone_number" - /> - </Form.Field> - <Form.Field> - <label htmlFor="gender">Jenis Kelamin</label> - <Form.Radio - label="Perempuan" - name="gender" - value="Perempuan" - onClick={this.handleRadioGender} - /> - <Form.Radio - label="Laki-laki" - name="gender" - value="Laki-laki" - onClick={this.handleRadioGender} - /> - </Form.Field> - <Form.Field> - <label htmlFor="self_description">Deskripsi Diri</label> - <input onChange={this.handleChange} maxlength="500" placeholder="Saya suka belajar" name="self_description" /> - </Form.Field> - <Form.Field> - <label htmlFor="linkedin_url">URL Profile LinkedIn</label> - <input - onChange={this.handleChange} - placeholder={ - this.state.linkedin_url === null - ? 'https://www.linkedin.com/in/jojo/' - : this.state.linkedin_url - } - defaultValue={ - this.state.linkedin_url === null - ? null - : this.state.linkedin_url - } - 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 - onChange={this.handleChange} - placeholder={this.state.portfolio_link === null ? 'https://www.example.com/myproject/' : - this.state.portfolio_link} - defaultValue={this.state.portfolio_link === null ? null : this.state.portfolio_link} - placeholder={ - this.state.portfolio_link === null - ? 'https://www.example.com/myproject/' - : this.state.portfolio_link - } - defaultValue={ - this.state.portfolio_link === null - ? null - : this.state.portfolio_link - } - name="portfolio_link" - /> - </Form.Field> - <Form.Field> - <label htmlFor="website_url">Website URL</label> - <input - onChange={this.handleChange} - placeholder={ - this.state.website_url === null - ? 'https://www.example.com/' - : this.state.website_url - } - defaultValue={ - this.state.website_url === null - ? null - : this.state.website_url - } - name="website_url" - /> - </Form.Field> - <Form.Field> - <label htmlFor="linkedin_url">URL Profile Github</label> - <input - onChange={this.handleChange} - placeholder="https://github.com/bob" - name="github_url" - /> - </Form.Field> - <Form.Field> - <label htmlFor="alamat">Alamat</label> - <input - onChange={this.handleChange} - placeholder={ - this.state.alamat === null ? 'Indonesia' : this.state.alamat - } - defaultValue={ - this.state.alamat === null ? null : this.state.alamat - } - name="alamat" - /> - </Form.Field> - <Form.Field> - <label htmlFor="region">Region</label> - <input - onChange={this.handleChange} - placeholder={ - this.state.region === null ? 'Indonesia' : this.state.region - } - defaultValue={ - this.state.region === null ? null : this.state.region - } - name="region" - /> - </Form.Field> - <Form.Field> - <label htmlFor="skills">Skills</label> - <input - onChange={this.handleChange} - placeholder="Isi sesuai dengan keahlian anda" - name="skills" - /> - </Form.Field> - <Form.Field> - <label htmlFor="latest_work">Latest Working Experience</label> - <input - onChange={this.handleChange} - placeholder={ - this.state.latest_work === null - ? 'Teaching Asssistant at Fasilkom UI' - : this.state.latest_work - } - defaultValue={ - this.state.latest_work === null - ? null - : this.state.latest_work - } - name="latest_work" - /> - </Form.Field> - <Form.Field> - <label htmlFor="latest_work_desc"> - Latest Working Experience Description - </label> - <input - onChange={this.handleChange} - placeholder={ - this.state.latest_work_desc === null - ? 'Evaluate weekly assignment for 15 students' - : this.state.latest_work_desc - } - defaultValue={ - this.state.latest_work_desc === null - ? null - : this.state.latest_work_desc - } - name="latest_work_desc" - /> - </Form.Field> - <Form.Field> - <label htmlFor="awards">Awards and Achievements</label> - <input - onChange={this.handleChange} - placeholder={ - this.state.awards === null - ? 'Juara 2 UIUX Gemastik 2019' - : this.state.awards - } - defaultValue={ - this.state.awards === null ? null : this.state.awards - } - name="awards" - /> - </Form.Field> - <Form.Field> - <label htmlFor="projects">Projects</label> - <input - onChange={this.handleChange} - placeholder={ - this.state.projects === null - ? 'Ow-Jek - Android Mobile Project' - : this.state.projects - } - defaultValue={ - this.state.projects === null ? null : this.state.projects - } - name="projects" - /> - </Form.Field> - <Form.Field> - <label htmlFor="certification">Sertifikasi</label> - <input - onChange={this.handleChange} - placeholder={ - this.state.certification === null - ? 'TOEFL' - : this.state.certification - } - defaultValue={ - this.state.certification === null - ? null - : this.state.certification - } - name="certification" - /> - </Form.Field> - <Form.Field> - <label htmlFor="seminar">Seminar dan Training</label> - <input - onChange={this.handleChange} - placeholder={ - this.state.seminar === null - ? 'Seminar Compfest' - : this.state.seminar - } - defaultValue={ - this.state.seminar === null ? null : this.state.seminar - } - name="seminar" - /> - </Form.Field> - <Form.Field> - <label htmlFor="interests">Interests</label> - <input - onChange={this.handleChange} - placeholder={this.state.interests === null ? 'Machine Learning' : this.state.interests} - defaultValue={this.state.interests === null ? null : this.state.interests} - name="interests" - /> - </Form.Field> - <Form.Field> - <label htmlFor="resume">Resume</label> - <input - onChange={this.handleFile} - placeholder="Resume" - name="resume" - type="File" - /> - </Form.Field> - <Form.Field> - <label htmlFor="phone_number">Expected Salary</label> - <input - onChange={this.handleChange} - placeholder="2000000" - name="expected_salary" - /> - </Form.Field> - <Form.Field> - <label htmlFor="intro">Intro</label> - <input - onChange={this.handleChange} - placeholder={ - this.state.intro === null - ? 'Ceritakan dirimu secara singkat' - : this.state.intro - } - defaultValue={ - this.state.intro === null ? null : this.state.intro - } - name="intro" - /> - </Form.Field> - <Form.Field> - <label htmlFor="volunteer">Volunteering Experience</label> - <input - onChange={this.handleChange} - placeholder="Ketua Organisasi A - 2020" - name="volunteer" - /> - </Form.Field> - <Form.Field> - <label htmlFor="intro">Status Pencarian Kerja</label> - <Form.Radio - label="Aktif" - name="job_seeking_status" - value="Active" - onClick={this.handleRadio} - /> - <Form.Radio - label="Pasif" - name="job_seeking_status" - value="Passive" - onClick={this.handleRadio} - /> - </Form.Field> - <Form.Field> - <Checkbox - onChange={this.handleCheckbox} - checked={!!this.state.show_transcript} - label="Ijinkan perusahaan tempat saya mendaftar untuk melihat transkrip akademik saya" - name="show_transcript" - /> - </Form.Field> - <Form.Field> - <label htmlFor="student_gpa">GPA</label> - <input - onChange={this.handleChange} - placeholder={ - this.state.student_gpa === null - ? '3.50' - : this.state.student_gpa - } - defaultValue={ - this.state.student_gpa === null - ? null - : this.state.student_gpa - } - name="student_gpa" - /> - </Form.Field> - <Form.Field> - <label htmlFor="dependants">Dependants</label> - <input - onChange={this.handleChange} - placeholder={ - this.state.dependants === null ? '0' : this.state.dependants - } - defaultValue={ - this.state.dependants === null ? null : this.state.dependants - } - name="dependants" - /> - </Form.Field> - - <Button - type="submit" + <ModalAlert + ref={(modal) => { + this.modalAlert = modal; + }} + /> + <Form + ref={(input) => { + this.form = input; + }} + key={this.state.refresh} size="small" - loading={this.state.loading} - primary - floated="right" + onSubmit={this.handleSubmit} > - Submit + <Form.Field> + <label htmlFor="photo">Profile Picture</label> + <input + onChange={this.handleFile} + placeholder="Profile Photo.jpg" + name="photo" + type="File" + /> + </Form.Field> + <Form.Field> + <label htmlFor="email">Email</label> + <input + onChange={this.handleChange} + placeholder={ + this.state.email === null + ? 'jojon@email.com' + : this.state.email + } + defaultValue={ + this.state.email === null ? null : this.state.email + } + name="email" + /> + </Form.Field> + <Form.Field> + <label htmlFor="phone_number">No. Hp</label> + <input + onChange={this.handleChange} + placeholder={ + this.state.phone_number === null + ? '08123456789' + : this.state.phone_number + } + defaultValue={ + this.state.phone_number === null + ? null + : this.state.phone_number + } + name="phone_number" + /> + </Form.Field> + <Form.Field> + <label htmlFor="gender">Jenis Kelamin</label> + <Form.Radio + label="Perempuan" + name="gender" + value="Perempuan" + onClick={this.handleRadioGender} + /> + <Form.Radio + label="Laki-laki" + name="gender" + value="Laki-laki" + onClick={this.handleRadioGender} + /> + </Form.Field> + <Form.Field> + <label htmlFor="self_description">Deskripsi Diri</label> + <input onChange={this.handleChange} maxlength="500" placeholder="Saya suka belajar" name="self_description" /> + </Form.Field> + <Form.Field> + <label htmlFor="linkedin_url">URL Profile LinkedIn</label> + <input + onChange={this.handleChange} + placeholder={ + this.state.linkedin_url === null + ? 'https://www.linkedin.com/in/jojo/' + : this.state.linkedin_url + } + defaultValue={ + this.state.linkedin_url === null + ? null + : this.state.linkedin_url + } + 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 + onChange={this.handleChange} + placeholder={this.state.portfolio_link === null ? 'https://www.example.com/myproject/' : + this.state.portfolio_link} + defaultValue={this.state.portfolio_link === null ? null : this.state.portfolio_link} + placeholder={ + this.state.portfolio_link === null + ? 'https://www.example.com/myproject/' + : this.state.portfolio_link + } + defaultValue={ + this.state.portfolio_link === null + ? null + : this.state.portfolio_link + } + name="portfolio_link" + /> + </Form.Field> + <Form.Field> + <label htmlFor="website_url">Website URL</label> + <input + onChange={this.handleChange} + placeholder={ + this.state.website_url === null + ? 'https://www.example.com/' + : this.state.website_url + } + defaultValue={ + this.state.website_url === null + ? null + : this.state.website_url + } + name="website_url" + /> + </Form.Field> + <Form.Field> + <label htmlFor="linkedin_url">URL Profile Github</label> + <input + onChange={this.handleChange} + placeholder="https://github.com/bob" + name="github_url" + /> + </Form.Field> + <Form.Field> + <label htmlFor="alamat">Alamat</label> + <input + onChange={this.handleChange} + placeholder={ + this.state.alamat === null ? 'Indonesia' : this.state.alamat + } + defaultValue={ + this.state.alamat === null ? null : this.state.alamat + } + name="alamat" + /> + </Form.Field> + <Form.Field> + <label htmlFor="region">Region</label> + <input + onChange={this.handleChange} + placeholder={ + this.state.region === null ? 'Indonesia' : this.state.region + } + defaultValue={ + this.state.region === null ? null : this.state.region + } + name="region" + /> + </Form.Field> + <Form.Field> + <label htmlFor="skills">Skills</label> + <input + onChange={this.handleChange} + placeholder="Isi sesuai dengan keahlian anda" + name="skills" + /> + </Form.Field> + <Form.Field> + <label htmlFor="latest_work">Latest Working Experience</label> + <input + onChange={this.handleChange} + placeholder={ + this.state.latest_work === null + ? 'Teaching Asssistant at Fasilkom UI' + : this.state.latest_work + } + defaultValue={ + this.state.latest_work === null + ? null + : this.state.latest_work + } + name="latest_work" + /> + </Form.Field> + <Form.Field> + <label htmlFor="latest_work_desc"> + Latest Working Experience Description + </label> + <input + onChange={this.handleChange} + placeholder={ + this.state.latest_work_desc === null + ? 'Evaluate weekly assignment for 15 students' + : this.state.latest_work_desc + } + defaultValue={ + this.state.latest_work_desc === null + ? null + : this.state.latest_work_desc + } + name="latest_work_desc" + /> + </Form.Field> + <Form.Field> + <label htmlFor="awards">Awards and Achievements</label> + <input + onChange={this.handleChange} + placeholder={ + this.state.awards === null + ? 'Juara 2 UIUX Gemastik 2019' + : this.state.awards + } + defaultValue={ + this.state.awards === null ? null : this.state.awards + } + name="awards" + /> + </Form.Field> + <Form.Field> + <label htmlFor="projects">Projects</label> + <input + onChange={this.handleChange} + placeholder={ + this.state.projects === null + ? 'Ow-Jek - Android Mobile Project' + : this.state.projects + } + defaultValue={ + this.state.projects === null ? null : this.state.projects + } + name="projects" + /> + </Form.Field> + <Form.Field> + <label htmlFor="certification">Sertifikasi</label> + <input + onChange={this.handleChange} + placeholder={ + this.state.certification === null + ? 'TOEFL' + : this.state.certification + } + defaultValue={ + this.state.certification === null + ? null + : this.state.certification + } + name="certification" + /> + </Form.Field> + <Form.Field> + <label htmlFor="seminar">Seminar dan Training</label> + <input + onChange={this.handleChange} + placeholder={ + this.state.seminar === null + ? 'Seminar Compfest' + : this.state.seminar + } + defaultValue={ + this.state.seminar === null ? null : this.state.seminar + } + name="seminar" + /> + </Form.Field> + <Form.Field> + <label htmlFor="interests">Interests</label> + <input + onChange={this.handleChange} + placeholder={this.state.interests === null ? 'Machine Learning' : this.state.interests} + defaultValue={this.state.interests === null ? null : this.state.interests} + name="interests" + /> + </Form.Field> + <Form.Field> + <label htmlFor="resume">Resume</label> + <input + onChange={this.handleFile} + placeholder="Resume" + name="resume" + type="File" + /> + </Form.Field> + <Form.Field> + <label htmlFor="phone_number">Expected Salary</label> + <input + onChange={this.handleChange} + placeholder="2000000" + name="expected_salary" + /> + </Form.Field> + <Form.Field> + <label htmlFor="intro">Intro</label> + <input + onChange={this.handleChange} + placeholder={ + this.state.intro === null + ? 'Ceritakan dirimu secara singkat' + : this.state.intro + } + defaultValue={ + this.state.intro === null ? null : this.state.intro + } + name="intro" + /> + </Form.Field> + <Form.Field> + <label htmlFor="volunteer">Volunteering Experience</label> + <input + onChange={this.handleChange} + placeholder="Ketua Organisasi A - 2020" + name="volunteer" + /> + </Form.Field> + <Form.Field> + <label htmlFor="intro">Status Pencarian Kerja</label> + <Form.Radio + label="Aktif" + name="job_seeking_status" + value="Active" + onClick={this.handleRadio} + /> + <Form.Radio + label="Pasif" + name="job_seeking_status" + value="Passive" + onClick={this.handleRadio} + /> + </Form.Field> + <Form.Field> + <Checkbox + onChange={this.handleCheckbox} + checked={!!this.state.show_transcript} + label="Ijinkan perusahaan tempat saya mendaftar untuk melihat transkrip akademik saya" + name="show_transcript" + /> + </Form.Field> + <Form.Field> + <label htmlFor="student_gpa">GPA</label> + <input + onChange={this.handleChange} + placeholder={ + this.state.student_gpa === null + ? '3.50' + : this.state.student_gpa + } + defaultValue={ + this.state.student_gpa === null + ? null + : this.state.student_gpa + } + name="student_gpa" + /> + </Form.Field> + <Form.Field> + <label htmlFor="dependants">Dependants</label> + <input + onChange={this.handleChange} + placeholder={ + this.state.dependants === null ? '0' : this.state.dependants + } + defaultValue={ + this.state.dependants === null ? null : this.state.dependants + } + name="dependants" + /> + </Form.Field> + + <Button + type="submit" + size="small" + loading={this.state.loading} + primary + floated="right" + > + Submit </Button> - </Form> + </Form> </Form.Field> </Segment> ); @@ -878,8 +902,8 @@ export default class ProfilePage extends React.Component { {this.state.github_url}{' '} </a> ) : ( - <p> N/A </p> - )} + <p> N/A </p> + )} </Grid.Column> </Grid> </Segment> @@ -1042,11 +1066,20 @@ export default class ProfilePage extends React.Component { </Grid.Column> </Grid> </Segment> - <Segment basic vertical> <Grid> <Grid.Column width={2}> - <Icon name="time" size="big" /> + <h3 className="lastSeen">Last Seen</h3> + </Grid.Column> + <Grid.Column width={13}> + <p> {this.state.lastLoggedIn} </p> + </Grid.Column> + </Grid> + </Segment> + <Segment basic vertical> + <Grid> + <Grid.Column width={2}> + <Icon name="time" size="big" /> </Grid.Column> <Grid.Column width={13}> <p> {this.state.age + ' years' || 'N/A'} </p> @@ -1140,14 +1173,14 @@ export default class ProfilePage extends React.Component { </p> </Message> ) : ( - <Message negative> - <Message.Header>Tidak mencari pekerjaan</Message.Header> - <p> - Saya sedang tidak mencari pekerjaan. Mohon jangan kirimkan - informasi mengenai lowongan pekerjaan. + <Message negative> + <Message.Header>Tidak mencari pekerjaan</Message.Header> + <p> + Saya sedang tidak mencari pekerjaan. Mohon jangan kirimkan + informasi mengenai lowongan pekerjaan. </p> - </Message> - )} + </Message> + )} </h4> </div> </Segment> @@ -1156,4 +1189,4 @@ export default class ProfilePage extends React.Component { </div> ); } -} +} \ No newline at end of file diff --git a/core/views/accounts.py b/core/views/accounts.py index 77cf9506f140230daf668d3017c460aaa59b7ded..136bd5b5c560e891e87f44b4cb1f7ef23eef7b26 100755 --- a/core/views/accounts.py +++ b/core/views/accounts.py @@ -6,7 +6,7 @@ from django.shortcuts import get_object_or_404 from rest_framework import viewsets, status from rest_framework.decorators import list_route, detail_route from rest_framework.exceptions import PermissionDenied -from rest_framework.parsers import FormParser,MultiPartParser +from rest_framework.parsers import FormParser, MultiPartParser from rest_framework.permissions import AllowAny from rest_framework.permissions import IsAdminUser, IsAuthenticated from rest_framework.response import Response @@ -95,15 +95,17 @@ class StudentViewSet(viewsets.ModelViewSet): if 'hackerrank_url' in request.data.keys(): if not re.search(hackerrank_url_pattern, request.data['hackerrank_url']): return Response({'Error': "Pastikan link hackerrank yang anda tulis benar. (Berpola : https://hackerrank.com/<username>"}, status=status.HTTP_400_BAD_REQUEST) - - serializer = self.serializer_class(user, data=request.data, partial=True) + + serializer = self.serializer_class( + user, data=request.data, partial=True) if serializer.is_valid(): if serializer.validated_data.get('skills') is not None and serializer.validated_data.get('skills').isdigit(): return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) serializer.save() return Response(serializer.data, status=status.HTTP_202_ACCEPTED) else: - serializer = self.serializer_class(user, data=request.data, partial=True) + serializer = self.serializer_class( + user, data=request.data, partial=True) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_202_ACCEPTED) @@ -119,12 +121,15 @@ class StudentViewSet(viewsets.ModelViewSet): student = get_object_or_404(Student.objects.all(), pk=pk) if hasattr(request.user, 'student') and request.user.student.pk != student.pk: - raise PermissionDenied("You are not allowed to see other student's transcript") + raise PermissionDenied( + "You are not allowed to see other student's transcript") if student.show_transcript: - access_token = get_access_token(credentials["user"], credentials["password"]) + access_token = get_access_token( + credentials["user"], credentials["password"]) ver_user = verify_user(access_token) - response = get_riwayat_user(access_token, ver_user['identity_number']) + response = get_riwayat_user( + access_token, ver_user['identity_number']) return Response({'name': student.full_name, 'transcript': response.json()}, status=status.HTTP_200_OK) else: return Response({'name': student.full_name, 'error': 'student does not allow transcript to be shown'}, @@ -145,7 +150,8 @@ class CompanyViewSet(viewsets.ModelViewSet): --- """ user = self.get_object() - serializer = self.serializer_class(user, data=request.data, partial=True) + serializer = self.serializer_class( + user, data=request.data, partial=True) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_202_ACCEPTED) @@ -195,7 +201,7 @@ class LoginViewSet(viewsets.GenericViewSet): if login_type == "sso-ui": return self.login_via_sso(request, username, password) elif login_type == "company": - user = authenticate(username = username, password = password) + user = authenticate(username=username, password=password) if user is not None: login(request, user) serializer = UserSerializer(user, context={'request': request}) @@ -228,14 +234,17 @@ class LoginViewSet(viewsets.GenericViewSet): if resp.get('nama_role') == "mahasiswa": access_token = get_access_token(username, password) ver_user = verify_user(access_token) - resp_student_detail = get_summary_user(access_token, ver_user['identity_number']) + resp_student_detail = get_summary_user( + access_token, ver_user['identity_number']) student = Student.objects.create( user=user, npm=resp.get("kodeidentitas"), 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') + major=resp_student_detail.get( + 'program')[0].get('nm_org'), + batch=resp_student_detail.get( + 'program')[0].get('angkatan') ) student.save() else: @@ -316,7 +325,8 @@ class CompanyRegisterViewSet(viewsets.GenericViewSet): ) user.save() company.save() - serializer = self.serializer_class(user, context={'request': request}) + serializer = self.serializer_class( + user, context={'request': request}) login(request, user) return Response(serializer.data, status=status.HTTP_201_CREATED) else: diff --git a/package-lock.json b/package-lock.json index 66536af8e8d2009920b169c2388787675150da24..11d3570574a0ed694d32d833be6b11e5323a66c9 100755 --- a/package-lock.json +++ b/package-lock.json @@ -6256,7 +6256,6 @@ "version": "5.13.1", "resolved": "https://registry.npmjs.org/fetch-mock/-/fetch-mock-5.13.1.tgz", "integrity": "sha512-eWUo2KI4sRGnRu8tKELCBfasALM5BfvrCxdI7J02j3eUM9mf+uYzJkURA0PSn/29JVapVrYFm+z+9XijXu1PdA==", - "dev": true, "requires": { "glob-to-regexp": "^0.3.0", "node-fetch": "^1.3.3", @@ -7074,8 +7073,7 @@ "glob-to-regexp": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz", - "integrity": "sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs=", - "dev": true + "integrity": "sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs=" }, "global": { "version": "4.4.0", @@ -10221,7 +10219,6 @@ "version": "1.7.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", - "dev": true, "requires": { "isarray": "0.0.1" }, @@ -10229,8 +10226,7 @@ "isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" } } },