diff --git a/assets/js/CompanyProfile.jsx b/assets/js/CompanyProfile.jsx index bec00414259a324235df563890decff11401534c..2e361f68381644396f8b9f1e79ba845f25475d67 100755 --- a/assets/js/CompanyProfile.jsx +++ b/assets/js/CompanyProfile.jsx @@ -30,6 +30,7 @@ export default class CompanyProfile extends React.Component { name: '', address: '', description: '', + website: '', }, refresh: 1, applications: [], @@ -155,6 +156,11 @@ export default class CompanyProfile extends React.Component { <TextArea placeholder='Try adding multiple lines' name="description" onChange={this.handleChange} autoHeight defaultValue={this.state.description === null ? null : this.state.description}/> + </Form.Field> + <Form.Field> + <label htmlFor="website">Website</label> + <input placeholder="Alamat Website" name="website" onChange={this.handleChange} + defaultValue={this.state.website === null ? null : this.state.website}/> </Form.Field> <Button type="submit" size="small" loading={this.state.loading} primary floated="right">Submit</Button> </Form> diff --git a/assets/js/__test__/CompanyProfile-test.jsx b/assets/js/__test__/CompanyProfile-test.jsx index fab194d22c5605be916f2cc663d77862b75ead24..073ec50c9c5882a36e89a1f86ae090daf953aa8d 100755 --- a/assets/js/__test__/CompanyProfile-test.jsx +++ b/assets/js/__test__/CompanyProfile-test.jsx @@ -55,6 +55,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.website).to.equal(companyUserVerified.data.company.website); expect(profile.state.logo).to.equal(companyUserVerified.data.company.logo); }); }); @@ -62,7 +63,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'}; + profile.state.form = {name:'Restopedia', address:'Bulan', description:'Martabak Tilaar', website:'www.uenak.com'}; const submitButton = ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Input')[1]; ReactTestUtils.Simulate.click(submitButton); diff --git a/core/serializers/accounts.py b/core/serializers/accounts.py index 78aa6d7332eed58ce0c63d24bb5f1ddecb495061..b1bf8f5d96f0d8c5d389e1c750e0ba785e13c8b3 100755 --- a/core/serializers/accounts.py +++ b/core/serializers/accounts.py @@ -130,11 +130,13 @@ class CompanyUpdateSerializer(serializers.ModelSerializer): return { 'address': instance.address, 'description': instance.description, - 'name': instance.name + 'name': instance.user.first_name, + 'website' : instance.website, } def update(self, instance, validated_data): instance.address = validated_data.get('address', instance.address) + instance.website = validated_data.get('website', instance.website) instance.description = validated_data.get( 'description', instance.description) instance.user.first_name = validated_data.get( @@ -145,7 +147,7 @@ class CompanyUpdateSerializer(serializers.ModelSerializer): class Meta: model = Company - fields = ['address', 'description', 'name'] + fields = ['address', 'description', 'name' , 'website'] class CompanySerializer(serializers.ModelSerializer): diff --git a/core/tests/test_accounts.py b/core/tests/test_accounts.py index 6ef76cadbe429cbf023674c93b1739e0fb2434b6..2e8209fbf26ca398f2fd410782b474e0d6039fd1 100755 --- a/core/tests/test_accounts.py +++ b/core/tests/test_accounts.py @@ -288,7 +288,8 @@ class ProfileUpdateTests(APITestCase): Company.objects.create(user=new_user, description="lalalala", status=Company.VERIFIED, logo=None, address=None) url = '/api/login/' - response = self.client.post(url, {'username': 'dummy.login.company', 'password': 'lalala123', 'login-type': 'company'}, format='json') + response = self.client.post(url, {'username': 'dummy.login.company', 'password': 'lalala123', 'login-type': 'company'}, + format='json') company_id = response.data.get('company').get('id') url = '/api/companies/' + str(company_id) + "/profile/" @@ -301,3 +302,6 @@ 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, {'website': 'www.huehue.com'}, format='multipart') + self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) \ No newline at end of file