Fakultas Ilmu Komputer UI

Commit 1018172c authored by Rayza Arasj Mahardhika's avatar Rayza Arasj Mahardhika
Browse files

1606876052 146 Sebagai perusahaan, kami ingin menambahkan link company LinkedIn kami ke profil kami

parent b9717b01
......@@ -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"
......
......@@ -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);
......
# -*- 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={
......
......@@ -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):
......
......@@ -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):
......
......@@ -415,3 +415,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)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment