Order reviewers configurable (COFFER_ORDER_REVIEWERS), default agent:leora
This commit is contained in:
parent
910e7fbe07
commit
c46842f863
@ -10,6 +10,13 @@ from coffer.units import ACCOUNT_COFFER, agent_account, human_account, to_subuni
|
|||||||
ACCOUNT_ESCROW = "company:coffer-escrow" # held credit for orders waiting for review
|
ACCOUNT_ESCROW = "company:coffer-escrow" # held credit for orders waiting for review
|
||||||
MAX_PENDING_ORDERS_PER_ACCOUNT = 2
|
MAX_PENDING_ORDERS_PER_ACCOUNT = 2
|
||||||
ORDER_REVIEWERS = frozenset({"agent:leora"}) # the operator; only it accepts or rejects orders
|
ORDER_REVIEWERS = frozenset({"agent:leora"}) # the operator; only it accepts or rejects orders
|
||||||
|
|
||||||
|
|
||||||
|
def order_reviewers() -> frozenset[str]:
|
||||||
|
"""The operator account(s). A deployment with a different operator sets COFFER_ORDER_REVIEWERS."""
|
||||||
|
import os
|
||||||
|
extra = {a.strip() for a in os.environ.get("COFFER_ORDER_REVIEWERS", "").split(",") if a.strip()}
|
||||||
|
return frozenset(extra) if extra else ORDER_REVIEWERS
|
||||||
ORDER_REVIEW_NOTICE = ("Your order is waiting for confirmation. We review every order and accept or reject it "
|
ORDER_REVIEW_NOTICE = ("Your order is waiting for confirmation. We review every order and accept or reject it "
|
||||||
"based on stock and volume. If it's rejected, your credits are released in full.")
|
"based on stock and volume. If it's rejected, your credits are released in full.")
|
||||||
|
|
||||||
@ -181,7 +188,7 @@ class Store:
|
|||||||
return sum(o.held for o in self.pending_orders(buyer_id))
|
return sum(o.held for o in self.pending_orders(buyer_id))
|
||||||
|
|
||||||
def _review(self, order_id: str, actor: str) -> Order:
|
def _review(self, order_id: str, actor: str) -> Order:
|
||||||
if actor not in ORDER_REVIEWERS:
|
if actor not in order_reviewers():
|
||||||
raise NotAReviewer(actor)
|
raise NotAReviewer(actor)
|
||||||
order = self.orders.get(order_id)
|
order = self.orders.get(order_id)
|
||||||
if order is None:
|
if order is None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user