Representation of wanted items in shares collection

main
Bob Mottram 2023-08-20 15:03:28 +01:00
parent 3b5149e989
commit 331adbf34c
1 changed files with 9 additions and 3 deletions

View File

@ -657,8 +657,14 @@ def get_shares_collection(actor: str, page_number: int, items_per_page: int,
if shares_file_type == 'shares': if shares_file_type == 'shares':
share_type = 'Proposal' share_type = 'Proposal'
publishes_direction = "provider"
reciprocal_direction = "receiver"
collection_name = nickname + "'s Shared Items"
else: else:
share_type = 'Want' share_type = 'Want'
publishes_direction = "receiver"
reciprocal_direction = "provider"
collection_name = nickname + "'s Wanted Items"
for _, shared_item in shares_json.items(): for _, shared_item in shares_json.items():
if not shared_item.get('shareId'): if not shared_item.get('shareId'):
@ -704,7 +710,7 @@ def get_shares_collection(actor: str, page_number: int, items_per_page: int,
"hasUnit": "one", "hasUnit": "one",
"hasNumericalValue": str(shared_item['itemQty']) "hasNumericalValue": str(shared_item['itemQty'])
}, },
"provider": shared_item['actor'] publishes_direction: shared_item['actor']
}, },
"attachment": [], "attachment": [],
"unitBased": False, "unitBased": False,
@ -757,7 +763,7 @@ def get_shares_collection(actor: str, page_number: int, items_per_page: int,
"hasUnit": "one", "hasUnit": "one",
"hasNumericalValue": str(shared_item['itemPrice']) "hasNumericalValue": str(shared_item['itemPrice'])
}, },
"receiver": shared_item['actor'] reciprocal_direction: shared_item['actor']
} }
shares_collection.append(offer_item) shares_collection.append(offer_item)
@ -768,7 +774,7 @@ def get_shares_collection(actor: str, page_number: int, items_per_page: int,
], ],
"id": actor + '?page=' + str(page_number), "id": actor + '?page=' + str(page_number),
"type": "OrderedCollection", "type": "OrderedCollection",
"name": nickname + "'s Shared Items", "name": collection_name,
"orderedItems": shares_collection "orderedItems": shares_collection
} }