From 48b584f0b32ecde0bbb5f251d1074ae66be7ab00 Mon Sep 17 00:00:00 2001
From: rayzaarasj <rayza.arasj@gmail.com>
Date: Fri, 15 Nov 2019 17:40:24 +0700
Subject: [PATCH 1/5] add test for new linkedin_url company

---
 core/tests/test_accounts.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/core/tests/test_accounts.py b/core/tests/test_accounts.py
index 312a18fd..36236c55 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)
-- 
GitLab


From f0413519a6b34b70d9e9cc8a515f1148eac69368 Mon Sep 17 00:00:00 2001
From: rayzaarasj <rayza.arasj@gmail.com>
Date: Fri, 15 Nov 2019 17:42:47 +0700
Subject: [PATCH 2/5] implement company profile linkedin_url backend

---
 core/migrations/0007_company_linkedin_url.py | 20 ++++++++++++++++++++
 core/models/accounts.py                      |  1 +
 core/serializers/accounts.py                 |  4 +++-
 3 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100644 core/migrations/0007_company_linkedin_url.py

diff --git a/core/migrations/0007_company_linkedin_url.py b/core/migrations/0007_company_linkedin_url.py
new file mode 100644
index 00000000..62345847
--- /dev/null
+++ b/core/migrations/0007_company_linkedin_url.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.17 on 2019-11-15 10:29
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('core', '0006_auto_20191115_1409'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='company',
+            name='linkedin_url',
+            field=models.URLField(blank=True, null=True),
+        ),
+    ]
diff --git a/core/models/accounts.py b/core/models/accounts.py
index 2f62d329..652e5f66 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 4488485f..d88ee57d 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):
-- 
GitLab


From 9f1cdd28f5b0e46f6bb32199724a45ae35102b53 Mon Sep 17 00:00:00 2001
From: rayzaarasj <rayza.arasj@gmail.com>
Date: Fri, 15 Nov 2019 20:08:36 +0700
Subject: [PATCH 3/5] add test for linkedin url frontend

---
 assets/js/__test__/CompanyProfile-test.jsx | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/assets/js/__test__/CompanyProfile-test.jsx b/assets/js/__test__/CompanyProfile-test.jsx
index 2a604c3d..012761e8 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);
 
-- 
GitLab


From f7310799886ea038fde965f8704c5c77557e91d9 Mon Sep 17 00:00:00 2001
From: rayzaarasj <rayza.arasj@gmail.com>
Date: Fri, 15 Nov 2019 20:08:50 +0700
Subject: [PATCH 4/5] implment fronend

---
 assets/js/CompanyProfile.jsx | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/assets/js/CompanyProfile.jsx b/assets/js/CompanyProfile.jsx
index 5ba41057..0d5d70a3 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"
-- 
GitLab


From 48c3d3e5773e29e7c2f78a5f60533508ab2620f5 Mon Sep 17 00:00:00 2001
From: rayzaarasj <rayza.arasj@gmail.com>
Date: Fri, 15 Nov 2019 20:23:51 +0700
Subject: [PATCH 5/5] reset migrations

---
 core/migrations/0001_initial.py              |  3 ++-
 core/migrations/0007_company_linkedin_url.py | 20 --------------------
 2 files changed, 2 insertions(+), 21 deletions(-)
 delete mode 100644 core/migrations/0007_company_linkedin_url.py

diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py
index a7c0ddd2..b0c0786f 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/migrations/0007_company_linkedin_url.py b/core/migrations/0007_company_linkedin_url.py
deleted file mode 100644
index 62345847..00000000
--- a/core/migrations/0007_company_linkedin_url.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by Django 1.11.17 on 2019-11-15 10:29
-from __future__ import unicode_literals
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
-    dependencies = [
-        ('core', '0006_auto_20191115_1409'),
-    ]
-
-    operations = [
-        migrations.AddField(
-            model_name='company',
-            name='linkedin_url',
-            field=models.URLField(blank=True, null=True),
-        ),
-    ]
-- 
GitLab