Fakultas Ilmu Komputer UI

Commit 64b52d44 authored by Metta Anantha Pindika's avatar Metta Anantha Pindika
Browse files

Merge branch '1606876046-203' into 'master'

1606876046 203

See merge request !263
parents cab7b151 fb3e5c20
Pipeline #26778 passed with stages
in 45 minutes and 30 seconds
...@@ -7,6 +7,7 @@ import { Doughnut } from 'react-chartjs-2'; ...@@ -7,6 +7,7 @@ import { Doughnut } from 'react-chartjs-2';
import Server from './lib/Server'; import Server from './lib/Server';
import Dumper from './lib/Dumper'; import Dumper from './lib/Dumper';
import ModalAlert from './components/ModalAlert'; import ModalAlert from './components/ModalAlert';
import DatePicker from "react-datepicker";
export default class CompanyProfile extends React.Component { export default class CompanyProfile extends React.Component {
static propTypes = { static propTypes = {
...@@ -21,6 +22,7 @@ export default class CompanyProfile extends React.Component { ...@@ -21,6 +22,7 @@ export default class CompanyProfile extends React.Component {
address: this.props.user.data.company.address, address: this.props.user.data.company.address,
category: this.props.user.data.company.category, category: this.props.user.data.company.category,
description: this.props.user.data.company.description, description: this.props.user.data.company.description,
founded: this.props.user.data.company.founded,
website: this.props.user.data.company.website, website: this.props.user.data.company.website,
logo: this.props.user.data.company.logo, logo: this.props.user.data.company.logo,
size: this.props.user.data.company.size, size: this.props.user.data.company.size,
...@@ -30,6 +32,7 @@ export default class CompanyProfile extends React.Component { ...@@ -30,6 +32,7 @@ export default class CompanyProfile extends React.Component {
name: '', name: '',
address: '', address: '',
description: '', description: '',
founded: '',
website: '', website: '',
size: '', size: '',
}, },
...@@ -61,6 +64,7 @@ export default class CompanyProfile extends React.Component { ...@@ -61,6 +64,7 @@ export default class CompanyProfile extends React.Component {
category: result.category, category: result.category,
id: result.id, id: result.id,
description: result.description, description: result.description,
founded: result.founded,
refresh: this.state.refresh + 1, refresh: this.state.refresh + 1,
website: result.website, website: result.website,
size: result.size, size: result.size,
...@@ -150,6 +154,9 @@ export default class CompanyProfile extends React.Component { ...@@ -150,6 +154,9 @@ export default class CompanyProfile extends React.Component {
- -
{this.state.description} {this.state.description}
</p> </p>
<p>
Founded: {this.state.founded}
</p>
<p>{this.state.website}</p> <p>{this.state.website}</p>
<p> <p>
{this.state.size} {this.state.size}
...@@ -225,6 +232,17 @@ karyawan ...@@ -225,6 +232,17 @@ karyawan
} }
/> />
</Form.Field> </Form.Field>
<label htmlFor="founded">Founded:</label>
<input
name="founded"
placeholder="YYYY-MM-DD"
pattern="\d{4}\-\d{2}\-\d{2}"
onChange={this.handleChange}
defaultValue={
this.state.founded === null ? null : this.state.founded
}
/>
<Form.Field/>
<Form.Field> <Form.Field>
<label htmlFor="size">Jumlah karyawan</label> <label htmlFor="size">Jumlah karyawan</label>
<input <input
......
...@@ -193,6 +193,10 @@ export default class CompanyRegisterModal extends React.Component { ...@@ -193,6 +193,10 @@ export default class CompanyRegisterModal extends React.Component {
<label htmlFor="description">Deskripsi</label> <label htmlFor="description">Deskripsi</label>
<TextArea onChange={this.handleChange} placeholder="Tell us more" name="description" autoHeight required /> <TextArea onChange={this.handleChange} placeholder="Tell us more" name="description" autoHeight required />
</Form.Field> </Form.Field>
<Form.Field required>
<label htmlFor="founded">Founded</label>
<TextArea onChange={this.handleChange} placeholder="YYYY-MM-DD" name="founded" required />
</Form.Field>
<Form.Field required> <Form.Field required>
<label htmlFor="address">Alamat</label> <label htmlFor="address">Alamat</label>
<Input onChange={this.handleChange} placeholder="Alamat" name="address" required /> <Input onChange={this.handleChange} placeholder="Alamat" name="address" required />
......
# Generated by Django 2.2.8 on 2019-12-06 08:01
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0002_student_ielts'),
]
operations = [
migrations.AddField(
model_name='company',
name='founded',
field=models.DateTimeField(blank=True, null=True),
),
]
# Generated by Django 2.2.8 on 2019-12-06 08:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0003_company_founded'),
]
operations = [
migrations.AlterField(
model_name='company',
name='founded',
field=models.DateField(blank=True, null=True),
),
]
...@@ -161,6 +161,7 @@ class Company(models.Model): ...@@ -161,6 +161,7 @@ class Company(models.Model):
updated = models.DateTimeField(auto_now=True) updated = models.DateTimeField(auto_now=True)
user = models.OneToOneField(User, on_delete=models.CASCADE) user = models.OneToOneField(User, on_delete=models.CASCADE)
description = models.TextField() description = models.TextField()
founded = models.DateField(blank=True, null=True)
status = models.IntegerField(default=NEW, validators=[MaxValueValidator(2), MinValueValidator(0)]) status = models.IntegerField(default=NEW, validators=[MaxValueValidator(2), MinValueValidator(0)])
logo = models.FileField(upload_to=get_company_logo_file_path, null=True, blank=True, logo = models.FileField(upload_to=get_company_logo_file_path, null=True, blank=True,
validators=[validate_image_file_extension]) validators=[validate_image_file_extension])
......
...@@ -175,6 +175,7 @@ class CompanyUpdateSerializer(serializers.ModelSerializer): ...@@ -175,6 +175,7 @@ class CompanyUpdateSerializer(serializers.ModelSerializer):
return { return {
'address': instance.address, 'address': instance.address,
'description': instance.description, 'description': instance.description,
'founded': instance.founded,
'name': instance.user.first_name, 'name': instance.user.first_name,
'website': instance.website, 'website': instance.website,
'linkedin_url': instance.linkedin_url, 'linkedin_url': instance.linkedin_url,
...@@ -185,8 +186,8 @@ class CompanyUpdateSerializer(serializers.ModelSerializer): ...@@ -185,8 +186,8 @@ class CompanyUpdateSerializer(serializers.ModelSerializer):
instance.address = validated_data.get('address', instance.address) instance.address = validated_data.get('address', instance.address)
instance.website = validated_data.get('website', instance.website) instance.website = validated_data.get('website', instance.website)
instance.size = validated_data.get('size', instance.size) instance.size = validated_data.get('size', instance.size)
instance.description = validated_data.get( instance.description = validated_data.get('description', instance.description)
'description', instance.description) instance.founded = validated_data.get('founded', instance.founded)
instance.user.first_name = validated_data.get( instance.user.first_name = validated_data.get(
'name', instance.user.first_name) 'name', instance.user.first_name)
instance.linkedin_url = validated_data.get('linkedin_url', instance.linkedin_url) instance.linkedin_url = validated_data.get('linkedin_url', instance.linkedin_url)
...@@ -196,7 +197,7 @@ class CompanyUpdateSerializer(serializers.ModelSerializer): ...@@ -196,7 +197,7 @@ class CompanyUpdateSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Company model = Company
fields = ['address', 'description', 'name', 'website', 'linkedin_url', 'size'] fields = ['address', 'description', 'founded', 'name', 'website', 'linkedin_url', 'size']
class CompanySerializer(serializers.ModelSerializer): class CompanySerializer(serializers.ModelSerializer):
......
...@@ -92,6 +92,7 @@ class RegisterTests(APITestCase): ...@@ -92,6 +92,7 @@ class RegisterTests(APITestCase):
def test_create_and_recreate(self): def test_create_and_recreate(self):
url = '/api/register/' url = '/api/register/'
tc_post = {'password': 'corporatepass', 'name': 'tutuplapak', 'description': 'menutup lapak', tc_post = {'password': 'corporatepass', 'name': 'tutuplapak', 'description': 'menutup lapak',
'founded': '2019-01-01',
'email': 'email@email.com', 'email': 'email@email.com',
'logo': 'lalala', 'address': 'alamat', 'category': 'Perusahaan Jasa', 'logo': 'lalala', 'address': 'alamat', 'category': 'Perusahaan Jasa',
'website': 'www.tutuplapak.com', 'size': '1000'} 'website': 'www.tutuplapak.com', 'size': '1000'}
...@@ -486,6 +487,9 @@ class ProfileUpdateTests(APITestCase): ...@@ -486,6 +487,9 @@ class ProfileUpdateTests(APITestCase):
response = self.client.patch(url, {'description': 'Masak-Masak'}, format='multipart') response = self.client.patch(url, {'description': 'Masak-Masak'}, format='multipart')
self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
response = self.client.patch(url, {'founded': '2019-01-01'}, format='multipart')
self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
response = self.client.patch(url, {'size': '1000'}, format='multipart') response = self.client.patch(url, {'size': '1000'}, format='multipart')
self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED) self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
......
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