diff --git a/assets/js/EditProfile.jsx b/assets/js/EditProfile.jsx index c7cb5c6221fa0190780c9f22138faece1b128d6c..c067fce36f80f807584bf3773a3574af836d2b9e 100644 --- a/assets/js/EditProfile.jsx +++ b/assets/js/EditProfile.jsx @@ -82,6 +82,7 @@ export default class ProfilePage extends React.Component { certification: '', languages: '', seminar: '', + dependants: '', }; this.getProfile = this.getProfile.bind(this); this.handleChange = this.handleChange.bind(this); @@ -472,6 +473,15 @@ export default class ProfilePage extends React.Component { name="student_gpa" /> </Form.Field> + <Form.Field> + <label htmlFor="dependants">Dependants</label> + <input + onChange={this.handleChange} + placeholder={this.state.dependants === null ? '0' : this.state.dependants} + defaultValue={this.state.dependants === null ? null : this.state.dependants} + name="dependants" + /> + </Form.Field> <Button type="submit" size="small" loading={this.state.loading} primary floated="right">Submit</Button> </Form> diff --git a/assets/js/ProfilePage.jsx b/assets/js/ProfilePage.jsx index cedd4c352dd5597aa66828ea9139f7efb4897f04..5f764ee0940e873e4ad4d162b3a193fcbcdf570c 100755 --- a/assets/js/ProfilePage.jsx +++ b/assets/js/ProfilePage.jsx @@ -80,6 +80,7 @@ export default class ProfilePage extends React.Component { certification: '', languages: '', semimar: '', + dependants: '', }; this.getProfile = this.getProfile.bind(this); this.handleChange = this.handleChange.bind(this); @@ -135,6 +136,7 @@ export default class ProfilePage extends React.Component { certification: data.certification, languages: data.languages, seminar: data.seminar, + dependants: data.dependants, }); if (this.props.route.own) { const newSession = this.props.user.data; @@ -459,6 +461,15 @@ export default class ProfilePage extends React.Component { name="student_gpa" /> </Form.Field> + <Form.Field> + <label htmlFor="dependants">Dependants</label> + <input + onChange={this.handleChange} + placeholder={this.state.dependants === null ? '0' : this.state.dependants} + defaultValue={this.state.dependants === null ? null : this.state.dependants} + name="dependants" + /> + </Form.Field> <Button type="submit" size="small" loading={this.state.loading} primary floated="right">Submit</Button> </Form> @@ -599,6 +610,17 @@ export default class ProfilePage extends React.Component { </Grid> </Segment> + <Segment basic vertical> + <Grid> + <Grid.Column width={2}> + <Icon name="child" size="big" /> + </Grid.Column> + <Grid.Column width={13}> + <a href={this.state.dependants}> {this.state.dependants || 'null'} </a> + </Grid.Column> + </Grid> + </Segment> + <Segment basic vertical> <Grid> <Grid.Column width={2}> diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py index a27295685ab2ecf27c397bd89c46744095111537..7306c234d00033c64ed05fb5e9763ce3fb2616e9 100644 --- a/core/migrations/0001_initial.py +++ b/core/migrations/0001_initial.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.11.17 on 2019-11-14 09:34 +# Generated by Django 1.11.17 on 2019-11-14 11:52 from __future__ import unicode_literals import core.lib.validators @@ -37,8 +37,8 @@ class Migration(migrations.Migration): ('status', models.IntegerField(default=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=b'Belum ada kategori perusahaan', max_length=140)), - ('website', models.CharField(default=b'Belum ada link website', max_length=100)), + ('category', models.CharField(default='Belum ada kategori perusahaan', max_length=140)), + ('website', models.CharField(default='Belum ada link website', max_length=100)), ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], options={ @@ -50,7 +50,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=b'', max_length=100)), + ('title', models.CharField(blank=True, default='', max_length=100)), ('content', models.TextField()), ], options={ @@ -64,16 +64,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([b'pdf'])])), + ('resume', models.FileField(blank=True, null=True, upload_to=core.models.accounts.get_student_resume_file_path, validators=[django.core.validators.FileExtensionValidator(['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(b'^0\\d{1,11}$')])), + ('phone_number', models.CharField(blank=True, db_index=True, max_length=100, null=True, validators=[django.core.validators.RegexValidator('^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([b'jpg', b'jpeg', b'png'])])), + ('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'])])), ('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)), @@ -91,13 +91,14 @@ class Migration(migrations.Migration): ('intro', models.CharField(blank=True, max_length=50, null=True)), ('expected_salary', models.CharField(blank=True, max_length=10, null=True)), ('job_seeking_status', models.CharField(blank=True, max_length=30, null=True)), - ('student_gpa', models.FloatField(blank=True, db_column=b'student_gpa', default=1.0, null=True)), + ('student_gpa', models.FloatField(blank=True, db_column='student_gpa', default=1.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)), ('certification', models.CharField(blank=True, max_length=100, null=True)), ('languages', models.CharField(blank=True, max_length=100, null=True)), ('seminar', models.CharField(blank=True, max_length=100, null=True)), + ('dependants', models.IntegerField(blank=True, db_column='dependants', default=0, null=True)), ], options={ 'ordering': ['-updated'], @@ -109,7 +110,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created', models.DateTimeField(auto_now_add=True)), ('updated', models.DateTimeField(auto_now=True)), - ('nip', models.IntegerField(unique=True, validators=[django.core.validators.MinValueValidator(100000000), django.core.validators.MaxValueValidator(9999999999L)])), + ('nip', models.IntegerField(unique=True, validators=[django.core.validators.MinValueValidator(100000000), django.core.validators.MaxValueValidator(9999999999)])), ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], options={ @@ -130,7 +131,7 @@ class Migration(migrations.Migration): ('updated', models.DateTimeField(auto_now=True)), ('name', models.CharField(max_length=100)), ('amount', models.IntegerField(null=True)), - ('max_accepted_applicants', models.IntegerField()), + ('max_accepted_applicants', models.IntegerField(default=0)), ('benefits', models.TextField(blank=True)), ('working_period', models.CharField(max_length=100, null=True)), ('tag', models.TextField(blank=True)), @@ -157,7 +158,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=b'Tidak memenuhi kualifikasi perusahaan.')), + ('reason', models.TextField(default='Tidak memenuhi kualifikasi perusahaan.')), ], ), migrations.AddField( diff --git a/core/models/accounts.py b/core/models/accounts.py index 45151d68238e9cf3275c99ef7e529a479037121b..f7d28ba53d18921486999aee2ab38c6e8d7b9adf 100755 --- a/core/models/accounts.py +++ b/core/models/accounts.py @@ -106,6 +106,7 @@ class Student(models.Model): certification = models.CharField(max_length=100, blank=True, null=True) languages = models.CharField(max_length= 100, blank=True, null=True) seminar = models.CharField(max_length=100, blank=True, null=True) + dependants = models.IntegerField(db_column='dependants', default=0, blank=True, null=True) @property def name(self): diff --git a/core/models/vacancies.py b/core/models/vacancies.py index 3fda04a79dbe315cdb2a5cb6db3965271a1fe7ee..6a9ce69260c89a4f3da6fc8c6d42445753ec364c 100755 --- a/core/models/vacancies.py +++ b/core/models/vacancies.py @@ -17,7 +17,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() + max_accepted_applicants = models.IntegerField(default=0) benefits = models.TextField(blank=True) working_period = models.CharField(max_length=100, null=True) tag = models.TextField(blank=True) diff --git a/core/serializers/accounts.py b/core/serializers/accounts.py index 97d380e75f9eb9f3979c2365caeba1a584bbb6f6..1d7abf9b4c25068a3769d9ff58f36016e035f704 100755 --- a/core/serializers/accounts.py +++ b/core/serializers/accounts.py @@ -22,7 +22,7 @@ class StudentSerializer(serializers.ModelSerializer): fields = ['id', 'name', 'user', 'npm', 'resume', 'phone_number', 'gender', 'birth_place', 'birth_date', 'major', 'batch', 'show_transcript', 'photo', 'accepted_no', 'linkedin_url', 'hackerrank_url', 'region', 'intro', 'portfolio_link', 'website_url', 'student_gpa', 'age', 'recommendations', 'work_experience', 'latest_work', 'latest_work_desc', 'read_no', 'volunteer', 'job_seeking_status', 'skills', 'expected_salary', - 'self_description', 'github_url', 'awards', 'certification', 'languages', 'seminar', 'alamat', 'projects'] + 'self_description', 'github_url', 'awards', 'certification', 'languages', 'seminar', 'alamat', 'projects', 'dependants'] def get_accepted_no(self, obj): apps = Application.objects.filter(student=obj, status=4) @@ -74,7 +74,8 @@ class StudentUpdateSerializer(serializers.ModelSerializer): 'projects' : instance.projects, 'certification' : instance.certification, 'languages' : instance.languages, - 'seminar' : instance.seminar + 'seminar' : instance.seminar, + 'dependants' : instance.dependants, } def update(self, instance, validated_data): @@ -134,6 +135,7 @@ class StudentUpdateSerializer(serializers.ModelSerializer): 'languages', instance.languages) instance.seminar = validated_data.get( 'seminar', instance.seminar) + instance.dependants = validated_data.get('dependants', instance.dependants) instance.save() instance.user.save() return instance @@ -142,7 +144,7 @@ class StudentUpdateSerializer(serializers.ModelSerializer): model = Student fields = ['resume', 'email', 'phone_number', 'gender', 'photo', 'show_transcript', 'linkedin_url', 'hackerrank_url', 'region', 'intro', 'portfolio_link', 'website_url', 'student_gpa', 'recommendations', 'work_experience', 'latest_work', 'latest_work_desc', 'volunteer', 'job_seeking_status', 'skills', 'expected_salary', - 'self_description', 'github_url', 'awards', 'certification', 'languages', 'seminar', 'alamat', 'projects'] + 'self_description', 'github_url', 'awards', 'certification', 'languages', 'seminar', 'alamat', 'projects', 'dependants'] class CompanyUpdateSerializer(serializers.ModelSerializer): diff --git a/core/tests/test_accounts.py b/core/tests/test_accounts.py index b10774d47d43afc707f2d9e96e100b84849a0787..aecb57aaab5d653b4f89416e3809af566cc1eb82 100755 --- a/core/tests/test_accounts.py +++ b/core/tests/test_accounts.py @@ -302,6 +302,14 @@ class ProfileUpdateTests(APITestCase): self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) self.assertEqual(response.data.get('work_experience'), 'Magang 3 bulan di Pusilkom') + url = '/api/students/' + str(student_id) + "/profile/" + response = self.client.patch(url, {'dependants': 0}, format='multipart') + self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) + self.assertEqual(response.data.get('dependants'), 0) + + url = '/api/students/' + str(student_id) + "/profile/" + response = self.client.patch(url, {'dependants': 'this is not valid dependants input'}, format='multipart') + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) def _create_test_file(self,path): f = open(path, 'r')