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

Check geocoded_point is not None when serializing other locations #861

Merged
merged 1 commit into from
Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Removed

### Fixed
Check geocoded_point is not None when serializing other locations [#861](https://github.com/open-apparel-registry/open-apparel-registry/pull/861)

### Security

Expand Down
1 change: 1 addition & 0 deletions src/django/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ def get_other_locations(self, facility):
.filter(is_active=True)
if l.facility_list_item != facility.created_from
if l.facility_list_item.geocoded_point != facility.location
if l.facility_list_item.geocoded_point is not None
if l.facility_list_item.facility_list.is_active
if l.facility_list_item.facility_list.is_public
]
Expand Down
12 changes: 12 additions & 0 deletions src/django/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3584,6 +3584,18 @@ def setUp(self):
confidence=0.85,
results='')

def test_excludes_match_if_geocoded_point_is_none(self):
self.other_list_item.geocoded_point = None
self.other_list_item.save()
response = self.client.get(
'/api/facilities/{}/'.format(self.facility.id)
)
data = json.loads(response.content)
self.assertEqual(
len(data['properties']['other_locations']),
0,
)

def test_serializes_other_match_location_in_facility_details(self):
response = self.client.get(
'/api/facilities/{}/'.format(self.facility.id)
Expand Down