mirror of https://gitlab.com/bashrc2/epicyon
Update valueflows for changes to fep-0837
parent
bb43d669ba
commit
83fb8754a5
29
shares.py
29
shares.py
|
@ -2078,10 +2078,7 @@ def _vf_share_id(share_id: str) -> str:
|
||||||
return share_id.replace('--', '/')
|
return share_id.replace('--', '/')
|
||||||
|
|
||||||
|
|
||||||
def vf_proposal_from_share(shared_item: {},
|
def vf_proposal_from_share(shared_item: {}, share_type: str) -> {}:
|
||||||
share_type: str,
|
|
||||||
publishes_direction: str,
|
|
||||||
reciprocal_direction: str) -> {}:
|
|
||||||
"""Returns a ValueFlows proposal from a shared item
|
"""Returns a ValueFlows proposal from a shared item
|
||||||
"""
|
"""
|
||||||
if not shared_item.get('shareId'):
|
if not shared_item.get('shareId'):
|
||||||
|
@ -2096,12 +2093,11 @@ def vf_proposal_from_share(shared_item: {},
|
||||||
"https://www.w3.org/ns/activitystreams",
|
"https://www.w3.org/ns/activitystreams",
|
||||||
{
|
{
|
||||||
"om2": om2_link,
|
"om2": om2_link,
|
||||||
"vf": "https://w3id.org/valueflows/ont/vf/",
|
"vf": "https://w3id.org/valueflows/ont/vf#",
|
||||||
"Proposal": "vf:Proposal",
|
"Proposal": "vf:Proposal",
|
||||||
"Intent": "vf:Intent",
|
"Intent": "vf:Intent",
|
||||||
"receiver": "vf:receiver",
|
|
||||||
"provider": "vf:provider",
|
|
||||||
"action": "vf:action",
|
"action": "vf:action",
|
||||||
|
"purpose": "vf:purpose",
|
||||||
"unitBased": "vf:unitBased",
|
"unitBased": "vf:unitBased",
|
||||||
"publishes": "vf:publishes",
|
"publishes": "vf:publishes",
|
||||||
"reciprocal": "vf:reciprocal",
|
"reciprocal": "vf:reciprocal",
|
||||||
|
@ -2111,7 +2107,8 @@ def vf_proposal_from_share(shared_item: {},
|
||||||
"hasNumericalValue": "om2:hasNumericalValue"
|
"hasNumericalValue": "om2:hasNumericalValue"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"type": share_type,
|
"type": "Proposal",
|
||||||
|
"purpose": share_type,
|
||||||
"id": share_id,
|
"id": share_id,
|
||||||
"attributedTo": actor_url,
|
"attributedTo": actor_url,
|
||||||
"name": shared_item['displayName'],
|
"name": shared_item['displayName'],
|
||||||
|
@ -2125,7 +2122,6 @@ def vf_proposal_from_share(shared_item: {},
|
||||||
"hasUnit": "one",
|
"hasUnit": "one",
|
||||||
"hasNumericalValue": str(shared_item['itemQty'])
|
"hasNumericalValue": str(shared_item['itemQty'])
|
||||||
},
|
},
|
||||||
publishes_direction: actor_url
|
|
||||||
},
|
},
|
||||||
"attachment": [],
|
"attachment": [],
|
||||||
"unitBased": False,
|
"unitBased": False,
|
||||||
|
@ -2177,8 +2173,7 @@ def vf_proposal_from_share(shared_item: {},
|
||||||
"resourceQuantity": {
|
"resourceQuantity": {
|
||||||
"hasUnit": "one",
|
"hasUnit": "one",
|
||||||
"hasNumericalValue": str(shared_item['itemPrice'])
|
"hasNumericalValue": str(shared_item['itemPrice'])
|
||||||
},
|
}
|
||||||
reciprocal_direction: actor_url
|
|
||||||
}
|
}
|
||||||
return offer_item
|
return offer_item
|
||||||
|
|
||||||
|
@ -2221,19 +2216,13 @@ def vf_proposal_from_id(base_dir: str, nickname: str, domain: str,
|
||||||
print('DEBUG: vf_proposal_from_id does not contain id ' + share_id)
|
print('DEBUG: vf_proposal_from_id does not contain id ' + share_id)
|
||||||
return {}
|
return {}
|
||||||
if shares_file_type == 'shares':
|
if shares_file_type == 'shares':
|
||||||
share_type = 'Proposal'
|
share_type = 'offer'
|
||||||
publishes_direction = "provider"
|
|
||||||
reciprocal_direction = "receiver"
|
|
||||||
else:
|
else:
|
||||||
share_type = 'Want'
|
share_type = 'request'
|
||||||
publishes_direction = "receiver"
|
|
||||||
reciprocal_direction = "provider"
|
|
||||||
shares_json[share_id]['shareId'] = share_id
|
shares_json[share_id]['shareId'] = share_id
|
||||||
shares_json[share_id]['actor'] = actor
|
shares_json[share_id]['actor'] = actor
|
||||||
return vf_proposal_from_share(shares_json[share_id],
|
return vf_proposal_from_share(shares_json[share_id],
|
||||||
share_type,
|
share_type)
|
||||||
publishes_direction,
|
|
||||||
reciprocal_direction)
|
|
||||||
|
|
||||||
|
|
||||||
def _is_valueflows_attachment(attach_item: {}) -> bool:
|
def _is_valueflows_attachment(attach_item: {}) -> bool:
|
||||||
|
|
|
@ -587,23 +587,16 @@ def get_shares_collection(actor: str, page_number: int, items_per_page: int,
|
||||||
shared_items_federated_domains, shares_file_type)
|
shared_items_federated_domains, shares_file_type)
|
||||||
|
|
||||||
if shares_file_type == 'shares':
|
if shares_file_type == 'shares':
|
||||||
share_type = 'Proposal'
|
share_type = 'offer'
|
||||||
publishes_direction = "provider"
|
|
||||||
reciprocal_direction = "receiver"
|
|
||||||
collection_name = nickname + "'s Shared Items"
|
collection_name = nickname + "'s Shared Items"
|
||||||
else:
|
else:
|
||||||
share_type = 'Want'
|
share_type = 'request'
|
||||||
publishes_direction = "receiver"
|
|
||||||
reciprocal_direction = "provider"
|
|
||||||
collection_name = nickname + "'s Wanted Items"
|
collection_name = nickname + "'s Wanted Items"
|
||||||
|
|
||||||
for share_id, shared_item in shares_json.items():
|
for share_id, shared_item in shares_json.items():
|
||||||
shared_item['shareId'] = share_id
|
shared_item['shareId'] = share_id
|
||||||
shared_item['actor'] = actor
|
shared_item['actor'] = actor
|
||||||
offer_item = vf_proposal_from_share(shared_item,
|
offer_item = vf_proposal_from_share(shared_item, share_type)
|
||||||
share_type,
|
|
||||||
publishes_direction,
|
|
||||||
reciprocal_direction)
|
|
||||||
if offer_item:
|
if offer_item:
|
||||||
shares_collection.append(offer_item)
|
shares_collection.append(offer_item)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue