Skip to content

Commit

Permalink
[STTNHUB-219] fix(locations): Format address using city and state att…
Browse files Browse the repository at this point in the history
…ributes (#266)

* [STTNHUB-219] fix(locations): Format address using city and state attributes

* fix flake8

* Remove useless brackets

* Remove duplicate function
  • Loading branch information
MarkLark86 authored Jan 12, 2023
1 parent 28898c7 commit b2398b7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 23 deletions.
4 changes: 2 additions & 2 deletions assets/agenda/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ export function getLocationString(item) {
return [
get(item, 'location.0.name', get(item, 'location.0.address.title')),
get(item, 'location.0.address.line.0'),
get(item, 'location.0.address.area'),
get(item, 'location.0.address.locality'),
get(item, 'location.0.address.city') || get(item, 'location.0.address.area'),
get(item, 'location.0.address.state') || get(item, 'location.0.address.locality'),
get(item, 'location.0.address.postal_code'),
get(item, 'location.0.address.country'),
].filter((d) => d).join(', ');
Expand Down
2 changes: 1 addition & 1 deletion assets/maps/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function getAddressLine(location) {
* @param {Object} location
*/
export function getAddressState(location) {
return get(location, 'address.locality');
return get(location, 'address.state') || get(location, 'address.locality');
}

/**
Expand Down
18 changes: 0 additions & 18 deletions newsroom/agenda/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,6 @@ def get_agenda_dates(agenda):
return "{} - {}, {}".format(time_short(start), time_short(end), date_short(start))


def get_location_string(agenda):
location = agenda.get("location", [])

if not location:
return ""

location_items = [
location[0].get("name"),
location[0].get("address", {}).get("line", [""])[0],
location[0].get("address", {}).get("area"),
location[0].get("address", {}).get("locality"),
location[0].get("address", {}).get("postal_code"),
location[0].get("address", {}).get("country"),
]

return ", ".join([location_part for location_part in location_items if location_part])


def get_public_contacts(agenda):
contacts = agenda.get("event", {}).get("event_contact_info", [])
public_contacts = []
Expand Down
4 changes: 2 additions & 2 deletions newsroom/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ def get_location_string(agenda):
location_items = [
location[0].get("name"),
location[0].get("address", {}).get("line", [""])[0],
location[0].get("address", {}).get("area"),
location[0].get("address", {}).get("locality"),
location[0].get("address", {}).get("city") or location[0].get("address", {}).get("area"),
location[0].get("address", {}).get("state") or location[0].get("address", {}).get("locality"),
location[0].get("address", {}).get("postal_code"),
location[0].get("address", {}).get("country"),
]
Expand Down

0 comments on commit b2398b7

Please sign in to comment.