diff --git a/assets/js/CompanyProfile.jsx b/assets/js/CompanyProfile.jsx index 5ba41057ad05093770b2a27fb783ddad278ac446..0d5d70a3965ab79a8fecb3047c0a10a436ae8f2c 100755 --- a/assets/js/CompanyProfile.jsx +++ b/assets/js/CompanyProfile.jsx @@ -26,6 +26,8 @@ export default class CompanyProfile extends React.Component { constructor(props) { super(props); let data = TopMenu.getInfo(this.props.user); + console.log("ASdasdadasda"); + console.log(data); this.state = { id: this.props.user.data.company.id, name: data.name, @@ -34,6 +36,7 @@ export default class CompanyProfile extends React.Component { description: data.description, website: data.website, logo: data.logo, + linkedin_url: data.linkedin_url, loading: false, form: { name: '', @@ -48,6 +51,14 @@ export default class CompanyProfile extends React.Component { this.getProfile = this.getProfile.bind(this); this.handleChange = this.handleChange.bind(this); this.handleSubmit = this.handleSubmit.bind(this); + Server.get( + `/companies/${this.state.id}/` + ).then( + (result) => { + console.log("ASDADS"); + this.setState({ linkedin_url : result.linkedin_url}) + } + ); Server.get( `/companies/${this.props.user.data.company.id}/vacancies/`, false, @@ -65,6 +76,7 @@ export default class CompanyProfile extends React.Component { getProfile() { return Server.get(`/companies/${this.state.id}/`).then( (result) => { + console.log(result); this.setState({ name: result.name, address: result.address, @@ -73,6 +85,7 @@ export default class CompanyProfile extends React.Component { description: result.description, refresh: this.state.refresh + 1, website: result.website, + linkedin_url: result.linkedin_url, }); if (result.logo != '') { this.setState({ logo: result.logo }); @@ -161,6 +174,14 @@ export default class CompanyProfile extends React.Component { {this.state.category} - {this.state.description} </p> <p>{this.state.website}</p> + {this.state.linkedin_url ? ( + <a href={this.state.linkedin_url}> + {' '} + {this.state.linkedin_url}{' '} + </a> + ) : ( + <p> Belum ada link LinkedIn</p> + )} </div> </Container> <Container textAlign="center" className="statistik"> @@ -232,6 +253,17 @@ export default class CompanyProfile extends React.Component { } /> </Form.Field> + <Form.Field> + <label htmlFor="linkedin_url">LinkedIn URL</label> + <input + placeholder="LinkedIn URL" + name="linkedin_url" + onChange={this.handleChange} + defaultValue={ + this.state.linkedin_url === null ? null : this.state.linkedin_url + } + /> + </Form.Field> <Button type="submit" size="small" diff --git a/assets/js/__test__/CompanyProfile-test.jsx b/assets/js/__test__/CompanyProfile-test.jsx index 2a604c3d3903c03870f9c6dfc45d9ca7a0e9caed..012761e8aee3fe213c34a5f82e540c3ca18fb3ba 100755 --- a/assets/js/__test__/CompanyProfile-test.jsx +++ b/assets/js/__test__/CompanyProfile-test.jsx @@ -25,7 +25,8 @@ 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', + linkedin_url: 'Belum ada LinkedIn URL', }, supervisor: null, student: null, @@ -57,13 +58,14 @@ describe('CompanyProfile', () => { 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); + expect(profile.state.linkedin_url).to.equal(companyUserVerified.data.company.linkedin_url); }); }); 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', linkedin_url:'https://www.linkedin.com/in/bob/'}; const submitButton = ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Input')[1]; ReactTestUtils.Simulate.click(submitButton); diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py index a7c0ddd2778159eaacb709b091530123ff5885e6..b0c0786fa8fd8dc556cacacb8f9531455f042861 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 12:53 +# Generated by Django 1.11.17 on 2019-11-15 13:23 from __future__ import unicode_literals import core.lib.validators @@ -39,6 +39,7 @@ class Migration(migrations.Migration): ('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)), + ('linkedin_url', models.URLField(blank=True, null=True)), ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], options={ diff --git a/core/models/accounts.py b/core/models/accounts.py index 2f62d32983eb488528bbd00879f1bc088f0307ed..652e5f663fafdbdb062b73ae7f9d2222e8f14fc8 100755 --- a/core/models/accounts.py +++ b/core/models/accounts.py @@ -145,6 +145,7 @@ class Company(models.Model): address = models.CharField(max_length=1000, blank=True, null=True) category = models.CharField(max_length=140, default="Belum ada kategori perusahaan") website = models.CharField(max_length=100, default="Belum ada link website") + linkedin_url = models.URLField(max_length=200,blank=True, null=True) @property def name(self): diff --git a/core/serializers/accounts.py b/core/serializers/accounts.py index 4488485f2f2ded647e7b517400c9cc1dc7d5dafd..d88ee57da28e55e5b2a76a8787e7391bf725987b 100755 --- a/core/serializers/accounts.py +++ b/core/serializers/accounts.py @@ -157,6 +157,7 @@ class CompanyUpdateSerializer(serializers.ModelSerializer): 'description': instance.description, 'name': instance.user.first_name, 'website' : instance.website, + 'linkedin_url' : instance.linkedin_url } def update(self, instance, validated_data): @@ -166,13 +167,14 @@ class CompanyUpdateSerializer(serializers.ModelSerializer): 'description', instance.description) instance.user.first_name = validated_data.get( 'name', instance.user.first_name) + instance.linkedin_url = validated_data.get('linkedin_url', instance.linkedin_url) instance.save() instance.user.save() return instance class Meta: model = Company - fields = ['address', 'description', 'name' , 'website'] + fields = ['address', 'description', 'name' , 'website', 'linkedin_url'] class CompanySerializer(serializers.ModelSerializer): diff --git a/core/tests/test_accounts.py b/core/tests/test_accounts.py index 312a18fd2df5879256aaa2c2689b067ea97a21ad..36236c551471e052c9ee7de6cff080ac954f8581 100755 --- a/core/tests/test_accounts.py +++ b/core/tests/test_accounts.py @@ -406,3 +406,9 @@ class ProfileUpdateTests(APITestCase): response = self.client.patch(url, {'website': 'www.huehue.com'}, format='multipart') self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) + + response = self.client.patch(url, {'linkedin_url': 'https://www.linkedin.com/company/bob'}, format='multipart') + self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) + + response = self.client.patch(url, {'linkedin_url': 'this is not valid url'}, format='multipart') + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)