From e84fbc7cf9549a49cac6e1ee47680f9fe7b9f052 Mon Sep 17 00:00:00 2001 From: "hadlinar.rahmadinni" <Spongebob18> Date: Fri, 15 Nov 2019 11:04:54 +0700 Subject: [PATCH 1/5] create test for company size field when registering a new company --- assets/js/__test__/CompanyProfile-test.jsx | 1 + core/tests/test_accounts.py | 3 ++- package-lock.json | 8 ++------ 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/assets/js/__test__/CompanyProfile-test.jsx b/assets/js/__test__/CompanyProfile-test.jsx index 2a604c3d..0797a8ce 100755 --- a/assets/js/__test__/CompanyProfile-test.jsx +++ b/assets/js/__test__/CompanyProfile-test.jsx @@ -26,6 +26,7 @@ const companyUserVerified = { address: 'Jl. Kebayoran Baru nomor 13, Jakarta Barat', category: 'Belum ada kategori perusahaan', website: 'Belum ada link website' + size: 'Jumlah karyawan belum dimasukan' }, supervisor: null, student: null, diff --git a/core/tests/test_accounts.py b/core/tests/test_accounts.py index 431bb504..3cfb1907 100755 --- a/core/tests/test_accounts.py +++ b/core/tests/test_accounts.py @@ -71,7 +71,8 @@ class LoginTests(APITestCase): class RegisterTests(APITestCase): def test_create_and_recreate(self): url = '/api/register/' - tc_post = {'password': 'corporatepass', 'name':'tutuplapak', 'description':'menutup lapak', 'email': 'email@email.com', 'logo':'lalala', 'address':'alamat', 'category':'Perusahaan Jasa', 'website':'www.tutuplapak.com'} + tc_post = {'password': 'corporatepass', 'name':'tutuplapak', 'description':'menutup lapak', 'email': 'email@email.com', + 'logo':'lalala', 'address':'alamat', 'category':'Perusahaan Jasa', 'website':'www.tutuplapak.com', 'size':'2000 karyawan'} response = self.client.post(url, tc_post, format='multipart') self.assertEqual(response.status_code, status.HTTP_201_CREATED) diff --git a/package-lock.json b/package-lock.json index fd82d3e6..0fdfd6ae 100755 --- a/package-lock.json +++ b/package-lock.json @@ -6256,7 +6256,6 @@ "version": "5.13.1", "resolved": "https://registry.npmjs.org/fetch-mock/-/fetch-mock-5.13.1.tgz", "integrity": "sha512-eWUo2KI4sRGnRu8tKELCBfasALM5BfvrCxdI7J02j3eUM9mf+uYzJkURA0PSn/29JVapVrYFm+z+9XijXu1PdA==", - "dev": true, "requires": { "glob-to-regexp": "^0.3.0", "node-fetch": "^1.3.3", @@ -7074,8 +7073,7 @@ "glob-to-regexp": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz", - "integrity": "sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs=", - "dev": true + "integrity": "sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs=" }, "global": { "version": "4.4.0", @@ -10221,7 +10219,6 @@ "version": "1.7.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", - "dev": true, "requires": { "isarray": "0.0.1" }, @@ -10229,8 +10226,7 @@ "isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" } } }, -- GitLab From 131a4bbfdbd8cf45885e6734daa5807585a99a66 Mon Sep 17 00:00:00 2001 From: "hadlinar.rahmadinni" <Spongebob18> Date: Fri, 15 Nov 2019 14:44:53 +0700 Subject: [PATCH 2/5] implement field jumlah karyawan for company --- assets/js/CompanyProfile.jsx | 14 +++++++++++++ assets/js/__test__/CompanyProfile-test.jsx | 2 +- assets/js/components/CompanyRegisterModal.jsx | 4 ++++ core/migrations/0001_initial.py | 5 +++-- core/migrations/0002_student_interest.py | 20 ------------------- core/migrations/0003_auto_20191115_0855.py | 20 ------------------- core/models/accounts.py | 1 + core/views/accounts.py | 3 ++- 8 files changed, 25 insertions(+), 44 deletions(-) delete mode 100644 core/migrations/0002_student_interest.py delete mode 100644 core/migrations/0003_auto_20191115_0855.py diff --git a/assets/js/CompanyProfile.jsx b/assets/js/CompanyProfile.jsx index 5ba41057..4677b45a 100755 --- a/assets/js/CompanyProfile.jsx +++ b/assets/js/CompanyProfile.jsx @@ -34,6 +34,7 @@ export default class CompanyProfile extends React.Component { description: data.description, website: data.website, logo: data.logo, + size: data.size, loading: false, form: { name: '', @@ -73,6 +74,7 @@ export default class CompanyProfile extends React.Component { description: result.description, refresh: this.state.refresh + 1, website: result.website, + size: result.size, }); if (result.logo != '') { this.setState({ logo: result.logo }); @@ -161,6 +163,7 @@ export default class CompanyProfile extends React.Component { {this.state.category} - {this.state.description} </p> <p>{this.state.website}</p> + <p>{this.state.size} karyawan</p> </div> </Container> <Container textAlign="center" className="statistik"> @@ -221,6 +224,17 @@ export default class CompanyProfile extends React.Component { } /> </Form.Field> + <Form.Field> + <label htmlFor="size">Jumlah karyawan</label> + <input + placeholder="Jumlah karyawan keseluruhan" + name="size" + onChange={this.handleChange} + defaultValue={ + this.state.size === null ? null : this.state.size + } + /> + </Form.Field> <Form.Field> <label htmlFor="website">Website</label> <input diff --git a/assets/js/__test__/CompanyProfile-test.jsx b/assets/js/__test__/CompanyProfile-test.jsx index 0797a8ce..8ba3fb97 100755 --- a/assets/js/__test__/CompanyProfile-test.jsx +++ b/assets/js/__test__/CompanyProfile-test.jsx @@ -25,7 +25,7 @@ const companyUserVerified = { logo: 'http://localhost:8001/files/company-logo/8a258a48-3bce-4873-b5d1-538b360d0059.png', address: 'Jl. Kebayoran Baru nomor 13, Jakarta Barat', category: 'Belum ada kategori perusahaan', - website: 'Belum ada link website' + website: 'Belum ada link website', size: 'Jumlah karyawan belum dimasukan' }, supervisor: null, diff --git a/assets/js/components/CompanyRegisterModal.jsx b/assets/js/components/CompanyRegisterModal.jsx index 3153b97d..6dd48522 100755 --- a/assets/js/components/CompanyRegisterModal.jsx +++ b/assets/js/components/CompanyRegisterModal.jsx @@ -184,6 +184,10 @@ export default class CompanyRegisterModal extends React.Component { <label htmlFor="address">Alamat</label> <Input onChange={this.handleChange} placeholder="Alamat" name="address" required /> </Form.Field> + <Form.Field required> + <label htmlFor="size">Jumlah karyawan (contoh: 1000)</label> + <Input onChange={this.handleChange} placeholder="Jumlah karyawan" name="size" required /> + </Form.Field> <Form.Field required> <label htmlFor="address">Website</label> <Input onChange={this.handleChange} placeholder="Website perusahaan anda" name="website" required /> diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py index 4bb9a876..4de30a01 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 14:00 +# Generated by Django 1.11.17 on 2019-11-15 04:18 from __future__ import unicode_literals import core.lib.validators @@ -98,6 +98,7 @@ class Migration(migrations.Migration): ('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)), + ('interests', models.CharField(blank=True, max_length=100, null=True)), ('dependants', models.IntegerField(blank=True, db_column=b'dependants', default=0, null=True)), ], options={ @@ -110,7 +111,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={ diff --git a/core/migrations/0002_student_interest.py b/core/migrations/0002_student_interest.py deleted file mode 100644 index c57bb171..00000000 --- a/core/migrations/0002_student_interest.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.17 on 2019-11-15 01:18 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('core', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='student', - name='interest', - field=models.CharField(blank=True, max_length=100, null=True), - ), - ] diff --git a/core/migrations/0003_auto_20191115_0855.py b/core/migrations/0003_auto_20191115_0855.py deleted file mode 100644 index 557a253d..00000000 --- a/core/migrations/0003_auto_20191115_0855.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.17 on 2019-11-15 01:55 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('core', '0002_student_interest'), - ] - - operations = [ - migrations.RenameField( - model_name='student', - old_name='interest', - new_name='interests', - ), - ] diff --git a/core/models/accounts.py b/core/models/accounts.py index 179df966..7146a15d 100755 --- a/core/models/accounts.py +++ b/core/models/accounts.py @@ -144,6 +144,7 @@ class Company(models.Model): logo = models.FileField(upload_to=get_company_logo_file_path, null=True, blank=True, validators=[validate_image_file_extension]) address = models.CharField(max_length=1000, blank=True, null=True) category = models.CharField(max_length=140, default="Belum ada kategori perusahaan") + size = models.CharField(max_length=10, default=0) website = models.CharField(max_length=100, default="Belum ada link website") @property diff --git a/core/views/accounts.py b/core/views/accounts.py index d4a6e361..ae17fbcb 100755 --- a/core/views/accounts.py +++ b/core/views/accounts.py @@ -264,7 +264,7 @@ class CompanyRegisterViewSet(viewsets.GenericViewSet): type: string """ data = {} - for attr in ['password', 'email', 'name', 'description', 'logo', 'address', 'category', 'website']: + for attr in ['password', 'email', 'name', 'description', 'logo', 'address', 'category', 'size','website']: data[attr] = request.data.get(attr) if data[attr] is None: return Response({'error': attr+' is required'}, status=status.HTTP_400_BAD_REQUEST) @@ -283,6 +283,7 @@ class CompanyRegisterViewSet(viewsets.GenericViewSet): logo=data['logo'], address=data['address'], category=data['category'], + size=data['size'], website=data['website'] ) user.save() -- GitLab From ecd8b855bb7d00fe5a368e6b9d691c69ba66a16f Mon Sep 17 00:00:00 2001 From: "hadlinar.rahmadinni" <Spongebob18> Date: Fri, 15 Nov 2019 20:21:27 +0700 Subject: [PATCH 3/5] add test and fixed edit size field function --- assets/js/CompanyProfile.jsx | 4 +- assets/js/__test__/CompanyProfile-test.jsx | 3 +- assets/js/components/CompanyRegisterModal.jsx | 2 +- core/migrations/0001_initial.py | 194 ------------------ core/models/accounts.py | 2 +- core/serializers/accounts.py | 4 +- core/tests/test_accounts.py | 3 + 7 files changed, 13 insertions(+), 199 deletions(-) delete mode 100644 core/migrations/0001_initial.py diff --git a/assets/js/CompanyProfile.jsx b/assets/js/CompanyProfile.jsx index 4677b45a..bfecd7b1 100755 --- a/assets/js/CompanyProfile.jsx +++ b/assets/js/CompanyProfile.jsx @@ -41,6 +41,7 @@ export default class CompanyProfile extends React.Component { address: '', description: '', website: '', + size: '', }, refresh: 1, applications: [], @@ -229,9 +230,10 @@ export default class CompanyProfile extends React.Component { <input placeholder="Jumlah karyawan keseluruhan" name="size" + size="small" onChange={this.handleChange} defaultValue={ - this.state.size === null ? null : this.state.size + this.state.size === null ? "0" : this.state.size } /> </Form.Field> diff --git a/assets/js/__test__/CompanyProfile-test.jsx b/assets/js/__test__/CompanyProfile-test.jsx index 8ba3fb97..a320b6f4 100755 --- a/assets/js/__test__/CompanyProfile-test.jsx +++ b/assets/js/__test__/CompanyProfile-test.jsx @@ -56,6 +56,7 @@ describe('CompanyProfile', () => { expect(profile.state.address).to.equal(companyUserVerified.data.company.address); expect(profile.state.category).to.equal(companyUserVerified.data.company.category); expect(profile.state.description).to.equal(companyUserVerified.data.company.description); + expect(profile.state.size).to.equal(companyUserVerified.data.company.size); expect(profile.state.website).to.equal(companyUserVerified.data.company.website); expect(profile.state.logo).to.equal(companyUserVerified.data.company.logo); }); @@ -64,7 +65,7 @@ describe('CompanyProfile', () => { it('submit edit form of verified company without problem', () => { const profile = ReactTestUtils.renderIntoDocument( <CompanyProfile user={companyUserVerified} />); - profile.state.form = {name:'Restopedia', address:'Bulan', description:'Martabak Tilaar', website:'www.uenak.com'}; + profile.state.form = {name:'Restopedia', address:'Bulan', description:'Martabak Tilaar', website:'www.uenak.com', size:'1000'}; const submitButton = ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Input')[1]; ReactTestUtils.Simulate.click(submitButton); diff --git a/assets/js/components/CompanyRegisterModal.jsx b/assets/js/components/CompanyRegisterModal.jsx index 6dd48522..15503594 100755 --- a/assets/js/components/CompanyRegisterModal.jsx +++ b/assets/js/components/CompanyRegisterModal.jsx @@ -186,7 +186,7 @@ export default class CompanyRegisterModal extends React.Component { </Form.Field> <Form.Field required> <label htmlFor="size">Jumlah karyawan (contoh: 1000)</label> - <Input onChange={this.handleChange} placeholder="Jumlah karyawan" name="size" required /> + <Input onChange={this.handleChange} placeholder="Jumlah karyawan" name="size" required/> </Form.Field> <Form.Field required> <label htmlFor="address">Website</label> diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py deleted file mode 100644 index 4de30a01..00000000 --- a/core/migrations/0001_initial.py +++ /dev/null @@ -1,194 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.17 on 2019-11-15 04:18 -from __future__ import unicode_literals - -import core.lib.validators -import core.models.accounts -from django.conf import settings -import django.core.validators -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.CreateModel( - name='Application', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('cover_letter', models.TextField(blank=True, null=True)), - ('status', models.IntegerField(default=0)), - ], - ), - migrations.CreateModel( - name='Company', - fields=[ - ('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)), - ('description', models.TextField()), - ('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)), - ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - options={ - 'ordering': ['-updated'], - }, - ), - migrations.CreateModel( - name='Feedback', - 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)), - ('content', models.TextField()), - ], - options={ - 'ordering': ['created'], - }, - ), - migrations.CreateModel( - name='Student', - fields=[ - ('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)), - ('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'])])), - ('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}$')])), - ('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'])])), - ('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)), - ('hackerrank_url', models.URLField(blank=True, null=True)), - ('website_url', models.URLField(blank=True, null=True)), - ('work_experience', models.CharField(blank=True, max_length=500, null=True)), - ('region', models.CharField(blank=True, max_length=30, null=True)), - ('alamat', models.CharField(blank=True, max_length=50, null=True)), - ('skills', models.CharField(blank=True, max_length=50, null=True)), - ('recommendations', models.CharField(blank=True, max_length=500, null=True)), - ('ui_ux_portofolio', models.FileField(blank=True, null=True, upload_to=core.models.accounts.get_student_ui_ux_portofolio_file_path, validators=[core.lib.validators.validate_document_file_extension])), - ('latest_work', models.CharField(blank=True, max_length=100, null=True)), - ('latest_work_desc', models.TextField(blank=True, null=True)), - ('github_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)), - ('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)), - ('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)), - ('interests', models.CharField(blank=True, max_length=100, null=True)), - ('dependants', models.IntegerField(blank=True, db_column=b'dependants', default=0, null=True)), - ], - options={ - 'ordering': ['-updated'], - }, - ), - migrations.CreateModel( - name='Supervisor', - fields=[ - ('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(9999999999)])), - ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - options={ - 'ordering': ['-updated'], - }, - ), - migrations.CreateModel( - name='Vacancy', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('verified', models.BooleanField(default=False)), - ('open_time', models.DateTimeField()), - ('description', models.TextField(blank=True)), - ('requirements', models.TextField(blank=True)), - ('responsibilities', models.TextField(blank=True)), - ('close_time', models.DateTimeField()), - ('created', models.DateTimeField(auto_now_add=True)), - ('updated', models.DateTimeField(auto_now=True)), - ('name', models.CharField(max_length=100)), - ('amount', models.IntegerField(null=True)), - ('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)), - ('salary', models.IntegerField(default=0)), - ('recruiter_activity', models.CharField(blank=True, max_length=10, null=True)), - ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='vacancies', to='core.Company')), - ], - options={ - 'ordering': ['-updated'], - }, - ), - migrations.CreateModel( - name='VacancyMilestone', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=100)), - ('detail', models.TextField()), - ('expected_start', models.DateField()), - ('expected_finish', models.DateField()), - ('vacancy', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='milestones', to='core.Vacancy')), - ], - ), - migrations.CreateModel( - 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.')), - ], - ), - migrations.AddField( - model_name='student', - name='applied_vacancies', - field=models.ManyToManyField(blank=True, related_name='applied_vacancies', through='core.Application', to='core.Vacancy'), - ), - migrations.AddField( - model_name='student', - name='bookmarked_vacancies', - field=models.ManyToManyField(blank=True, related_name='bookmarked_vacancies', to='core.Vacancy'), - ), - migrations.AddField( - model_name='student', - name='user', - field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), - ), - migrations.AddField( - model_name='application', - name='student', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Student'), - ), - migrations.AddField( - model_name='application', - name='vacancy', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Vacancy'), - ), - migrations.AlterUniqueTogether( - name='application', - unique_together=set([('student', 'vacancy')]), - ), - ] diff --git a/core/models/accounts.py b/core/models/accounts.py index 7146a15d..0500798b 100755 --- a/core/models/accounts.py +++ b/core/models/accounts.py @@ -144,7 +144,7 @@ class Company(models.Model): logo = models.FileField(upload_to=get_company_logo_file_path, null=True, blank=True, validators=[validate_image_file_extension]) address = models.CharField(max_length=1000, blank=True, null=True) category = models.CharField(max_length=140, default="Belum ada kategori perusahaan") - size = models.CharField(max_length=10, default=0) + size = models.CharField(max_length=10, default=0, null=True, blank=True) website = models.CharField(max_length=100, default="Belum ada link website") @property diff --git a/core/serializers/accounts.py b/core/serializers/accounts.py index 779a7c11..72e3268b 100755 --- a/core/serializers/accounts.py +++ b/core/serializers/accounts.py @@ -157,11 +157,13 @@ class CompanyUpdateSerializer(serializers.ModelSerializer): 'description': instance.description, 'name': instance.user.first_name, 'website' : instance.website, + 'size' : instance.size, } def update(self, instance, validated_data): instance.address = validated_data.get('address', instance.address) instance.website = validated_data.get('website', instance.website) + instance.size = validated_data.get('size', instance.size) instance.description = validated_data.get( 'description', instance.description) instance.user.first_name = validated_data.get( @@ -172,7 +174,7 @@ class CompanyUpdateSerializer(serializers.ModelSerializer): class Meta: model = Company - fields = ['address', 'description', 'name' , 'website'] + fields = ['address', 'description', 'name' , 'website', 'size'] class CompanySerializer(serializers.ModelSerializer): diff --git a/core/tests/test_accounts.py b/core/tests/test_accounts.py index 3cfb1907..2ab946bb 100755 --- a/core/tests/test_accounts.py +++ b/core/tests/test_accounts.py @@ -341,5 +341,8 @@ class ProfileUpdateTests(APITestCase): response = self.client.patch(url, {'description': 'Masak-Masak'}, format='multipart') self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) + response = self.client.patch(url, {'size': '1000'}, format='multipart') + self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) + response = self.client.patch(url, {'website': 'www.huehue.com'}, format='multipart') self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) \ No newline at end of file -- GitLab From 239ac1e22aae607aeabd4a08674e59aed7c8d44e Mon Sep 17 00:00:00 2001 From: "hadlinar.rahmadinni" <Spongebob18> Date: Fri, 15 Nov 2019 21:09:26 +0700 Subject: [PATCH 4/5] pull from master, delete old migration file --- core/migrations/0001_initial.py | 12 +++++----- core/migrations/0002_auto_20191115_2030.py | 26 ---------------------- 2 files changed, 7 insertions(+), 31 deletions(-) delete mode 100644 core/migrations/0002_auto_20191115_2030.py diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py index 3267b5f7..f2ef2d9e 100644 --- a/core/migrations/0001_initial.py +++ b/core/migrations/0001_initial.py @@ -1,9 +1,5 @@ # -*- coding: utf-8 -*- -<<<<<<< HEAD -# Generated by Django 1.11.17 on 2019-11-15 13:37 -======= -# Generated by Django 1.11.17 on 2019-11-15 13:23 ->>>>>>> ed5cfc1d7b856d5b9a203648dfa4720be05392be +# Generated by Django 1.11.17 on 2019-11-15 14:04 from __future__ import unicode_literals import core.lib.validators @@ -58,6 +54,7 @@ class Migration(migrations.Migration): ('created', models.DateTimeField(auto_now_add=True)), ('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')), ], options={ 'ordering': ['created'], @@ -183,6 +180,11 @@ class Migration(migrations.Migration): name='user', field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), ), + migrations.AddField( + model_name='feedback', + name='studentId', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.Student'), + ), migrations.AddField( model_name='application', name='student', diff --git a/core/migrations/0002_auto_20191115_2030.py b/core/migrations/0002_auto_20191115_2030.py deleted file mode 100644 index 1b420d2b..00000000 --- a/core/migrations/0002_auto_20191115_2030.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.17 on 2019-11-15 13:30 -from __future__ import unicode_literals - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('core', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='feedback', - name='companyId', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.Company'), - ), - migrations.AddField( - model_name='feedback', - name='studentId', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.Student'), - ), - ] -- GitLab From e2aafd8fb037887b9c92b4f06229055b5322beed Mon Sep 17 00:00:00 2001 From: "hadlinar.rahmadinni" <Spongebob18> Date: Fri, 15 Nov 2019 21:33:42 +0700 Subject: [PATCH 5/5] fixed test --- core/tests/test_accounts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/tests/test_accounts.py b/core/tests/test_accounts.py index bcca3345..922b9fda 100755 --- a/core/tests/test_accounts.py +++ b/core/tests/test_accounts.py @@ -78,7 +78,7 @@ class RegisterTests(APITestCase): def test_create_and_recreate(self): url = '/api/register/' tc_post = {'password': 'corporatepass', 'name':'tutuplapak', 'description':'menutup lapak', 'email': 'email@email.com', - 'logo':'lalala', 'address':'alamat', 'category':'Perusahaan Jasa', 'website':'www.tutuplapak.com', 'size':'2000 karyawan'} + 'logo':'lalala', 'address':'alamat', 'category':'Perusahaan Jasa', 'website':'www.tutuplapak.com', 'size':'1000'} response = self.client.post(url, tc_post, format='multipart') self.assertEqual(response.status_code, status.HTTP_201_CREATED) -- GitLab