From f407aa1d9cd88870ec7427e45540dfe41dca4bf9 Mon Sep 17 00:00:00 2001 From: RYAN NAUFAL PIOSCHA <ryan.naufal@ui.ac.id> Date: Mon, 7 Oct 2019 05:33:48 +0700 Subject: [PATCH] 1606884716 11 Menambahkan link website perusahaan --- .gitlab-ci.yml | 1 + assets/js/CompanyProfile.jsx | 1 + assets/js/__test__/CompanyProfile-test.jsx | 1 + assets/js/components/CompanyRegisterModal.jsx | 4 ++++ core/models/accounts.py | 1 + core/tests/test_accounts.py | 2 +- core/views/accounts.py | 5 +++-- 7 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 040e750d..53ce6292 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,6 +24,7 @@ test: - npm install - npm run build-production - pip install -r requirements.txt + - python manage.py makemigrations - python manage.py migrate - python manage.py test - npm run karma diff --git a/assets/js/CompanyProfile.jsx b/assets/js/CompanyProfile.jsx index 3c909b0f..e66b186d 100644 --- a/assets/js/CompanyProfile.jsx +++ b/assets/js/CompanyProfile.jsx @@ -22,6 +22,7 @@ export default class CompanyProfile extends React.Component { <h2>{ data.name }</h2> <h3>{ data.address }t</h3> <p>{ data.category } - { data.description }</p> + <p>{ data.website }</p> </div> </Container> </Segment> diff --git a/assets/js/__test__/CompanyProfile-test.jsx b/assets/js/__test__/CompanyProfile-test.jsx index e1a9d657..0a4e3dd2 100644 --- a/assets/js/__test__/CompanyProfile-test.jsx +++ b/assets/js/__test__/CompanyProfile-test.jsx @@ -25,6 +25,7 @@ const companyUser = { 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' }, supervisor: null, student: null, diff --git a/assets/js/components/CompanyRegisterModal.jsx b/assets/js/components/CompanyRegisterModal.jsx index 04cd735b..562b76ea 100644 --- a/assets/js/components/CompanyRegisterModal.jsx +++ b/assets/js/components/CompanyRegisterModal.jsx @@ -158,6 +158,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="address">Website</label> + <Input onChange={this.handleChange} placeholder="Website perusahaan anda" name="website" required /> + </Form.Field> <Modal.Actions style={{ textAlign: 'right' }}> <Button loading={this.state.loading} type="submit" color="blue"> <Icon name="checkmark" />Submit</Button> </Modal.Actions> diff --git a/core/models/accounts.py b/core/models/accounts.py index 310679ea..da8b6364 100644 --- a/core/models/accounts.py +++ b/core/models/accounts.py @@ -101,6 +101,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") + website = models.CharField(max_length=100, default="Belum ada link website") @property def name(self): diff --git a/core/tests/test_accounts.py b/core/tests/test_accounts.py index 0a59be29..6562147f 100644 --- a/core/tests/test_accounts.py +++ b/core/tests/test_accounts.py @@ -92,7 +92,7 @@ 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'} + tc_post = {'password': 'corporatepass', 'name':'tutuplapak', 'description':'menutup lapak', 'email': 'email@email.com', 'logo':'lalala', 'address':'alamat', 'category':'Perusahaan Jasa', 'website':'www.tutuplapak.com'} response = self.client.post(url, tc_post, format='multipart') self.assertEqual(response.status_code, status.HTTP_201_CREATED) diff --git a/core/views/accounts.py b/core/views/accounts.py index d95c1200..8cadcadf 100644 --- a/core/views/accounts.py +++ b/core/views/accounts.py @@ -240,7 +240,7 @@ class CompanyRegisterViewSet(viewsets.GenericViewSet): type: string """ data = {} - for attr in ['password', 'email', 'name', 'description', 'logo', 'address', 'category']: + for attr in ['password', 'email', 'name', 'description', 'logo', 'address', 'category', 'website']: data[attr] = request.data.get(attr) if data[attr] is None: return Response({'error': attr+' is required'}, status=status.HTTP_400_BAD_REQUEST) @@ -258,7 +258,8 @@ class CompanyRegisterViewSet(viewsets.GenericViewSet): description=data['description'], logo=data['logo'], address=data['address'], - category=data['category'] + category=data['category'], + website=data['website'] ) user.save() company.save() -- GitLab