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

Commit

Permalink
Correct Facility Parent Company link (#772)
Browse files Browse the repository at this point in the history
Correct Facility Parent Company link

Connects #729
  • Loading branch information
rajadain committed Sep 10, 2019
2 parents 372e62f + 6bdad93 commit 84a11f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix a bug which prevented the facility claims dashboard page header from loading [#778](https://github.com/open-apparel-registry/open-apparel-registry/pull/778)
- Fix a bug which prevented the vector tile marker layer from rendering [#782](https://github.com/open-apparel-registry/open-apparel-registry/pull/782)
- Capture infinite-scroll emitted bug in an ErrorBoundary in order not to crash the map component [#777](https://github.com/open-apparel-registry/open-apparel-registry/pull/777)
- Correct Facility Parent Company link [#772](https://github.com/open-apparel-registry/open-apparel-registry/pull/772)

### Security
- Fix several npm security vulnerabilities via GitHub dependabot [#792](https://github.com/open-apparel-registry/open-apparel-registry/pull/792)
Expand Down
36 changes: 13 additions & 23 deletions src/django/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
from waffle import switch_is_active


def _get_parent_company(claim):
if not claim or not claim.parent_company:
return None

return {
'id': claim.parent_company.admin.id,
'name': claim.parent_company.name,
}


class UserSerializer(ModelSerializer):
password = CharField(write_only=True)
name = SerializerMethodField()
Expand Down Expand Up @@ -432,14 +442,6 @@ def get_claim_info(self, facility):
.filter(status=FacilityClaim.APPROVED) \
.get(facility=facility)

if claim.parent_company:
parent_company = {
'id': claim.parent_company.admin.id,
'name': claim.parent_company.name,
}
else:
parent_company = None

return {
'id': claim.id,
'facility': {
Expand All @@ -450,7 +452,7 @@ def get_claim_info(self, facility):
'address': claim.facility_address,
'website': claim.facility_website
if claim.facility_website_publicly_visible else None,
'parent_company': parent_company,
'parent_company': _get_parent_company(claim),
'phone_number': claim.facility_phone_number
if claim.facility_phone_number_publicly_visible else None,
'minimum_order': claim.facility_minimum_order_quantity,
Expand Down Expand Up @@ -558,13 +560,7 @@ def get_notes(self, claim):
return data

def get_facility_parent_company(self, claim):
if not claim.parent_company:
return None

return {
'id': claim.parent_company.id,
'name': claim.parent_company.name,
}
return _get_parent_company(claim)


class FacilityClaimReviewNoteSerializer(ModelSerializer):
Expand Down Expand Up @@ -628,13 +624,7 @@ def get_facility_types(self, claim):
return FacilityClaim.FACILITY_TYPE_CHOICES

def get_facility_parent_company(self, claim):
if not claim.parent_company:
return None

return {
'id': claim.parent_company.id,
'name': claim.parent_company.name,
}
return _get_parent_company(claim)

def get_affiliation_choices(self, claim):
return FacilityClaim.AFFILIATION_CHOICES
Expand Down

0 comments on commit 84a11f8

Please sign in to comment.