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

Format and return alternate_place_names #608

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
7 changes: 7 additions & 0 deletions gramps_webapi/api/resources/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,13 @@ def get_place_profile_for_object(
"alternate_names": [
place_name.value for place_name in place.get_alternative_names()
],
"alternate_place_names": [
{
"value": place_name.value,
"date_str": locale.date_displayer.display(place_name.date),
}
for place_name in place.get_alternative_names()
],
"lat": float(latitude) if (latitude and longitude) else None,
"long": float(longitude) if (latitude and longitude) else None,
}
Expand Down
4 changes: 4 additions & 0 deletions tests/test_endpoints/test_places.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,15 @@ def test_get_places_handle_parameter_profile(self):
rv["profile"],
{
"alternate_names": [],
"alternate_place_names": [],
Copy link
Author

Choose a reason for hiding this comment

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

I wasn't sure how the test data is created. How can I create a Place with alt names?

Copy link
Author

Choose a reason for hiding this comment

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

@DavidMStraub can you point me in the right direction for setting up new test data?

Copy link
Author

Choose a reason for hiding this comment

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

Ah from the gramps example db. I will update the tests

"gramps_id": "P0860",
"lat": 33.6259414,
"long": -97.1333453,
"name": "Gainesville",
"parent_places": [
{
"alternate_names": [],
"alternate_place_names": [],
"gramps_id": "P0194",
"lat": 0,
"long": 0,
Expand All @@ -528,6 +530,7 @@ def test_get_places_handle_parameter_profile(self):
},
{
"alternate_names": [],
"alternate_place_names": [],
"gramps_id": "P0010",
"lat": 0,
"long": 0,
Expand All @@ -536,6 +539,7 @@ def test_get_places_handle_parameter_profile(self):
},
{
"alternate_names": [],
"alternate_place_names": [],
"gramps_id": "P0957",
"lat": 0,
"long": 0,
Expand Down