From 07c7aea973f15a2a1ef1f77e72e193eae07cada7 Mon Sep 17 00:00:00 2001 From: zulia <zulia.putri@ui.ac.id> Date: Fri, 15 Nov 2019 20:26:23 +0700 Subject: [PATCH 1/3] convert date time into readable date time --- assets/js/ProfilePage.jsx | 864 ++++++++++++++++++++------------------ core/views/accounts.py | 34 +- package-lock.json | 14 +- 3 files changed, 483 insertions(+), 429 deletions(-) diff --git a/assets/js/ProfilePage.jsx b/assets/js/ProfilePage.jsx index ef69a5c6..eecacf67 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, @@ -169,6 +170,28 @@ export default class ProfilePage extends React.Component { ); } + 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; + }; + isFromGithubLinkValid = () => { var github_link = this.state.form.github_url; if (github_link == null) return; @@ -283,407 +306,418 @@ 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} - 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} + 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> + <Segment basic vertical> + <Grid> + <Grid.Column width={2}> + <h3 className="lastSeen">Last Seen</h3> + </Grid.Column> + <Grid.Column width={13}> + <p> {this.state.lastLoggedIn} </p> + </Grid.Column> + </Grid> + </Segment> + + <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> ); @@ -882,8 +916,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> @@ -1050,7 +1084,21 @@ export default class ProfilePage extends React.Component { <Segment basic vertical> <Grid> <Grid.Column width={2}> - <Icon name="time" size="big" /> + <Icon name="time" size="big" /> + </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> @@ -1144,14 +1192,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> diff --git a/core/views/accounts.py b/core/views/accounts.py index 805758b4..125d37c4 100755 --- a/core/views/accounts.py +++ b/core/views/accounts.py @@ -5,7 +5,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 @@ -79,12 +79,14 @@ class StudentViewSet(viewsets.ModelViewSet): else: return Response({}, status=status.HTTP_415_UNSUPPORTED_MEDIA_TYPE) - 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) 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) @@ -100,12 +102,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'}, @@ -126,7 +131,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) @@ -176,7 +182,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}) @@ -209,14 +215,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: @@ -297,7 +306,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 fd82d3e6..4f4fe58f 100755 --- a/package-lock.json +++ b/package-lock.json @@ -5602,7 +5602,7 @@ "resolve": { "version": "1.12.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", - "integrity": "sha1-P8ZEo1yEpIVUYJ/ybsUrZvpXffY=", + "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -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", @@ -7948,7 +7946,7 @@ "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha1-E7BM2z5sXRnfkatph6hpVhmwqnE=", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true } } @@ -8650,7 +8648,7 @@ "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha1-zUJUFnelQzPPVBpJEIwUMrRMlCQ=", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, "requires": { "ansi-styles": "^3.2.1", @@ -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=" } } }, -- GitLab From 11d7e977f6b1a6a9aff0c1cec6356996ed1fa5a3 Mon Sep 17 00:00:00 2001 From: zulia <zulia.putri@ui.ac.id> Date: Fri, 15 Nov 2019 21:07:06 +0700 Subject: [PATCH 2/3] resolving conflict --- core/views/accounts.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/core/views/accounts.py b/core/views/accounts.py index 25270b22..136bd5b5 100755 --- a/core/views/accounts.py +++ b/core/views/accounts.py @@ -84,10 +84,6 @@ class StudentViewSet(viewsets.ModelViewSet): else: return Response({}, status=status.HTTP_415_UNSUPPORTED_MEDIA_TYPE) -<<<<<<< HEAD - serializer = self.serializer_class( - user, data=request.data, partial=True) -======= if 'github_url' in request.data.keys(): if not re.search(github_url_pattern, request.data['github_url']): return Response({'Error': "Pastikan link github yang anda tulis benar. (Berpola : https://github.com/<username>"}, status=status.HTTP_400_BAD_REQUEST) @@ -99,9 +95,9 @@ 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) ->>>>>>> origin + + 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) -- GitLab From 8f728f37419d1265751e1139dedcca33784de827 Mon Sep 17 00:00:00 2001 From: zulia <zulia.putri@ui.ac.id> Date: Fri, 15 Nov 2019 21:22:51 +0700 Subject: [PATCH 3/3] resolve conflict --- assets/js/ProfilePage.jsx | 433 +------------------------------------- 1 file changed, 11 insertions(+), 422 deletions(-) diff --git a/assets/js/ProfilePage.jsx b/assets/js/ProfilePage.jsx index 53516706..9453cf75 100755 --- a/assets/js/ProfilePage.jsx +++ b/assets/js/ProfilePage.jsx @@ -170,6 +170,12 @@ export default class ProfilePage extends React.Component { ); } + isFromGithubLinkValid = () => { + var github_link = this.state.form.github_url; + if (github_link == null) return; + return github_link.includes('https://github.com/'); + }; + convertDateTime = (dateTime) => { const monthNameIndex = { '01': 'Januari', @@ -185,6 +191,7 @@ export default class ProfilePage extends React.Component { '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)}`; @@ -192,12 +199,6 @@ export default class ProfilePage extends React.Component { return newTime; }; - isFromGithubLinkValid = () => { - var github_link = this.state.form.github_url; - if (github_link == null) return; - return github_link.includes('https://github.com/'); - }; - parseIndonesianDateFormat(dateIndex) { const monthNameIndex = { '01': 'Januari', @@ -306,7 +307,6 @@ 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}> -<<<<<<< HEAD <ModalAlert ref={(modal) => { this.modalAlert = modal; @@ -317,397 +317,6 @@ export default class ProfilePage extends React.Component { this.form = input; }} key={this.state.refresh} -======= - <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" ->>>>>>> origin size="small" onSubmit={this.handleSubmit} > @@ -769,11 +378,7 @@ export default class ProfilePage extends React.Component { </Form.Field> <Form.Field> <label htmlFor="self_description">Deskripsi Diri</label> - <input - onChange={this.handleChange} - placeholder="Saya suka belajar" - name="self_description" - /> + <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> @@ -1027,17 +632,6 @@ export default class ProfilePage extends React.Component { name="intro" /> </Form.Field> - <Segment basic vertical> - <Grid> - <Grid.Column width={2}> - <h3 className="lastSeen">Last Seen</h3> - </Grid.Column> - <Grid.Column width={13}> - <p> {this.state.lastLoggedIn} </p> - </Grid.Column> - </Grid> - </Segment> - <Form.Field> <label htmlFor="volunteer">Volunteering Experience</label> <input @@ -1472,21 +1066,16 @@ 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> + <p> {this.state.lastLoggedIn} </p> </Grid.Column> </Grid> </Segment> - <Segment basic vertical> <Grid> <Grid.Column width={2}> @@ -1600,4 +1189,4 @@ export default class ProfilePage extends React.Component { </div> ); } -} +} \ No newline at end of file -- GitLab