diff --git a/assets/js/CompanyProfile.jsx b/assets/js/CompanyProfile.jsx index 4608142de36782cb5972ae4adec9f09a679cfa4f..daad07612077f4a6fd3c29956b02f190e686c3cc 100644 --- a/assets/js/CompanyProfile.jsx +++ b/assets/js/CompanyProfile.jsx @@ -7,6 +7,7 @@ import { Doughnut } from 'react-chartjs-2'; import Server from './lib/Server'; import Dumper from './lib/Dumper'; import ModalAlert from './components/ModalAlert'; +import DatePicker from "react-datepicker"; export default class CompanyProfile extends React.Component { static propTypes = { @@ -21,6 +22,7 @@ export default class CompanyProfile extends React.Component { address: this.props.user.data.company.address, category: this.props.user.data.company.category, description: this.props.user.data.company.description, + founded: this.props.user.data.company.founded, website: this.props.user.data.company.website, logo: this.props.user.data.company.logo, size: this.props.user.data.company.size, @@ -30,6 +32,7 @@ export default class CompanyProfile extends React.Component { name: '', address: '', description: '', + founded: '', website: '', size: '', }, @@ -61,6 +64,7 @@ export default class CompanyProfile extends React.Component { category: result.category, id: result.id, description: result.description, + founded: result.founded, refresh: this.state.refresh + 1, website: result.website, size: result.size, @@ -150,6 +154,9 @@ export default class CompanyProfile extends React.Component { - {this.state.description} </p> + <p> + Founded: {this.state.founded} + </p> <p>{this.state.website}</p> <p> {this.state.size} @@ -225,6 +232,17 @@ karyawan } /> </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> <label htmlFor="size">Jumlah karyawan</label> <input diff --git a/assets/js/components/CompanyRegisterModal.jsx b/assets/js/components/CompanyRegisterModal.jsx index d399e50fc9f93a694682330b7862a2db5df3d5b7..8832c2e256f0590de46a1afe188963fb44738976 100755 --- a/assets/js/components/CompanyRegisterModal.jsx +++ b/assets/js/components/CompanyRegisterModal.jsx @@ -193,6 +193,10 @@ export default class CompanyRegisterModal extends React.Component { <label htmlFor="description">Deskripsi</label> <TextArea onChange={this.handleChange} placeholder="Tell us more" name="description" autoHeight required /> </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> <label htmlFor="address">Alamat</label> <Input onChange={this.handleChange} placeholder="Alamat" name="address" required /> diff --git a/core/migrations/0003_company_founded.py b/core/migrations/0003_company_founded.py new file mode 100644 index 0000000000000000000000000000000000000000..e08d227a9a4ad0683852f0467d48af7c78558ddd --- /dev/null +++ b/core/migrations/0003_company_founded.py @@ -0,0 +1,18 @@ +# 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), + ), + ] diff --git a/core/migrations/0004_auto_20191206_1510.py b/core/migrations/0004_auto_20191206_1510.py new file mode 100644 index 0000000000000000000000000000000000000000..c070541976410c77e8af1d47246ba03269f8b5ca --- /dev/null +++ b/core/migrations/0004_auto_20191206_1510.py @@ -0,0 +1,18 @@ +# 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), + ), + ] diff --git a/core/models/accounts.py b/core/models/accounts.py index c9dddd8d4f5520433d90ab7148606a11bf50ec46..6077d2107310ef9c92b6c7b3873d4ff6019af257 100755 --- a/core/models/accounts.py +++ b/core/models/accounts.py @@ -161,6 +161,7 @@ class Company(models.Model): updated = models.DateTimeField(auto_now=True) user = models.OneToOneField(User, on_delete=models.CASCADE) description = models.TextField() + founded = models.DateField(blank=True, null=True) status = models.IntegerField(default=NEW, validators=[MaxValueValidator(2), MinValueValidator(0)]) logo = models.FileField(upload_to=get_company_logo_file_path, null=True, blank=True, validators=[validate_image_file_extension]) diff --git a/core/serializers/accounts.py b/core/serializers/accounts.py index c6c4bdcb1d19a53672a8ab6f71b041730e1cf26c..831814ee23cf1d0c6a858c92b6c8c5b983db52ce 100755 --- a/core/serializers/accounts.py +++ b/core/serializers/accounts.py @@ -175,6 +175,7 @@ class CompanyUpdateSerializer(serializers.ModelSerializer): return { 'address': instance.address, 'description': instance.description, + 'founded': instance.founded, 'name': instance.user.first_name, 'website': instance.website, 'linkedin_url': instance.linkedin_url, @@ -185,8 +186,8 @@ class CompanyUpdateSerializer(serializers.ModelSerializer): 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.description = validated_data.get('description', instance.description) + instance.founded = validated_data.get('founded', instance.founded) instance.user.first_name = validated_data.get( 'name', instance.user.first_name) instance.linkedin_url = validated_data.get('linkedin_url', instance.linkedin_url) @@ -196,7 +197,7 @@ class CompanyUpdateSerializer(serializers.ModelSerializer): class Meta: model = Company - fields = ['address', 'description', 'name', 'website', 'linkedin_url', 'size'] + fields = ['address', 'description', 'founded', 'name', 'website', 'linkedin_url', 'size'] class CompanySerializer(serializers.ModelSerializer): diff --git a/core/tests/test_accounts.py b/core/tests/test_accounts.py index fa65ad1b01c7719dc3249b8bb4ca9923900e1721..8debc4c76e66b8339e9d39a7b1d538fdaa48a68a 100755 --- a/core/tests/test_accounts.py +++ b/core/tests/test_accounts.py @@ -92,6 +92,7 @@ class RegisterTests(APITestCase): def test_create_and_recreate(self): url = '/api/register/' tc_post = {'password': 'corporatepass', 'name': 'tutuplapak', 'description': 'menutup lapak', + 'founded': '2019-01-01', 'email': 'email@email.com', 'logo': 'lalala', 'address': 'alamat', 'category': 'Perusahaan Jasa', 'website': 'www.tutuplapak.com', 'size': '1000'} @@ -486,6 +487,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, {'founded': '2019-01-01'}, 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)