Fakultas Ilmu Komputer UI

Commit 7197922f authored by Hadlina Rahmadinni's avatar Hadlina Rahmadinni
Browse files

1606918566 123

parent ef1282a1
......@@ -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
......
......@@ -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);
......
......@@ -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 />
......
# -*- 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',
......
# -*- 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'),
),
]
......@@ -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)
......
......@@ -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):
......
......@@ -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)
......
......@@ -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()
......
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