Fakultas Ilmu Komputer UI

Commit 3be1c46d authored by Bram Sedana Wehantouw's avatar Bram Sedana Wehantouw
Browse files

1606824502 72 Added new field to vacancy

parent 20d36906
......@@ -102,6 +102,7 @@ export default class CreateVacancy extends React.Component {
data.salary = this.state.salary;
data.open_time = this.state.open_time.format();
data.close_time = this.state.close_time.format();
data.max_accepted_applicants = this.state.max_accepted_applicants;
data.working_period = this.state.working_period;
if (!this.state.vacancyId) {
data.company = this.state.company.id;
......@@ -140,6 +141,7 @@ export default class CreateVacancy extends React.Component {
<CKEditor value={this.state.responsibilities} onChange={this.handleResponsibilities} /> }
<script>CKEDITOR.replace( 'responsibilities' );</script>
<br />
<Form.Field label="Jumlah yang Diterima" name="max_accepted_applicants" control={Input} onChange={this.handleChange} value={this.state.max_accepted_applicants} required />
<label htmlFor="benefits"> <b> Keuntungan </b> </label>
{ !this.state.loading && <CKEditor value={this.state.benefits} onChange={this.handleBenefits} /> }
<script>CKEDITOR.replace( 'benefits' );</script>
......
......@@ -25,6 +25,8 @@ describe('Vacancy', () => {
updated: '2017-03-28T07:34:13.122093Z',
working_period: 'Juli-Agustus',
verified: true,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
};
const response2 = {
......@@ -46,6 +48,8 @@ describe('Vacancy', () => {
updated: '2017-03-28T07:34:13.122093Z',
working_period: 'Oktober-Desember',
verified: true,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
};
const studentUser = {
......
......@@ -148,6 +148,8 @@ describe('VacancyList', () => {
status: 0,
bookmarked: false,
id: 4,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
working_period: 'Juli-Agustus',
},
{
......@@ -182,6 +184,8 @@ describe('VacancyList', () => {
status: 1,
bookmarked: false,
id: 4,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
working_period: 'Juli-Agustus',
},
{
......@@ -216,6 +220,8 @@ describe('VacancyList', () => {
status: 2,
bookmarked: true,
id: 4,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
working_period: 'Juli-Agustus',
},
{
......@@ -250,6 +256,8 @@ describe('VacancyList', () => {
status: 3,
bookmarked: true,
id: 4,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
working_period: 'Juli-Agustus',
},
{
......@@ -284,6 +292,8 @@ describe('VacancyList', () => {
status: 4,
bookmarked: true,
id: 4,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
working_period: 'Juli-Agustus',
},
];
......@@ -306,6 +316,8 @@ describe('VacancyList', () => {
open_time: '2017-03-28T05:55:38Z',
updated: '2017-03-28T07:34:13.122093Z',
verified: true,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
working_period: 'Juli-Agustus',
}, {
salary: '1',
......@@ -325,6 +337,8 @@ describe('VacancyList', () => {
open_time: '2017-03-28T05:55:38Z',
updated: '2017-03-28T07:34:13.122093Z',
verified: true,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
working_period: 'Juli-Agustus',
}];
......@@ -346,6 +360,8 @@ describe('VacancyList', () => {
open_time: '2017-03-28T05:55:38Z',
updated: '2017-03-28T07:34:13.122093Z',
verified: true,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
working_period: 'Juli-Agustus',
}];
......
......@@ -37,6 +37,7 @@ export default class CompanyVacancy extends React.Component {
<Grid.Column floated="left">
<p>{ this.state.count } Pendaftar<br/>
{ this.state.countNew } Pendaftar Baru<br/><br/>
{ this.props.data.total_accepted_applicants } / {this.props.data.max_accepted_applicants } Diterima<br/>
Ditutup {moment(moment(this.props.data.close_time)).fromNow()}</p>
</Grid.Column>
<Grid.Column floated="right">
......
......@@ -139,6 +139,10 @@ export default class Vacancy extends React.Component {
{ this.props.data.company.address }<br />
{ this.props.data.working_period}<br />
{ this.state.count } orang telah mendaftar!<br />
<b>
{ this.props.data.total_accepted_applicants }
/ { this.props.data.max_accepted_applicants }
diterima </b><br />
<b>{`Ditutup ${moment(moment(this.props.data.close_time)).fromNow()}`}</b><br />
Rp. { this.props.data.salary } <br />
<b>{this.props.data.apply_before}</b>
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2019-10-12 15:05
# Generated by Django 1.11.17 on 2019-10-12 16:28
from __future__ import unicode_literals
from django.db import migrations, models
......@@ -17,4 +17,10 @@ class Migration(migrations.Migration):
name='benefits',
field=models.TextField(blank=True),
),
migrations.AddField(
model_name='vacancy',
name='max_accepted_applicants',
field=models.IntegerField(default=3),
preserve_default=False,
),
]
......@@ -16,6 +16,7 @@ class Vacancy(models.Model):
updated = models.DateTimeField(auto_now=True)
name = models.CharField(max_length=100, null=False)
amount = models.IntegerField(null=True)
max_accepted_applicants = models.IntegerField()
benefits = models.TextField(blank=True)
working_period = models.CharField(max_length=100, null=True)
tag = models.TextField(blank=True)
......
......@@ -9,7 +9,11 @@ class VacancySerializer(serializers.ModelSerializer):
company = CompanySerializer()
status = serializers.SerializerMethodField('_get_app_status')
bookmarked = serializers.SerializerMethodField('_get_bookmarked_status')
total_accepted_applicants = serializers.SerializerMethodField('_get_total_accepted_applicants')
def _get_total_accepted_applicants(self, instance):
return len(Application.objects.filter(vacancy = instance, status = 4))
def _get_app_status(self, instance):
try:
request = self.context.get("request")
......@@ -33,7 +37,7 @@ class VacancySerializer(serializers.ModelSerializer):
class Meta:
model = Vacancy
fields = ['company', 'verified', 'open_time', 'description', 'close_time', 'created','apply_before', 'updated', 'name', \
'status', 'bookmarked', 'id', 'salary', 'responsibilities', 'requirements','working_period', 'benefits']
'status', 'bookmarked', 'id', 'salary', 'responsibilities', 'requirements','working_period', 'benefits', 'max_accepted_applicants', 'total_accepted_applicants']
def name_position_validator(names):
for name in names.split(" "):
......
......@@ -23,7 +23,8 @@ class CreateAndUpdateVacancyTest(APITestCase):
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', 'requirements': 'new_vacancy', 'working_period':'3 Bulan'}, format='json')
'close_time': self.tomorrow, 'name': 'new vacancy', 'description': 'new_vacancy ', 'requirements': 'new_vacancy',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
vacancies = Vacancy.objects.count()
......@@ -38,7 +39,8 @@ class CreateAndUpdateVacancyTest(APITestCase):
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', 'working_period':'3 Bulan'}, format='json')
'description': 'new_vacancy ', 'amount': 10, 'requirements': 'new_vacancy',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
vacancy = Vacancy.objects.first()
......@@ -54,7 +56,8 @@ class CreateAndUpdateVacancyTest(APITestCase):
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, 'responsibilities': 'new_vacancy', 'requirements':'new_vacancy', 'working_period':'3 Bulan'}, format='json')
'description': 'new_vacancy ', 'amount': 10, 'responsibilities': 'new_vacancy', 'requirements':'new_vacancy',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
vacancy = Vacancy.objects.first()
......@@ -69,7 +72,8 @@ class CreateAndUpdateVacancyTest(APITestCase):
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, 'benefits':'new_vacancy', 'requirements': 'new_vacancy', 'working_period':'3 Bulan'}, format='json')
'description': 'new_vacancy ', 'amount': 10, 'benefits':'new_vacancy', 'requirements': 'new_vacancy',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
print(response)
self.assertEqual(response.status_code, status.HTTP_200_OK)
......@@ -84,7 +88,8 @@ class CreateAndUpdateVacancyTest(APITestCase):
url = '/api/vacancies/'
response = self.client.post(url, {'company': new_company.pk, 'open_time': self.today,
'close_time': self.yesterday, 'name': 'new_vacancy', 'description': 'new_vacancy', 'responsibilities': 'new_vacancy', 'requirements': 'new_vacancy', 'working_period':'3 Bulan'}, format='json')
'close_time': self.yesterday, 'name': 'new_vacancy', 'description': 'new_vacancy', 'responsibilities': 'new_vacancy', 'requirements': 'new_vacancy',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
vacancies = Vacancy.objects.count()
......@@ -99,7 +104,8 @@ class CreateAndUpdateVacancyTest(APITestCase):
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': 'sepuluh', 'salary':'dua juta', 'requirements': 'new_vacancy', 'working_period':'3 Bulan'}, format='json')
'description': 'new_vacancy ', 'amount': 'sepuluh', 'salary':'dua juta', 'requirements': 'new_vacancy',
'max_accepted_applicants':3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
vacancies_count = Vacancy.objects.count()
......@@ -114,7 +120,8 @@ class CreateAndUpdateVacancyTest(APITestCase):
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': 'sepuluh', 'benefits':'new_vacancy', 'working_period':'3 Bulan'}, format='json')
'description': 'new_vacancy ', 'amount': 'sepuluh', 'benefits':'new_vacancy',
'max_accepted_applicants':3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
vacancies_count = Vacancy.objects.count()
......@@ -127,11 +134,12 @@ class CreateAndUpdateVacancyTest(APITestCase):
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')
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, {'open_time': self.today, 'close_time': self.tomorrow,
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'responsibilities': 'new_vacancy2', 'requirements': 'new_vacancy2', 'working_period':'3 Bulan'}, format='json')
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'responsibilities': 'new_vacancy2', 'requirements': 'new_vacancy2',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_update_vacancy_with_amount_salary_success(self):
......@@ -141,11 +149,12 @@ class CreateAndUpdateVacancyTest(APITestCase):
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')
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, {'open_time': self.today, 'close_time': self.tomorrow,
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 10, 'salary': 2, 'responsibilities': 'new_vacancy2', 'requirements': 'new_vacancy2', 'working_period':'3 Bulan'}, format='json')
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 10, 'salary': 2, 'responsibilities': 'new_vacancy2', 'requirements': 'new_vacancy2',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
vacancy = Vacancy.objects.first()
......@@ -158,10 +167,10 @@ class CreateAndUpdateVacancyTest(APITestCase):
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')
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, {'open_time': self.today, 'close_time': self.tomorrow, 'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 10, 'benefits':'new_vacancy2', 'responsibilities': 'new_vacancy2', 'requirements': 'new_vacancy', 'working_period':'3 Bulan'}, format='json')
response = self.client.patch(url, {'open_time': self.today, 'close_time': self.tomorrow, 'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 10, 'benefits':'new_vacancy2', 'responsibilities': 'new_vacancy2', 'requirements': 'new_vacancy', 'working_period':'3 Bulan', 'max_accepted_applicants': 3}, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
vacancy = Vacancy.objects.first()
......@@ -175,11 +184,12 @@ class CreateAndUpdateVacancyTest(APITestCase):
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')
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, {'open_time': self.today, 'close_time': self.tomorrow,
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 10, 'responsibilities': 'new_vacancy2', 'requirements': 'new_vacancy2', 'working_period':'3 Bulan'}, format='json')
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 10, 'responsibilities': 'new_vacancy2', 'requirements': 'new_vacancy2',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
vacancy = Vacancy.objects.first()
......@@ -192,11 +202,12 @@ class CreateAndUpdateVacancyTest(APITestCase):
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')
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, {'open_time': self.today, 'close_time': self.yesterday,
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'responsibilities': 'new_vacancy2', 'requirements': 'new_vacancy2', 'working_period':'3 Bulan'}, format='json')
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'responsibilities': 'new_vacancy2', 'requirements': 'new_vacancy2',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_update_vacancy_with_amount_salary_string_failed(self):
......@@ -206,11 +217,13 @@ class CreateAndUpdateVacancyTest(APITestCase):
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')
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, {'open_time': self.today, 'close_time': self.yesterday,
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 'sepuluh', 'salary': 'dua juta', 'requirements': 'new_vacancy', 'working_period':'3 Bulan'}, format='json')
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 'sepuluh', 'salary': 'dua juta', 'requirements': 'new_vacancy',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
vacancy = Vacancy.objects.first()
......@@ -224,7 +237,8 @@ class CreateAndUpdateVacancyTest(APITestCase):
url = '/api/vacancies/'
response = self.client.post(url, {'company': new_company.pk, 'open_time': self.today,
'close_time': self.today, 'name': 'new_vacancy', 'description': 'new_vacancy', 'working_period':'3 Bulan'}, format='json')
'close_time': self.today, 'name': 'new_vacancy', 'description': 'new_vacancy',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
......@@ -239,7 +253,8 @@ class CreateAndUpdateVacancyTest(APITestCase):
url = '/api/vacancies/'
response = self.client.post(url, {'company': new_company.pk, 'open_time': datetime.fromtimestamp(0),
'close_time': datetime.fromtimestamp(0), 'name': 'new_vacancy', 'description': 'new_vacancy', 'working_period':'3 Bulan'}, format='json')
'close_time': datetime.fromtimestamp(0), 'name': 'new_vacancy', 'description': 'new_vacancy',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
......@@ -253,11 +268,13 @@ class CreateAndUpdateVacancyTest(APITestCase):
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')
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, {'open_time': self.today, 'close_time': self.today,
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'requirements': 'new_vacancy2', 'working_period':'3 Bulan'}, format='json')
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'requirements': 'new_vacancy2',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
......@@ -268,12 +285,13 @@ class CreateAndUpdateVacancyTest(APITestCase):
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')
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, {'open_time': datetime.fromtimestamp(0), 'close_time': datetime.fromtimestamp(0),
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 'sepuluh', 'requirements': 'new_vacancy2', 'working_period':'3 Bulan'}, format='json')
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 'sepuluh', 'requirements': 'new_vacancy2',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
vacancy = Vacancy.objects.first()
......@@ -286,10 +304,10 @@ class CreateAndUpdateVacancyTest(APITestCase):
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')
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, {'open_time': self.today, 'close_time': self.tomorrow,'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 'sepuluh', 'benefits':'new_vacancy2', 'requirements': 'new_vacancy', 'working_period':'3 Bulan'}, format='json')
response = self.client.patch(url, {'open_time': self.today, 'close_time': self.tomorrow,'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 'sepuluh', 'benefits':'new_vacancy2', 'requirements': 'new_vacancy', 'working_period':'3 Bulan', 'max_accepted_applicants': 3}, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
vacancy = Vacancy.objects.first()
......@@ -302,11 +320,12 @@ class CreateAndUpdateVacancyTest(APITestCase):
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')
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, {'open_time': self.today, 'close_time': self.tomorrow,
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'responsibilities': 'new_vacancy2', 'amount': 'sepuluh', 'requirements': 'new_vacancy2', 'working_period':'3 Bulan'}, format='json')
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'responsibilities': 'new_vacancy2', 'amount': 'sepuluh', 'requirements': 'new_vacancy2',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
vacancy = Vacancy.objects.first()
......@@ -320,7 +339,8 @@ class CreateAndUpdateVacancyTest(APITestCase):
url = '/api/vacancies/'
response = self.client.post(url, {'company': new_company.pk, 'open_time': self.yesterday,
'close_time': self.today, 'name': 'new_vacancy', 'description': 'new_vacancy', 'responsibilities': 'new_vacancy', 'requirements': 'new_vacancy', 'working_period':'3 Bulan'}, format='json')
'close_time': self.today, 'name': 'new_vacancy', 'description': 'new_vacancy', 'responsibilities': 'new_vacancy', 'requirements': 'new_vacancy',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
vacancies = Vacancy.objects.count()
......@@ -333,11 +353,12 @@ class CreateAndUpdateVacancyTest(APITestCase):
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')
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, {'open_time': self.yesterday, 'close_time': self.today,
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'responsibilities': 'new_vacancy2', 'requirements': 'new_vacancy2','working_period':'3 Bulan'}, format='json')
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'responsibilities': 'new_vacancy2', 'requirements': 'new_vacancy2',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_new_vacancy_with_tag(self):
......@@ -350,11 +371,12 @@ class CreateAndUpdateVacancyTest(APITestCase):
new_vacancy = Vacancy.objects.create(company=new_company, verified=False, open_time= self.today,
description="lalala", close_time=self.tomorrow, name='new_company',
tag=VACANCY_TAG, working_period="3 Bulan")
tag=VACANCY_TAG, max_accepted_applicants=3, working_period="3 Bulan")
url = '/api/vacancies/' + str(new_vacancy.pk) + '/'
response = self.client.patch(url, {'open_time': self.today, 'close_time': self.tomorrow,
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 10, 'responsibilities': 'new_vacancy2', 'requirements': 'new_vacancy2','working_period':'3 Bulan'}, format='json')
'name': 'new_vacancy2', 'description': 'new_vacancy2', 'amount': 10, 'responsibilities': 'new_vacancy2', 'requirements': 'new_vacancy2',
'max_accepted_applicants': 3, 'working_period':'3 Bulan'}, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
vacancy = Vacancy.objects.first()
......
......@@ -112,7 +112,7 @@ class ApplicationTests(APITestCase):
new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None,
address=None)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0),
description="lalala",working_period="3 Bulan", requirements= "requirements", close_time=(timezone.now() + timedelta(days=1)))
description="lalala", max_accepted_applicants=3, working_period="3 Bulan", requirements= "requirements", close_time=(timezone.now() + timedelta(days=1)))
url = '/api/students/' + str(student_id) + '/applied-vacancies/'
response = self.client.post(url, {'vacancy_id': new_vacancy.pk, 'cover_letter': 'this is a cover letter.'},
......@@ -135,7 +135,7 @@ class ApplicationTests(APITestCase):
new_student = Student.objects.create(user=new_user2, npm=1234123412)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(0),
description="lalala",working_period="3 Bulan" ,close_time=datetime.today())
description="lalala", close_time=datetime.today(), max_accepted_applicants=3, working_period="3 Bulan")
application = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="lorem ipsum")
......@@ -157,7 +157,7 @@ class ApplicationTests(APITestCase):
address=None)
new_student = Student.objects.create(user=new_user2, npm=1234123412)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(0),
description="lalala", working_period="3 Bulan",close_time=datetime.today())
description="lalala", close_time=datetime.today(), max_accepted_applicants=3, working_period="3 Bulan")
url = '/api/applications/' + str(new_vacancy.pk) + '/count/'
......@@ -196,7 +196,7 @@ class ApplicationTests(APITestCase):
new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None,
address=None)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(0),
description="lalala", working_period="3 Bulan",close_time=(timezone.now() - timedelta(days=1)))
description="lalala", close_time=(timezone.now() - timedelta(days=1)), max_accepted_applicants=3, working_period="3 Bulan")
url = '/api/students/' + str(student_id) + '/applied-vacancies/'
response = self.client.post(url, {'vacancy_id': new_vacancy.pk, 'cover_letter': 'this is a cover letter.'},
format='json')
......@@ -308,7 +308,7 @@ class BookmarkApplicationTests(APITestCase):
new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None,
address=None)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, requirements= "requirements", open_time=datetime.fromtimestamp(1541319300.0),
description="lalala", working_period="3 Bulan",close_time=timezone.now())
description="lalala", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan")
url = '/api/students/' + str(student_id) + '/bookmarked-vacancies/'
response = self.client.post(url, {'vacancy_id': new_vacancy.pk}, format='json')
......@@ -332,8 +332,8 @@ class VacancyTest(APITestCase):
def test_search_vacancy(self, m):
superuser = User.objects.create_user('dummy.company', 'dummy.company@company.com', 'lalala123')
company = Company.objects.create(user=superuser, description="This is a test company")
Vacancy.objects.create(company=company, open_time=datetime.now(), close_time=datetime.now(), name="Software Engineer",working_period="3 Bulan")
Vacancy.objects.create(company=company, open_time=datetime.now(), close_time=datetime.now(), name="Data Engineer",working_period="3 Bulan")
Vacancy.objects.create(company=company, open_time=datetime.now(), close_time=datetime.now(), name="Software Engineer", max_accepted_applicants=3, working_period="3 Bulan")
Vacancy.objects.create(company=company, open_time=datetime.now(), close_time=datetime.now(), name="Data Engineer", max_accepted_applicants=3, working_period="3 Bulan")
m.get('https://akun.cs.ui.ac.id/oauth/token/verify/?client_id=X3zNkFmepkdA47ASNMDZRX3Z9gqSU1Lwywu5WepG',
json={"username": 'dummy.mahasiswa', "role": 'mahasiswa', "identity_number": '1234567890'},
status_code=200)
......@@ -389,9 +389,9 @@ class VacancyTest(APITestCase):
open_time = datetime(2019, 10, 20)
close_time = datetime(2019, 12, 20)
vacancy1 = Vacancy.objects.create(company=new_company, verified=True, open_time=open_time,
description='', close_time=close_time, name='vacancy1',working_period="3 Bulan")
description='', close_time=close_time, name='vacancy1', max_accepted_applicants=3, working_period="3 Bulan")
vacancy2 = Vacancy.objects.create(company=new_company2, verified=True, open_time=open_time,
description='', close_time=close_time, name='vacancy2',working_period="3 Bulan")
description='', close_time=close_time, name='vacancy2', max_accepted_applicants=3, working_period="3 Bulan")
url = '/api/vacancies/?company={}&company={}'.format(new_company.id, new_company2.id)
response = self.client.get(url, format='json')
vacancies = Vacancy.objects.filter(company__id__in=[new_company.id, new_company2.id])
......@@ -451,7 +451,7 @@ class VacancyTest(APITestCase):
new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None,
address=None)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0),
description="expired vacancy", close_time=datetime.fromtimestamp(1541319301.0),working_period="3 Bulan")
description="expired vacancy", close_time=datetime.fromtimestamp(1541319301.0), max_accepted_applicants=3, working_period="3 Bulan")
url = '/api/vacancies/?opened_only=true'
response = self.client.get(url, format='json')
......@@ -478,7 +478,8 @@ class VacancyTest(APITestCase):
address=None)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(0),
description="lalala", close_time=timezone.now() + timedelta(minutes = 10),working_period="3 Bulan")
description="lalala", close_time=timezone.now() + timedelta(minutes = 10),
max_accepted_applicants=3, working_period="3 Bulan")
self.client.force_authenticate(user=superuser)
response = new_vacancy.apply_before
......@@ -562,7 +563,7 @@ class CompanyListsTests(APITestCase):
new_student = Student.objects.create(user=new_user2, npm=1234123412)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0),
description="lalala", requirements= "requirements", close_time=timezone.now(),working_period="3 Bulan")
description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan")
new_app = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd")
self.client.force_authenticate(new_user)
......@@ -580,7 +581,7 @@ class CompanyListsTests(APITestCase):
new_student = Student.objects.create(user=new_user2, npm=1234123412)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0),
description="lalala", requirements= "requirements", close_time=timezone.now(),working_period="3 Bulan")
description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan")
new_app = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd")
new_user3 = User.objects.create_user('dummy.company4', 'dummy.company4@company.com', 'lalala123')
......@@ -602,7 +603,7 @@ class CompanyListsTests(APITestCase):
new_student = Student.objects.create(user=new_user2, npm=1234123412)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0),
description="lalala", requirements= "requirements", close_time=timezone.now(),working_period="3 Bulan")
description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3, working_period="3 Bulan")
new_app = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd")
new_user3 = User.objects.create_user('dummy.company4', 'dummy.company4@company.com', 'lalala123')
......@@ -624,7 +625,7 @@ class CompanyListsTests(APITestCase):
new_student = Student.objects.create(user=new_user2, npm=1234123412)