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 { ...@@ -102,6 +102,7 @@ export default class CreateVacancy extends React.Component {
data.salary = this.state.salary; data.salary = this.state.salary;
data.open_time = this.state.open_time.format(); data.open_time = this.state.open_time.format();
data.close_time = this.state.close_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; data.working_period = this.state.working_period;
if (!this.state.vacancyId) { if (!this.state.vacancyId) {
data.company = this.state.company.id; data.company = this.state.company.id;
...@@ -140,6 +141,7 @@ export default class CreateVacancy extends React.Component { ...@@ -140,6 +141,7 @@ export default class CreateVacancy extends React.Component {
<CKEditor value={this.state.responsibilities} onChange={this.handleResponsibilities} /> } <CKEditor value={this.state.responsibilities} onChange={this.handleResponsibilities} /> }
<script>CKEDITOR.replace( 'responsibilities' );</script> <script>CKEDITOR.replace( 'responsibilities' );</script>
<br /> <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> <label htmlFor="benefits"> <b> Keuntungan </b> </label>
{ !this.state.loading && <CKEditor value={this.state.benefits} onChange={this.handleBenefits} /> } { !this.state.loading && <CKEditor value={this.state.benefits} onChange={this.handleBenefits} /> }
<script>CKEDITOR.replace( 'benefits' );</script> <script>CKEDITOR.replace( 'benefits' );</script>
......
...@@ -25,6 +25,8 @@ describe('Vacancy', () => { ...@@ -25,6 +25,8 @@ describe('Vacancy', () => {
updated: '2017-03-28T07:34:13.122093Z', updated: '2017-03-28T07:34:13.122093Z',
working_period: 'Juli-Agustus', working_period: 'Juli-Agustus',
verified: true, verified: true,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
}; };
const response2 = { const response2 = {
...@@ -46,6 +48,8 @@ describe('Vacancy', () => { ...@@ -46,6 +48,8 @@ describe('Vacancy', () => {
updated: '2017-03-28T07:34:13.122093Z', updated: '2017-03-28T07:34:13.122093Z',
working_period: 'Oktober-Desember', working_period: 'Oktober-Desember',
verified: true, verified: true,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
}; };
const studentUser = { const studentUser = {
......
...@@ -148,6 +148,8 @@ describe('VacancyList', () => { ...@@ -148,6 +148,8 @@ describe('VacancyList', () => {
status: 0, status: 0,
bookmarked: false, bookmarked: false,
id: 4, id: 4,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
working_period: 'Juli-Agustus', working_period: 'Juli-Agustus',
}, },
{ {
...@@ -182,6 +184,8 @@ describe('VacancyList', () => { ...@@ -182,6 +184,8 @@ describe('VacancyList', () => {
status: 1, status: 1,
bookmarked: false, bookmarked: false,
id: 4, id: 4,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
working_period: 'Juli-Agustus', working_period: 'Juli-Agustus',
}, },
{ {
...@@ -216,6 +220,8 @@ describe('VacancyList', () => { ...@@ -216,6 +220,8 @@ describe('VacancyList', () => {
status: 2, status: 2,
bookmarked: true, bookmarked: true,
id: 4, id: 4,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
working_period: 'Juli-Agustus', working_period: 'Juli-Agustus',
}, },
{ {
...@@ -250,6 +256,8 @@ describe('VacancyList', () => { ...@@ -250,6 +256,8 @@ describe('VacancyList', () => {
status: 3, status: 3,
bookmarked: true, bookmarked: true,
id: 4, id: 4,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
working_period: 'Juli-Agustus', working_period: 'Juli-Agustus',
}, },
{ {
...@@ -284,6 +292,8 @@ describe('VacancyList', () => { ...@@ -284,6 +292,8 @@ describe('VacancyList', () => {
status: 4, status: 4,
bookmarked: true, bookmarked: true,
id: 4, id: 4,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
working_period: 'Juli-Agustus', working_period: 'Juli-Agustus',
}, },
]; ];
...@@ -306,6 +316,8 @@ describe('VacancyList', () => { ...@@ -306,6 +316,8 @@ describe('VacancyList', () => {
open_time: '2017-03-28T05:55:38Z', open_time: '2017-03-28T05:55:38Z',
updated: '2017-03-28T07:34:13.122093Z', updated: '2017-03-28T07:34:13.122093Z',
verified: true, verified: true,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
working_period: 'Juli-Agustus', working_period: 'Juli-Agustus',
}, { }, {
salary: '1', salary: '1',
...@@ -325,6 +337,8 @@ describe('VacancyList', () => { ...@@ -325,6 +337,8 @@ describe('VacancyList', () => {
open_time: '2017-03-28T05:55:38Z', open_time: '2017-03-28T05:55:38Z',
updated: '2017-03-28T07:34:13.122093Z', updated: '2017-03-28T07:34:13.122093Z',
verified: true, verified: true,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
working_period: 'Juli-Agustus', working_period: 'Juli-Agustus',
}]; }];
...@@ -346,6 +360,8 @@ describe('VacancyList', () => { ...@@ -346,6 +360,8 @@ describe('VacancyList', () => {
open_time: '2017-03-28T05:55:38Z', open_time: '2017-03-28T05:55:38Z',
updated: '2017-03-28T07:34:13.122093Z', updated: '2017-03-28T07:34:13.122093Z',
verified: true, verified: true,
max_accepted_applicants: 3,
total_accepted_applicants: 0,
working_period: 'Juli-Agustus', working_period: 'Juli-Agustus',
}]; }];
......
...@@ -37,6 +37,7 @@ export default class CompanyVacancy extends React.Component { ...@@ -37,6 +37,7 @@ export default class CompanyVacancy extends React.Component {
<Grid.Column floated="left"> <Grid.Column floated="left">
<p>{ this.state.count } Pendaftar<br/> <p>{ this.state.count } Pendaftar<br/>
{ this.state.countNew } Pendaftar Baru<br/><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> Ditutup {moment(moment(this.props.data.close_time)).fromNow()}</p>
</Grid.Column> </Grid.Column>
<Grid.Column floated="right"> <Grid.Column floated="right">
......
...@@ -139,6 +139,10 @@ export default class Vacancy extends React.Component { ...@@ -139,6 +139,10 @@ export default class Vacancy extends React.Component {
{ this.props.data.company.address }<br /> { this.props.data.company.address }<br />
{ this.props.data.working_period}<br /> { this.props.data.working_period}<br />
{ this.state.count } orang telah mendaftar!<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 /> <b>{`Ditutup ${moment(moment(this.props.data.close_time)).fromNow()}`}</b><br />
Rp. { this.props.data.salary } <br /> Rp. { this.props.data.salary } <br />
<b>{this.props.data.apply_before}</b> <b>{this.props.data.apply_before}</b>
......
# -*- coding: utf-8 -*- # -*- 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 __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models
...@@ -17,4 +17,10 @@ class Migration(migrations.Migration): ...@@ -17,4 +17,10 @@ class Migration(migrations.Migration):
name='benefits', name='benefits',
field=models.TextField(blank=True), 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): ...@@ -16,6 +16,7 @@ class Vacancy(models.Model):
updated = models.DateTimeField(auto_now=True) updated = models.DateTimeField(auto_now=True)
name = models.CharField(max_length=100, null=False) name = models.CharField(max_length=100, null=False)
amount = models.IntegerField(null=True) amount = models.IntegerField(null=True)
max_accepted_applicants = models.IntegerField()
benefits = models.TextField(blank=True) benefits = models.TextField(blank=True)
working_period = models.CharField(max_length=100, null=True) working_period = models.CharField(max_length=100, null=True)
tag = models.TextField(blank=True) tag = models.TextField(blank=True)
......
...@@ -9,7 +9,11 @@ class VacancySerializer(serializers.ModelSerializer): ...@@ -9,7 +9,11 @@ class VacancySerializer(serializers.ModelSerializer):
company = CompanySerializer() company = CompanySerializer()
status = serializers.SerializerMethodField('_get_app_status') status = serializers.SerializerMethodField('_get_app_status')
bookmarked = serializers.SerializerMethodField('_get_bookmarked_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): def _get_app_status(self, instance):
try: try:
request = self.context.get("request") request = self.context.get("request")
...@@ -33,7 +37,7 @@ class VacancySerializer(serializers.ModelSerializer): ...@@ -33,7 +37,7 @@ class VacancySerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Vacancy model = Vacancy
fields = ['company', 'verified', 'open_time', 'description', 'close_time', 'created','apply_before', 'updated', 'name', \ 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): def name_position_validator(names):
for name in names.split(" "): for name in names.split(" "):
......
This diff is collapsed.
...@@ -112,7 +112,7 @@ class ApplicationTests(APITestCase): ...@@ -112,7 +112,7 @@ class ApplicationTests(APITestCase):
new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None, new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None,
address=None) address=None)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0), 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/' 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.'}, response = self.client.post(url, {'vacancy_id': new_vacancy.pk, 'cover_letter': 'this is a cover letter.'},
...@@ -135,7 +135,7 @@ class ApplicationTests(APITestCase): ...@@ -135,7 +135,7 @@ class ApplicationTests(APITestCase):
new_student = Student.objects.create(user=new_user2, npm=1234123412) 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), 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") application = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="lorem ipsum")
...@@ -157,7 +157,7 @@ class ApplicationTests(APITestCase): ...@@ -157,7 +157,7 @@ class ApplicationTests(APITestCase):
address=None) address=None)
new_student = Student.objects.create(user=new_user2, npm=1234123412) 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), 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/' url = '/api/applications/' + str(new_vacancy.pk) + '/count/'
...@@ -196,7 +196,7 @@ class ApplicationTests(APITestCase): ...@@ -196,7 +196,7 @@ class ApplicationTests(APITestCase):
new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None, new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None,
address=None) address=None)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(0), 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/' 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.'}, response = self.client.post(url, {'vacancy_id': new_vacancy.pk, 'cover_letter': 'this is a cover letter.'},
format='json') format='json')
...@@ -308,7 +308,7 @@ class BookmarkApplicationTests(APITestCase): ...@@ -308,7 +308,7 @@ class BookmarkApplicationTests(APITestCase):
new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None, new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None,
address=None) address=None)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, requirements= "requirements", open_time=datetime.fromtimestamp(1541319300.0), 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/' url = '/api/students/' + str(student_id) + '/bookmarked-vacancies/'
response = self.client.post(url, {'vacancy_id': new_vacancy.pk}, format='json') response = self.client.post(url, {'vacancy_id': new_vacancy.pk}, format='json')
...@@ -332,8 +332,8 @@ class VacancyTest(APITestCase): ...@@ -332,8 +332,8 @@ class VacancyTest(APITestCase):
def test_search_vacancy(self, m): def test_search_vacancy(self, m):
superuser = User.objects.create_user('dummy.company', 'dummy.company@company.com', 'lalala123') superuser = User.objects.create_user('dummy.company', 'dummy.company@company.com', 'lalala123')
company = Company.objects.create(user=superuser, description="This is a test company") 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="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",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', m.get('https://akun.cs.ui.ac.id/oauth/token/verify/?client_id=X3zNkFmepkdA47ASNMDZRX3Z9gqSU1Lwywu5WepG',
json={"username": 'dummy.mahasiswa', "role": 'mahasiswa', "identity_number": '1234567890'}, json={"username": 'dummy.mahasiswa', "role": 'mahasiswa', "identity_number": '1234567890'},
status_code=200) status_code=200)
...@@ -389,9 +389,9 @@ class VacancyTest(APITestCase): ...@@ -389,9 +389,9 @@ class VacancyTest(APITestCase):
open_time = datetime(2019, 10, 20) open_time = datetime(2019, 10, 20)
close_time = datetime(2019, 12, 20) close_time = datetime(2019, 12, 20)
vacancy1 = Vacancy.objects.create(company=new_company, verified=True, open_time=open_time, 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, 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) url = '/api/vacancies/?company={}&company={}'.format(new_company.id, new_company2.id)
response = self.client.get(url, format='json') response = self.client.get(url, format='json')
vacancies = Vacancy.objects.filter(company__id__in=[new_company.id, new_company2.id]) vacancies = Vacancy.objects.filter(company__id__in=[new_company.id, new_company2.id])
...@@ -451,7 +451,7 @@ class VacancyTest(APITestCase): ...@@ -451,7 +451,7 @@ class VacancyTest(APITestCase):
new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None, new_company = Company.objects.create(user=new_user, description="lalala", status=Company.VERIFIED, logo=None,
address=None) address=None)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(1541319300.0), 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' url = '/api/vacancies/?opened_only=true'
response = self.client.get(url, format='json') response = self.client.get(url, format='json')
...@@ -478,7 +478,8 @@ class VacancyTest(APITestCase): ...@@ -478,7 +478,8 @@ class VacancyTest(APITestCase):
address=None) address=None)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(0), 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) self.client.force_authenticate(user=superuser)
response = new_vacancy.apply_before response = new_vacancy.apply_before
...@@ -562,7 +563,7 @@ class CompanyListsTests(APITestCase): ...@@ -562,7 +563,7 @@ class CompanyListsTests(APITestCase):
new_student = Student.objects.create(user=new_user2, npm=1234123412) 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), 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_app = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd")
self.client.force_authenticate(new_user) self.client.force_authenticate(new_user)
...@@ -580,7 +581,7 @@ class CompanyListsTests(APITestCase): ...@@ -580,7 +581,7 @@ class CompanyListsTests(APITestCase):
new_student = Student.objects.create(user=new_user2, npm=1234123412) 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), 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_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') new_user3 = User.objects.create_user('dummy.company4', 'dummy.company4@company.com', 'lalala123')
...@@ -602,7 +603,7 @@ class CompanyListsTests(APITestCase): ...@@ -602,7 +603,7 @@ class CompanyListsTests(APITestCase):
new_student = Student.objects.create(user=new_user2, npm=1234123412) 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), 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_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') new_user3 = User.objects.create_user('dummy.company4', 'dummy.company4@company.com', 'lalala123')
...@@ -624,7 +625,7 @@ class CompanyListsTests(APITestCase): ...@@ -624,7 +625,7 @@ class CompanyListsTests(APITestCase):
new_student = Student.objects.create(user=new_user2, npm=1234123412) 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), 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_app = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd")
self.client.force_authenticate(new_user) self.client.force_authenticate(new_user)
...@@ -642,7 +643,7 @@ class CompanyListsTests(APITestCase): ...@@ -642,7 +643,7 @@ class CompanyListsTests(APITestCase):
new_student = Student.objects.create(user=new_user2, npm=1234123412) 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), 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_app = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd")
self.client.force_authenticate(new_user) self.client.force_authenticate(new_user)
...@@ -661,7 +662,7 @@ class CompanyListsTests(APITestCase): ...@@ -661,7 +662,7 @@ class CompanyListsTests(APITestCase):
new_student = Student.objects.create(user=new_user2, npm=1234123412) 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), 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_app = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd")
self.client.force_authenticate(new_user) self.client.force_authenticate(new_user)
...@@ -680,7 +681,7 @@ class CompanyListsTests(APITestCase): ...@@ -680,7 +681,7 @@ class CompanyListsTests(APITestCase):
new_student = Student.objects.create(user=new_user2, npm=1234123412) 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), 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_app = Application.objects.create(student=new_student, vacancy=new_vacancy, cover_letter="asdasdasd")
self.client.force_authenticate(new_user) self.client.force_authenticate(new_user)
...@@ -730,7 +731,7 @@ class SupervisorApprovalTests(APITestCase): ...@@ -730,7 +731,7 @@ class SupervisorApprovalTests(APITestCase):
new_company2 = Company.objects.create(user=new_user2, description="lalala", status=Company.VERIFIED, logo=None, new_company2 = Company.objects.create(user=new_user2, description="lalala", status=Company.VERIFIED, logo=None,
address=None) address=None)
new_vacancy2 = Vacancy.objects.create(company=new_company2, verified=False, open_time=datetime.fromtimestamp(1541319300.0), new_vacancy2 = Vacancy.objects.create(company=new_company2, verified=False, open_time=datetime.fromtimestamp(1541319300.0),
description="lalala", requirements= "requirements", close_time=timezone.now()) description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3)
url = '/api/vacancies/' + str(new_vacancy2.pk) + '/verify/' url = '/api/vacancies/' + str(new_vacancy2.pk) + '/verify/'
response = self.client.patch(url, {'verified': True}, format='json') response = self.client.patch(url, {'verified': True}, format='json')
...@@ -746,7 +747,7 @@ class SupervisorApprovalTests(APITestCase): ...@@ -746,7 +747,7 @@ class SupervisorApprovalTests(APITestCase):
self.client.force_authenticate(user=new_user) self.client.force_authenticate(user=new_user)
new_vacancy = Vacancy.objects.create(company=new_company, verified=False, open_time=datetime.fromtimestamp(1541319300.0), new_vacancy = Vacancy.objects.create(company=new_company, verified=False, open_time=datetime.fromtimestamp(1541319300.0),
description="lalala", requirements= "requirements", close_time=timezone.now()) description="lalala", requirements= "requirements", close_time=timezone.now(), max_accepted_applicants=3)
url = '/api/vacancies/' + str(new_vacancy.pk) + '/verify/' url = '/api/vacancies/' + str(new_vacancy.pk) + '/verify/'
response = self.client.patch(url, format='json') response = self.client.patch(url, format='json')
...@@ -1006,10 +1007,10 @@ class AcceptOneOfferTests(APITestCase): ...@@ -1006,10 +1007,10 @@ class AcceptOneOfferTests(APITestCase):
address=None) address=None)
new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(0), new_vacancy = Vacancy.objects.create(company=new_company, verified=True, open_time=datetime.fromtimestamp(0),
description="lalala", requirements= "requirements", close_time=datetime.today()) description="lalala", requirements= "requirements", close_time=datetime.today(), max_accepted_applicants=3)
new_vacancy2 = Vacancy.objects.create(company=new_company2, verified=True, open_time=datetime.fromtimestamp(0), new_vacancy2 = Vacancy.objects.create(company=new_company2, verified=True, open_time=datetime.fromtimestamp(0),
description="lalala", requirements= "requirements", close_time=datetime.today()) description="lalala", requirements= "requirements", close_time=datetime.today(), max_accepted_applicants=3)
new_user3 = User.objects.create_user('dummy.student', 'dummy.student@company.com', 'lalala123') new_user3 = User.objects.create_user('dummy.student', 'dummy.student@company.com', 'lalala123')
new_student = Student.objects.create(user=new_user3, npm=1234123412) new_student = Student.objects.create(user=new_user3, npm=1234123412)
......
...@@ -98,13 +98,14 @@ class VacancyViewSet(MultiSerializerViewSetMixin, viewsets.ModelViewSet): ...@@ -98,13 +98,14 @@ class VacancyViewSet(MultiSerializerViewSetMixin, viewsets.ModelViewSet):
# if close_time < open_time: # if close_time < open_time:
# raise ValidationError('Waktu tutup lowongan harus lebih dari waktu buka lowongan!') # raise ValidationError('Waktu tutup lowongan harus lebih dari waktu buka lowongan!')
max_accepted_applicants = data['max_accepted_applicants']
if open_time < str(datetime.today()): if open_time < str(datetime.today()):
raise ValidationError('Waktu buka lowongan harus lebih dari hari ini!') raise ValidationError('Waktu buka lowongan harus lebih dari hari ini!')
elif close_time <= open_time: elif close_time <= open_time:
raise ValidationError('Waktu tutup lowongan harus lebih dari waktu buka lowongan dan tidak sama dengan waktu pembukaan lowongan!') raise ValidationError('Waktu tutup lowongan harus lebih dari waktu buka lowongan dan tidak sama dengan waktu pembukaan lowongan!')
elif close_time == open_time: elif close_time == open_time:
raise ValidationError('Waktu tutup dan buka lowongan tidak boleh sama!') raise ValidationError('Waktu tutup dan buka lowongan tidak boleh sama!')
vacancy = Vacancy(company=company, open_time=open_time, close_time=close_time, name=name, description=description, salary=salary, working_period=working_period, tag=tag) vacancy = Vacancy(company=company, open_time=open_time, close_time=close_time, name=name, description=description, salary=salary, working_period=working_period, tag=tag, max_accepted_applicants=max_accepted_applicants)