Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix location from ingested items display #697

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions assets/agenda/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {get, isEmpty, includes, keyBy, sortBy} from 'lodash';

Check warning on line 1 in assets/agenda/utils.ts

View workflow job for this annotation

GitHub Actions / client

'includes' is defined but never used
import moment from 'moment/moment';

import {IAgendaItem, IAgendaListGroup, IAgendaListGroupItem, ICoverage, IUser} from 'interfaces';
Expand Down Expand Up @@ -235,14 +235,19 @@
* @return {String}
*/
export function getLocationString(item: any) {
return [
get(item, 'location.0.name', get(item, 'location.0.address.title')),
get(item, 'location.0.address.line.0'),
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: any) => d).join(', ');
const location = item.location?.[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar changes would need to be done on the back-end too: https://github.com/superdesk/newsroom-core/blob/develop/newsroom/utils.py#L217 (this is mainly for emails)

const locationAddress = location?.address;

const locationArray: Array<string> = [
location?.name ?? locationAddress?.title ?? '',
locationAddress?.line?.[0] ?? '',
locationAddress?.city ?? locationAddress?.area ?? '',
locationAddress?.state ?? locationAddress?.locality ?? '',
locationAddress?.postal_code ?? '',
locationAddress?.country ?? '',
];

return locationArray.filter((d: string) => d != null && d.trim() != '').map((loc) => loc.trim()).join(', ');
}

/**
Expand Down
4 changes: 3 additions & 1 deletion newsroom/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ def get_location_string(agenda):
location[0].get("address", {}).get("country"),
]

return ", ".join([location_part for location_part in location_items if location_part])
return ", ".join(
[location_part.strip() for location_part in location_items if location_part and not location_part.isspace()]
)


def get_public_contacts(agenda):
Expand Down
Loading