Fakultas Ilmu Komputer UI

Commit c4d87b27 authored by Refo Ilmiya Akbar's avatar Refo Ilmiya Akbar
Browse files

Merge branch '1606876033-184' into 'master'

1606876033 184

Closes #184

See merge request !220
parents 420b75f1 43002031
Pipeline #26573 passed with stages
in 11 minutes and 45 seconds
# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2019-12-03 03:38
# Generated by Django 1.11.17 on 2019-12-03 19:28
from __future__ import unicode_literals
import core.lib.validators
......@@ -37,9 +37,9 @@ class Migration(migrations.Migration):
('status', models.IntegerField(default=0, validators=[django.core.validators.MaxValueValidator(2), django.core.validators.MinValueValidator(0)])),
('logo', models.FileField(blank=True, null=True, upload_to=core.models.accounts.get_company_logo_file_path, validators=[core.lib.validators.validate_image_file_extension])),
('address', models.CharField(blank=True, max_length=1000, null=True)),
('category', models.CharField(default='Belum ada kategori perusahaan', max_length=140)),
('category', models.CharField(default=b'Belum ada kategori perusahaan', max_length=140)),
('size', models.CharField(blank=True, default=0, max_length=10, null=True)),
('website', models.CharField(default='Belum ada link website', max_length=100)),
('website', models.CharField(default=b'Belum ada link website', max_length=100)),
('linkedin_url', models.URLField(blank=True, null=True)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
......@@ -52,7 +52,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created', models.DateTimeField(auto_now_add=True)),
('title', models.CharField(blank=True, default='', max_length=100)),
('title', models.CharField(blank=True, default=b'', max_length=100)),
('content', models.TextField()),
('companyId', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.Company')),
],
......@@ -79,16 +79,16 @@ class Migration(migrations.Migration):
('created', models.DateTimeField(auto_now_add=True)),
('updated', models.DateTimeField(auto_now=True)),
('npm', models.IntegerField(unique=True, validators=[core.lib.validators.validate_npm])),
('resume', models.FileField(blank=True, null=True, upload_to=core.models.accounts.get_student_resume_file_path, validators=[django.core.validators.FileExtensionValidator(['pdf'])])),
('resume', models.FileField(blank=True, null=True, upload_to=core.models.accounts.get_student_resume_file_path, validators=[django.core.validators.FileExtensionValidator([b'pdf'])])),
('sertifikat', models.FileField(blank=True, null=True, upload_to=core.models.accounts.get_student_sertifikat_file_path, validators=[core.lib.validators.validate_document_file_extension])),
('phone_number', models.CharField(blank=True, db_index=True, max_length=100, null=True, validators=[django.core.validators.RegexValidator('^0\\d{1,11}$')])),
('phone_number', models.CharField(blank=True, db_index=True, max_length=100, null=True, validators=[django.core.validators.RegexValidator(b'^0\\d{1,11}$')])),
('gender', models.CharField(blank=True, max_length=30, null=True)),
('birth_place', models.CharField(blank=True, max_length=30, null=True)),
('birth_date', models.DateField(blank=True, null=True)),
('major', models.CharField(blank=True, max_length=30, null=True)),
('batch', models.CharField(blank=True, max_length=4, null=True)),
('show_transcript', models.BooleanField(default=False)),
('photo', models.FileField(blank=True, null=True, upload_to=core.models.accounts.get_student_photo_file_path, validators=[django.core.validators.FileExtensionValidator(['jpg', 'jpeg', 'png'])])),
('photo', models.FileField(blank=True, null=True, upload_to=core.models.accounts.get_student_photo_file_path, validators=[django.core.validators.FileExtensionValidator([b'jpg', b'jpeg', b'png'])])),
('self_description', models.CharField(blank=True, db_index=True, max_length=500, null=True)),
('portfolio_link', models.URLField(blank=True, null=True)),
('linkedin_url', models.URLField(blank=True, null=True)),
......@@ -104,10 +104,10 @@ class Migration(migrations.Migration):
('github_url', models.URLField(blank=True, null=True)),
('gitlab_url', models.URLField(blank=True, null=True)),
('intro', models.CharField(blank=True, max_length=50, null=True)),
('expected_salary', models.CharField(blank=True, max_length=10, null=True, validators=[django.core.validators.RegexValidator('^\\d{0,10}$')])),
('expected_salary', models.CharField(blank=True, max_length=10, null=True, validators=[django.core.validators.RegexValidator(b'^\\d{0,10}$')])),
('job_seeking_status', models.CharField(blank=True, max_length=30, null=True)),
('student_gpa', models.FloatField(blank=True, db_column='student_gpa', default=1.0, null=True, validators=[core.lib.validators.validate_student_gpa])),
('student_toefl', models.CharField(blank=True, max_length=3, null=True)),
('student_gpa', models.FloatField(blank=True, db_column=b'student_gpa', default=1.0, null=True, validators=[core.lib.validators.validate_student_gpa])),
('student_toefl', models.IntegerField(blank=True, db_column=b'toefl', default=0, null=True)),
('volunteer', models.CharField(blank=True, max_length=100, null=True)),
('awards', models.CharField(blank=True, max_length=100, null=True)),
('projects', models.CharField(blank=True, max_length=100, null=True)),
......@@ -115,7 +115,7 @@ class Migration(migrations.Migration):
('languages', models.CharField(blank=True, max_length=100, null=True)),
('seminar', models.CharField(blank=True, max_length=100, null=True)),
('interests', models.CharField(blank=True, max_length=100, null=True)),
('dependants', models.IntegerField(blank=True, db_column='dependants', default=0, null=True)),
('dependants', models.IntegerField(blank=True, db_column=b'dependants', default=0, null=True)),
],
options={
'ordering': ['-updated'],
......@@ -154,6 +154,7 @@ class Migration(migrations.Migration):
('tag', models.TextField(blank=True)),
('salary', models.IntegerField(default=0)),
('recruiter_activity', models.CharField(blank=True, max_length=10, null=True)),
('office_address', models.TextField(blank=True, default=b'')),
('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='vacancies', to='core.Company')),
],
options={
......@@ -175,7 +176,7 @@ class Migration(migrations.Migration):
name='ReasonRejected',
fields=[
('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='core.Application')),
('reason', models.TextField(default='Tidak memenuhi kualifikasi perusahaan.')),
('reason', models.TextField(default=b'Tidak memenuhi kualifikasi perusahaan.')),
],
),
migrations.AddField(
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2019-12-03 03:51
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='student',
name='student_toefl',
field=models.IntegerField(blank=True, db_column='toefl', default=0, null=True),
),
]
......@@ -22,6 +22,7 @@ class Vacancy(models.Model):
tag = models.TextField(blank=True)
salary = models.IntegerField(default=0)
recruiter_activity = models.CharField(blank=True, max_length=10, null=True)
office_address= models.TextField(blank=True, default='')
@property
def apply_before(self):
......
......@@ -558,3 +558,85 @@ class CreateAndUpdateVacancyTest(APITestCase):
vacancy = Vacancy.objects.first()
self.assertEqual(vacancy.recruiter_activity, None)
def test_create_vacancy_with_office_address_success(self):
superuser = User.objects.create_superuser('dummy.company', 'dummy.company@company.com', 'lalala123')
new_company = Company.objects.create(user=superuser, description="lalalaz", status=Company.VERIFIED, logo=None,
address=None)
self.client.force_authenticate(user=superuser)
url = '/api/vacancies/'
response = self.client.post(url, {'company': new_company.pk, 'open_time': self.today,
'close_time': self.tomorrow, 'name': 'new vacancy',
'description': 'new_vacancy ', 'amount': 10, 'requirements': 'new_vacancy',
'max_accepted_applicants': 3, 'working_period': '3 Bulan',
'office_address': 'Freelance'}, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
vacancy = Vacancy.objects.first()
self.assertEqual(vacancy.office_address, 'Freelance')
def test_create_vacancy_with_office_address_fail_invalid_value_type(self):
superuser = User.objects.create_superuser('dummy.company', 'dummy.company@company.com', 'lalala123')
new_company = Company.objects.create(user=superuser, description="lalalaz", status=Company.VERIFIED, logo=None,
address=None)
self.client.force_authenticate(user=superuser)
url = '/api/vacancies/'
response = self.client.post(url, {'company': new_company.pk, 'open_time': self.today,
'close_time': self.tomorrow, 'name': 'new vacancy',
'description': 'new_vacancy ', 'amount': 10, 'requirements': 'new_vacancy',
'max_accepted_applicants': 3, 'working_period': '3 Bulan',
'office_address': 123}, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response.json()['error'], 'Office Address harus berupa string!')
vacancy_count = Vacancy.objects.count()
self.assertEqual(vacancy_count, 0)
def test_update_vacancy_with_office_address_success(self):
superuser = User.objects.create_superuser('dummy.company', 'dummy.company@company.com', 'lalala123')
new_company = Company.objects.create(user=superuser, description="lalalaz", status=Company.VERIFIED, logo=None,
address=None)
self.client.force_authenticate(user=superuser)
new_vacancy = Vacancy.objects.create(company=new_company, verified=False, open_time=self.today,
description="lalala", close_time=self.tomorrow, name='new_company',
max_accepted_applicants=3)
url = '/api/vacancies/' + str(new_vacancy.pk) + '/'
response = self.client.patch(url, {'company': new_company.pk, 'open_time': self.today,
'close_time': self.tomorrow, 'name': 'new vacancy',
'description': 'new_vacancy ', 'amount': 10,
'requirements': 'new_vacancy', 'responsibilities': 'new_vacancy',
'max_accepted_applicants': 3, 'working_period': '3 Bulan',
'office_address': 'Freelance'}, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
vacancy = Vacancy.objects.first()
self.assertEqual(vacancy.office_address, 'Freelance')
def test_update_vacancy_with_office_address_fail_invalid_value_type(self):
superuser = User.objects.create_superuser('dummy.company', 'dummy.company@company.com', 'lalala123')
new_company = Company.objects.create(user=superuser, description="lalalaz", status=Company.VERIFIED, logo=None,
address=None)
self.client.force_authenticate(user=superuser)
new_vacancy = Vacancy.objects.create(company=new_company, verified=False, open_time=self.today,
description="lalala", close_time=self.tomorrow, name='new_company',
max_accepted_applicants=3)
url = '/api/vacancies/' + str(new_vacancy.pk) + '/'
response = self.client.patch(url, {'company': new_company.pk, 'open_time': self.today,
'close_time': self.tomorrow, 'name': 'new vacancy',
'description': 'new_vacancy ', 'amount': 10,
'requirements': 'new_vacancy',
'max_accepted_applicants': 3, 'working_period': '3 Bulan',
'office_address': 123}, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response.json()['error'], 'Office Address harus berupa string!')
vacancy = Vacancy.objects.first()
self.assertEqual(vacancy.office_address, '')
......@@ -127,6 +127,13 @@ class VacancyViewSet(MultiSerializerViewSetMixin, viewsets.ModelViewSet):
except:
raise ValidationError(views_constants.ERROR_AMOUNT_MUST_NUMBER)
def office_address_validator(self, office_address):
print(office_address)
print(type(office_address))
if not isinstance(office_address, basestring):
print('DEBUG ERROR')
raise ValidationError(views_constants.ERROR_INVALID_OFFICE_ADDRESS)
def responsibilities_validator(self, responsibilities):
if not isinstance(responsibilities, basestring):
raise ValidationError(views_constants.ERROR_RESPONSIBILITIES_MUST_STRING)
......@@ -154,6 +161,7 @@ class VacancyViewSet(MultiSerializerViewSetMixin, viewsets.ModelViewSet):
views_constants.NAME: raw_data[views_constants.NAME],
views_constants.SALARY: raw_data.get(views_constants.SALARY, 0),
views_constants.TAG: raw_data.get(views_constants.TAG, ''),
views_constants.OFFICE_ADDRESS: raw_data.get(views_constants.OFFICE_ADDRESS, ''),
views_constants.REQUIREMENTS: raw_data.get(views_constants.REQUIREMENTS, ''),
views_constants.RESPONSIBILITIES: raw_data.get(views_constants.RESPONSIBILITIES, ''),
views_constants.BENEFITS: raw_data.get(views_constants.BENEFITS, ''),
......@@ -161,7 +169,7 @@ class VacancyViewSet(MultiSerializerViewSetMixin, viewsets.ModelViewSet):
views_constants.RECRUITER_ACTIVITY: raw_data.get(views_constants.RECRUITER_ACTIVITY, ''),
views_constants.DESCRIPTION: raw_data[views_constants.DESCRIPTION],
views_constants.WORKING_PERIOD: raw_data[views_constants.WORKING_PERIOD],
views_constants.MAX_ACCEPTED_APPLICANTS: raw_data[views_constants.MAX_ACCEPTED_APPLICANTS]
views_constants.MAX_ACCEPTED_APPLICANTS: raw_data[views_constants.MAX_ACCEPTED_APPLICANTS],
}
return data
......@@ -175,6 +183,8 @@ class VacancyViewSet(MultiSerializerViewSetMixin, viewsets.ModelViewSet):
self.responsibilities_validator(data[views_constants.RESPONSIBILITIES])
if data.get(views_constants.RECRUITER_ACTIVITY):
self.recruiter_activity_validator(data[views_constants.RECRUITER_ACTIVITY])
if data.get(views_constants.OFFICE_ADDRESS):
self.office_address_validator(data[views_constants.OFFICE_ADDRESS])
def create(self, request):
print("[LOG] data: " + str(request.data))
......
......@@ -7,6 +7,7 @@ ERROR_AMOUNT_MUST_NUMBER = 'Amount must number only'
ERROR_RESPONSIBILITIES_MUST_STRING = 'Responsibilities must be string'
ERROR_INVALID_RECRUITER_RESPONSE = 'Tingkat Respons Perekrut harus salah satu dari Selalu, Sering, Kadang, Jarang, ' \
'dan Tidak Pernah!'
ERROR_INVALID_OFFICE_ADDRESS = 'Office Address harus berupa string!'
ERROR_VACANCY_ALREADY_APPLIED = 'You have already applied for the vacancy'
ERROR_COMPANY_DOES_NOT_EXIST = 'No company exists with that ID'
ERROR_VACANCY_CLOSED = 'vacancy is closed'
......@@ -54,6 +55,7 @@ ERROR = 'error'
IS_VALID = 'is_valid'
MAX_ACCEPTED_APPLICANTS = 'max_accepted_applicants'
NAME = 'name'
OFFICE_ADDRESS = 'office_address'
OPEN_TIME = 'open_time'
OPENED_ONLY = 'opened_only'
ORDERING = 'order'
......
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