Skip to content

Commit

Permalink
Merge pull request #839 from Princeton-CDH/feature/export-location-wi…
Browse files Browse the repository at this point in the history
…th-name

Update address export to include location name
  • Loading branch information
rlskoeser authored Nov 14, 2024
2 parents a7e55f2 + 9353156 commit d8392e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions mep/accounts/management/commands/export_addresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def get_object_data(self, obj):
care_of_person_id=obj.care_of_person.slug if obj.care_of_person else None,
care_of_person_name=obj.care_of_person.name if obj.care_of_person else None,
# Location data
location_name=loc.name.strip(),
street_address=loc.street_address,
city=loc.city,
postal_code=loc.postal_code,
Expand Down
9 changes: 9 additions & 0 deletions mep/accounts/tests/test_accounts_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,8 @@ def test_get_object_data(self):
assert gay_data["start_date"] == "1919-01-01"
assert gay_data["end_date"] == "1930-01-01"
assert gay_data["care_of_person_id"] == "hemingway"
# location does not have a name
assert gay_data["location_name"] == ""

# without dates
self.cmd.include_dates = False
Expand All @@ -684,3 +686,10 @@ def test_get_object_data(self):
assert gay_data["members"][0]["sort_name"] == "Gay, Francisque"
assert gay_data["care_of_person_id"] == "hemingway"
assert gay_data["care_of_person_name"] == "Ernest Hemingway"

# add a location name to confirm it is included
loc = address.location
loc.name = "Le Hotel"
loc.save()
gay_data = self.cmd.get_object_data(address)
assert gay_data["location_name"] == loc.name

0 comments on commit d8392e7

Please sign in to comment.