Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
fixup three bugs
Browse files Browse the repository at this point in the history
- fix lint
- update validation test
- ensure workers count and female_workers_percentage are saved
  • Loading branch information
Kelly Innes committed Jul 11, 2019
1 parent 324b230 commit 6e649a0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 34 deletions.
1 change: 1 addition & 0 deletions src/app/src/__tests__/utils.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,7 @@ it('checks whether the claim a facility form is valid', () => {
label: 'label',
value: 'value',
},
jobTitle: 'computer programmer',
};

expect(isEqual(
Expand Down
16 changes: 10 additions & 6 deletions src/app/src/actions/claimedFacilityDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createAction } from 'redux-act';
import mapValues from 'lodash/mapValues';
import isNull from 'lodash/isNull';
import omit from 'lodash/omit';
import isInteger from 'lodash/isInteger';
import { isInt } from 'validator';

import apiRequest from '../util/apiRequest';
Expand Down Expand Up @@ -78,12 +79,15 @@ export function submitClaimedFacilityDetailsUpdate(claimID) {
],
),
{
facility_workers_count: isInt(data.facility_workers_count)
? data.facility_workers.count
: null,
facility_female_workers_percentage: isInt(data.facility_female_workers_percentage)
? data.facility_female_workers_percentage
: null,
facility_workers_count:
(isInteger(data.facility_workers_count) || isInt(data.facility_workers_count))
? data.facility_workers_count
: null,
facility_female_workers_percentage:
(isInteger(data.facility_female_workers_percentage) ||
isInt(data.facility_female_workers_percentage))
? data.facility_female_workers_percentage
: null,
},
);

Expand Down
56 changes: 28 additions & 28 deletions src/django/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,34 @@ def get_claimed_details(self, request, pk=None):

claim.parent_company = parent_company

claim = FacilityClaim \
.objects \
.get(pk=pk)

field_names = (
'facility_description',
'facility_name_english',
'facility_name_native_language',
'facility_address',
'facility_phone_number',
'facility_phone_number_publicly_visible',
'facility_website',
'facility_website_publicly_visible',
'facility_minimum_order_quantity',
'facility_average_lead_time',
'point_of_contact_person_name',
'point_of_contact_email',
'point_of_contact_publicly_visible',
'office_official_name',
'office_address',
'office_country_code',
'office_phone_number',
'office_info_publicly_visible',
)

for field_name in field_names:
setattr(claim, field_name, request.data.get(field_name))

try:
workers_count = int(request.data.get('facility_workers_count'))
except ValueError:
Expand Down Expand Up @@ -2067,34 +2095,6 @@ def get_claimed_details(self, request, pk=None):

claim.other_facility_type = other_facility_type

claim = FacilityClaim \
.objects \
.get(pk=pk)

field_names = (
'facility_description',
'facility_name_english',
'facility_name_native_language',
'facility_address',
'facility_phone_number',
'facility_phone_number_publicly_visible',
'facility_website',
'facility_website_publicly_visible',
'facility_minimum_order_quantity',
'facility_average_lead_time',
'point_of_contact_person_name',
'point_of_contact_email',
'point_of_contact_publicly_visible',
'office_official_name',
'office_address',
'office_country_code',
'office_phone_number',
'office_info_publicly_visible',
)

for field_name in field_names:
setattr(claim, field_name, request.data.get(field_name))

claim.save()

try:
Expand Down

0 comments on commit 6e649a0

Please sign in to comment.