diff --git a/assets/js/CompanyProfile.jsx b/assets/js/CompanyProfile.jsx index 0d5d70a3965ab79a8fecb3047c0a10a436ae8f2c..bf2c94a7cfb4e9f18efc9bb9029b30d91e823a48 100755 --- a/assets/js/CompanyProfile.jsx +++ b/assets/js/CompanyProfile.jsx @@ -36,6 +36,7 @@ export default class CompanyProfile extends React.Component { description: data.description, website: data.website, logo: data.logo, + size: data.size, linkedin_url: data.linkedin_url, loading: false, form: { @@ -43,6 +44,7 @@ export default class CompanyProfile extends React.Component { address: '', description: '', website: '', + size: '', }, refresh: 1, applications: [], @@ -85,6 +87,7 @@ export default class CompanyProfile extends React.Component { description: result.description, refresh: this.state.refresh + 1, website: result.website, + size: result.size, linkedin_url: result.linkedin_url, }); if (result.logo != '') { @@ -174,6 +177,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> {this.state.linkedin_url ? ( <a href={this.state.linkedin_url}> {' '} @@ -242,6 +246,18 @@ export default class CompanyProfile extends React.Component { } /> </Form.Field> + <Form.Field> + <label htmlFor="size">Jumlah karyawan</label> + <input + placeholder="Jumlah karyawan keseluruhan" + name="size" + size="small" + onChange={this.handleChange} + defaultValue={ + this.state.size === null ? "0" : 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 012761e8aee3fe213c34a5f82e540c3ca18fb3ba..c065dc4124476cedac49e77ff3379a55fe79696e 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', linkedin_url: 'Belum ada LinkedIn URL', }, supervisor: null, @@ -56,6 +57,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); expect(profile.state.linkedin_url).to.equal(companyUserVerified.data.company.linkedin_url); @@ -65,7 +67,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', linkedin_url:'https://www.linkedin.com/in/bob/'}; + profile.state.form = {name:'Restopedia', address:'Bulan', description:'Martabak Tilaar', website:'www.uenak.com', linkedin_url:'https://www.linkedin.com/in/bob/', 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 3153b97dddbc14ca76669c9fedfec862a84561f5..155035941b14790179c1885a317a67d3bbd14ed5 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 b0c0786fa8fd8dc556cacacb8f9531455f042861..f2ef2d9e04e6fd7b69f8be59e9ef11cb9032f40a 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-15 13:23 +# Generated by Django 1.11.17 on 2019-11-15 14:04 from __future__ import unicode_literals import core.lib.validators @@ -38,6 +38,7 @@ class Migration(migrations.Migration): ('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)), + ('size', models.CharField(blank=True, default=0, max_length=10, null=True)), ('website', models.CharField(default=b'Belum ada link website', max_length=100)), ('linkedin_url', models.URLField(blank=True, null=True)), ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), @@ -53,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'], @@ -178,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 1b420d2b5a17ece49c94cabcdac608680db5a4de..0000000000000000000000000000000000000000 --- 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'), - ), - ] diff --git a/core/models/accounts.py b/core/models/accounts.py index 652e5f663fafdbdb062b73ae7f9d2222e8f14fc8..98fc67a7f1dcdf62253d8350661596052afea123 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, null=True, blank=True) website = models.CharField(max_length=100, default="Belum ada link website") linkedin_url = models.URLField(max_length=200,blank=True, null=True) diff --git a/core/serializers/accounts.py b/core/serializers/accounts.py index d88ee57da28e55e5b2a76a8787e7391bf725987b..792c46bf6be5c29d12a5fe859db7083f1e7c35d3 100755 --- a/core/serializers/accounts.py +++ b/core/serializers/accounts.py @@ -157,12 +157,14 @@ class CompanyUpdateSerializer(serializers.ModelSerializer): 'description': instance.description, 'name': instance.user.first_name, 'website' : instance.website, - 'linkedin_url' : instance.linkedin_url + 'linkedin_url' : instance.linkedin_url, + '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( @@ -174,7 +176,7 @@ class CompanyUpdateSerializer(serializers.ModelSerializer): class Meta: model = Company - fields = ['address', 'description', 'name' , 'website', 'linkedin_url'] + fields = ['address', 'description', 'name' , 'website', 'linkedin_url', 'size'] class CompanySerializer(serializers.ModelSerializer): diff --git a/core/tests/test_accounts.py b/core/tests/test_accounts.py index 7dbc8e3f76425447e17de0ac20141123445d2507..922b9fdade93273e57d0ab315aa7f2759cd841c3 100755 --- a/core/tests/test_accounts.py +++ b/core/tests/test_accounts.py @@ -77,7 +77,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':'1000'} response = self.client.post(url, tc_post, format='multipart') self.assertEqual(response.status_code, status.HTTP_201_CREATED) @@ -413,6 +414,9 @@ 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) diff --git a/core/views/accounts.py b/core/views/accounts.py index 136bd5b5c560e891e87f44b4cb1f7ef23eef7b26..4619460bdd64c63c3544a1faaeea13a158b12f03 100755 --- a/core/views/accounts.py +++ b/core/views/accounts.py @@ -302,7 +302,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) @@ -321,6 +321,7 @@ class CompanyRegisterViewSet(viewsets.GenericViewSet): logo=data['logo'], address=data['address'], category=data['category'], + size=data['size'], website=data['website'] ) user.save()