Fakultas Ilmu Komputer UI

Commit 3c4c1b05 authored by metta.anantha's avatar metta.anantha
Browse files

Merge branch 'master' of https://gitlab.cs.ui.ac.id/pmpl/class-project/kape into 1606876046-203

parents 261761e8 57e01d81
Pipeline #26771 passed with stages
in 7 minutes and 49 seconds
......@@ -54,6 +54,7 @@ export default class EditProfile extends ProfileHandler {
awards: '',
projects: '',
certification: '',
sertifikat:'',
languages: '',
seminar: '',
interests: '',
......@@ -117,6 +118,7 @@ export default class EditProfile extends ProfileHandler {
awards: data.awards,
projects: data.projects,
certification: data.certification,
sertifikat:data.sertifikat,
languages: data.languages,
seminar: data.seminar,
interests: data.interests,
......@@ -341,15 +343,6 @@ export default class EditProfile extends ProfileHandler {
name="student_gpa"
/>
</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="expected_salary">Expected Salary</label>
<input onChange={this.handleChange} placeholder="2000000" name="expected_salary" />
......@@ -461,6 +454,93 @@ export default class EditProfile extends ProfileHandler {
<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="sertifikat">Sertifikat</label>
<input
onChange={this.handleFile}
placeholder="Sertifikat"
name="pdf_sertifikat"
type="File"
/>
</Form.Field>
<Form.Field>
<label htmlFor="languages">Bahasa yang dikuasai</label>
<input
onChange={this.handleChange}
placeholder={
this.state.languages === null
? 'Indonesia'
: this.state.languages
}
defaultValue={
this.state.languages === null ? null : this.state.languages
}
name="languages"
/>
</Form.Field>
<Form.Field>
<input
onChange={this.handleChange}
placeholder={
......
......@@ -291,10 +291,10 @@ export default class ProfilePage extends ProfileHandler {
render() {
const sertifikat_exists = this.state.sertifikat;
let sertifikat_state;
if (sertifikat_exists) {
sertifikat_state = <p>Sertifikat sudah ada</p>;
} else {
if (sertifikat_exists == '') {
sertifikat_state = <p>Sertifikat belum ada</p>;
} else {
sertifikat_state = <p>Sertifikat sudah ada</p>;
}
const defaultPicture = 'https://semantic-ui.com/images/wireframe/square-image.png';
return (
......@@ -487,6 +487,110 @@ export default class ProfilePage extends ProfileHandler {
</Grid.Column>
</Grid>
</Segment>
<Segment basic vertical>
<Grid>
<Grid.Column width={2}>
<Icon name="hand peace outline" size="big" />
</Grid.Column>
<Grid.Column width={13}>
<p>
{' '}
{this.state.volunteer || 'N/A'}
{' '}
</p>
</Grid.Column>
</Grid>
</Segment>
<Segment basic vertical>
<Grid>
<Grid.Column width={2}>
<Icon name="trophy" size="big" />
</Grid.Column>
<Grid.Column width={13}>
<p>
{' '}
{this.state.awards || 'Awards belum ditambahkan'}
{' '}
</p>
</Grid.Column>
</Grid>
</Segment>
<Segment basic vertical>
<Grid>
<Grid.Column width={2}>
<Icon name="certificate" size="big" />
</Grid.Column>
<Grid.Column width={13}>
{ sertifikat_state }
</Grid.Column>
</Grid>
</Segment>
<Segment basic vertical>
<Grid>
<Grid.Column width={2}>
<Icon name="folder open" size="big" />
</Grid.Column>
<Grid.Column width={13}>
<p>
{' '}
{this.state.projects
|| 'Projects belum ditambahkan'}
{' '}
</p>
</Grid.Column>
</Grid>
</Segment>
<Segment basic vertical>
<Grid>
<Grid.Column width={2}>
<Icon name="certificate" size="big" />
</Grid.Column>
<Grid.Column width={13}>
<p>
{' '}
{this.state.certification || 'N/A'}
{' '}
</p>
</Grid.Column>
</Grid>
</Segment>
<Segment basic vertical>
<Grid>
<Grid.Column width={2}>
<Icon name="comment" size="big" />
</Grid.Column>
<Grid.Column width={13}>
<p>
{' '}
{this.state.languages || 'N/A'}
{' '}
</p>
</Grid.Column>
</Grid>
</Segment>
<Segment basic vertical>
<Grid>
<Grid.Column width={2}>
<Icon name="slideshare" size="big" />
</Grid.Column>
<Grid.Column width={13}>
<p>
{' '}
{this.state.seminar
|| 'Seminar dan Training kosong'}
{' '}
</p>
</Grid.Column>
</Grid>
</Segment>
<Segment basic vertical>
<Grid>
<Grid.Column width={2}>
......
......@@ -2,6 +2,7 @@ import React from 'react';
import ReactTestUtils from 'react-dom/test-utils';
import fetchMock from 'fetch-mock';
import EditProfil from '../EditProfile';
import Storage from '../lib/Storage';
import { studentSession, response, response2 } from '../object/Response';
describe('EditProfil', () => {
......@@ -49,4 +50,45 @@ describe('EditProfil', () => {
ReactTestUtils.Simulate.change(emailNode, { target: { value: password } });
expect(emailNode.value).to.equal(password);
});
it('check if the user data is set correctly', () => {
fetchMock.get('*', response2);
const profile = ReactTestUtils.renderIntoDocument(
<EditProfil route={{ own: true, data: studentSession }} user={{ data: studentSession }} params={{ id: 3 }} />);
profile.getProfile().then(()=> expect(profile.props.route.own).to.equal(true));
const userData = Storage.get('user-data');
expect(userData.student).to.equal(null);
fetchMock.restore();
});
it('get student that doesnt exist', () => {
fetchMock.get('*', response2);
const profile = ReactTestUtils.renderIntoDocument(
<EditProfil route={{ own: false, data: studentSession }} user={{ data: studentSession }} params={{ id: -1 }} />);
profile.getProfile().then(()=> expect(profile.state.name).to.equal('Gagal mendapatkan informasi'));
fetchMock.restore();
});
it('check if the date parser is working properly', () => {
fetchMock.get('*', response2);
const profile = ReactTestUtils.renderIntoDocument(
<EditProfil route={{ own: true, data: studentSession }} user={{ data: studentSession }} params={{ id: 3 }} />);
const birthDate = '1996-06-30'
const parsedDate = profile.parseIndonesianDateFormat(birthDate)
expect(parsedDate).to.equal('30 Juni 1996')
fetchMock.restore();
});
it('check if the form is showing correctly', () => {
fetchMock.get('*', response2);
const profile = ReactTestUtils.renderIntoDocument(
<EditProfil route={{ own: true, data: studentSession }} user={{ data: studentSession }} params={{ id: 3 }} />);
profile.getProfile();
expect(profile.updateForm(false)).to.exist;
fetchMock.restore();
});
});
......@@ -30,6 +30,7 @@ const studentUserVerified = {
npm: 1406543593,
resume: null,
phone_number: null,
sertifikat:'ada',
bookmarked_vacancies: [
3,
],
......@@ -41,8 +42,9 @@ const studentUserVerified = {
},
};
describe('Sertifikat', () => {
it('render sertifikat', () => {
describe('Sertifikat doesnt exists', () => {
it('render sertifikat doesnt exists', () => {
studentUserVerified.data.sertifikat = null;
const sertifikat = ReactTestUtils.renderIntoDocument(
<p>Sertifikat belum ada</p>,
);
......@@ -50,6 +52,15 @@ describe('Sertifikat', () => {
});
});
describe('Sertifikat exists', () => {
it('render sertifikat exists', () => {
const sertifikat = ReactTestUtils.renderIntoDocument(
<p>Sertifikat sudah ada</p>,
);
expect(sertifikat).to.exist;
});
});
describe('ProfilePage', () => {
it('renders without problem', () => {
fetchMock.get('*', response);
......
......@@ -63,7 +63,9 @@ describe('LoginForm', () => {
<LoginForm url="" />,
);
const submitButton = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Button');
const submitButton = ReactTestUtils.findRenderedDOMComponentWithClass(formLogin, 'submit');
console.log(submitButton);
ReactTestUtils.Simulate.click(submitButton);
const form = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Form');
......@@ -77,7 +79,7 @@ describe('LoginForm', () => {
<LoginForm url="" />,
);
const submitButton = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Button');
const submitButton = ReactTestUtils.findRenderedDOMComponentWithClass(formLogin, 'submit');
ReactTestUtils.Simulate.click(submitButton);
const form = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Form');
......
......@@ -33,17 +33,25 @@ export default class LoginForm extends React.Component {
this.state = {
username: '',
password: '',
hide: true,
errorFlag: false,
loading: false,
};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.handleClick = this.handleClick.bind(this);
}
handleChange(event, name) {
this.setState({ [name]: event.target.value });
}
handleClick(event) {
event.preventDefault();
this.setState({ hide: !this.state.hide });
}
handleSubmit(event) {
event.preventDefault();
const data = {
......@@ -103,17 +111,22 @@ export default class LoginForm extends React.Component {
<Form.Field>
<label htmlFor="password"> Password </label>
<Input
type="password"
type={this.state.hide ? "password" : "text"}
id="password"
icon="key"
iconPosition="left"
action={{
icon: this.state.hide ? "unhide" : "hide",
onClick: this.handleClick
}}
placeholder="password"
value={this.state.password}
onChange={(e) => this.handleChange(e, 'password')}
required
/>
</Form.Field>
</Form.Group>
<Button type="submit" fluid color="blue">
<Button className="submit" type="submit" fluid color="blue">
Login
</Button>
<Message
......
# Generated by Django 2.2.8 on 2019-12-05 15:09
# Generated by Django 2.2.8 on 2019-12-06 03:44
from django.db import migrations, models
......
......@@ -285,6 +285,94 @@ class VacancyTest(APITestCase):
VacancySerializer(Vacancy.objects.order_by('-created'), many=True,
context={'request': request}).data)
def test_sort_vacancies_by_close_time(self):
superuser = User.objects.create_superuser('dummy.company', 'dummy.company@company.com', 'lalala123')
self.client.force_authenticate(user=superuser)
new_user = User.objects.create_user('dummy.company3', 'dummy.company3@company.com', 'lalala123')
new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None,
address=None)
open_time = datetime(2019, 12, 7)
close_time1 = datetime(2019, 12, 20)
close_time2 = datetime(2020, 2, 22)
close_time3 = datetime(2020, 2, 21)
created_time = datetime(2019, 12, 6)
v1 = Vacancy.objects.create(company=new_company, verified=True, open_time=open_time, salary=3000000,
description='', close_time=close_time1, name='vacancy1', max_accepted_applicants=3,
working_period="3 Bulan", created = created_time)
v1.save()
v2 = Vacancy.objects.create(company=new_company, verified=True, open_time=open_time, salary=3500000,
description='', close_time=close_time2, name='vacancy2', max_accepted_applicants=3,
working_period="3 Bulan", created=created_time)
v2.save()
v3 = Vacancy.objects.create(company=new_company, verified=True, open_time=open_time, salary=3500000,
description='', close_time=close_time3, name='vacancy2', max_accepted_applicants=3,
working_period="3 Bulan", created=created_time)
v3.save()
factory = APIRequestFactory()
url_close_time_asc = '/api/vacancies/?sort=close_time&order=ascending'
request = factory.get(url_close_time_asc)
response = self.client.get(url_close_time_asc, format='json')
self.assertEqual(dict(response.data)['results'], VacancySerializer(Vacancy.objects.order_by('close_time'), many=True,
context={'request': request}).data)
url_close_time_desc = '/api/vacancies/?sort=close_time&order=descending'
request = factory.get(url_close_time_desc)
response = self.client.get(url_close_time_desc, format='json')
self.assertEqual(dict(response.data)['results'], VacancySerializer(Vacancy.objects.order_by('-close_time'), many=True,
context={'request': request}).data)
def test_sort_vacancies_by_open_time(self):
superuser = User.objects.create_superuser('dummy.company', 'dummy.company@company.com', 'lalala123')
self.client.force_authenticate(user=superuser)
new_user = User.objects.create_user('dummy.company3', 'dummy.company3@company.com', 'lalala123')
new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None,
address=None)
open_time1 = datetime(2019, 12, 20)
open_time2 = datetime(2020, 2, 22)
open_time3 = datetime(2020, 2, 21)
close_time = datetime(2020, 3, 1)
created_time = datetime(2019, 12, 6)
v1 = Vacancy.objects.create(company=new_company, verified=True, open_time=open_time1, salary=3000000,
description='', close_time=close_time, name='vacancy1', max_accepted_applicants=3,
working_period="3 Bulan", created = created_time)
v1.save()
v2 = Vacancy.objects.create(company=new_company, verified=True, open_time=open_time2, salary=3500000,
description='', close_time=close_time, name='vacancy2', max_accepted_applicants=3,
working_period="3 Bulan", created=created_time)
v2.save()
v3 = Vacancy.objects.create(company=new_company, verified=True, open_time=open_time3, salary=3500000,
description='', close_time=close_time, name='vacancy2', max_accepted_applicants=3,
working_period="3 Bulan", created=created_time)
v3.save()
factory = APIRequestFactory()
url_open_time_asc = '/api/vacancies/?sort=open_time&order=ascending'
request = factory.get(url_open_time_asc)
response = self.client.get(url_open_time_asc, format='json')
self.assertEqual(dict(response.data)['results'], VacancySerializer(Vacancy.objects.order_by('open_time'), many=True,
context={'request': request}).data)
url_open_time_desc = '/api/vacancies/?sort=open_time&order=descending'
request = factory.get(url_open_time_desc)
response = self.client.get(url_open_time_desc, format='json')
self.assertEqual(dict(response.data)['results'], VacancySerializer(Vacancy.objects.order_by('-open_time'), many=True,
context={'request': request}).data)
def test_fail_on_unverified_user_vacancy_list(self):
url = '/api/vacancies/'
response = self.client.post(url, format='json')
......
......@@ -91,6 +91,7 @@ class StudentViewSet(viewsets.ModelViewSet):
if request.data[key].content_type == 'application/pdf':
user.sertifikat = request.data[key]
user.save()
print('HEHE TERSIMPAN SERTIFIKAT')
return Response({}, status=status.HTTP_200_OK)
else:
return Response({}, status=status.HTTP_415_UNSUPPORTED_MEDIA_TYPE)
......
......@@ -101,7 +101,7 @@ class VacancyViewSet(MultiSerializerViewSetMixin, viewsets.ModelViewSet):
return vacancies
def sort(self, order_by, vacancies, order):
if (order_by is not None) and (order_by in [views_constants.NAME, views_constants.SALARY, views_constants.MOST_RECENT]) and (
if (order_by is not None) and (order_by in [views_constants.NAME, views_constants.SALARY, views_constants.MOST_RECENT, views_constants.CLOSE_TIME, views_constants.OPEN_TIME]) and (
order in [views_constants.ORDER_ASCENDING, views_constants.ORDER_DESCENDING]):
if order_by == views_constants.MOST_RECENT:
return vacancies.order_by('-created')
......
This diff is collapsed.
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