Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.

9 downloads

Install on DigitalOcean Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-server.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-server.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-server.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Daniel Quellhorst Changelog for this batch. 65ef78d 3 hours, 49 minutes ago History
exchange_resolve.py · 2.5 KB · 49 lines
1"""action_exchange_resolve -- a person decides on a document a partner sent.
2
3POST {inbox_id, decision: accept | reject | refuse, note?}
4
5refuse (any document, with a note saying why): the sender is told with a
6signed document_refusal naming the document, which its box records against
7what it sent ("Refused by <us>: <why>" on its invoice or order, attention
8there); here the decision is recorded and a bill made from a refused invoice
9is disputed. Nothing is recorded unless the sender was told.
10
11accept and reject are for an order confirmation that differs:
12
13A seller's order confirmation is compared with our purchase order line by
14line (quantity, unit, unit price; lines rejected, missing or added) and,
15when anything differs, waits in the inbox as needs_attention with every
16difference listed. Nothing changes our order until a person decides here:
17
18- accept: our purchase order becomes what the seller confirmed, through
19 recorded changes. Each line write carries this person's name in the change
20 log (actor exchange-accept:<user>); rejected lines go to quantity 0 and
21 stay visible; added lines are added; the order's totals are stamped from
22 its lines. The differences are recomputed from the stored, signed document
23 against the order as it stands now, so what is applied is what was shown.
24- reject: our order stays as it is.
25
26Either way the inbox row records the decision, who made it and when, and
27leaves the attention queue. Staff only (an admin, the owner role or
28role:manager) who may update the order -- the object checks both, because
29every write it makes is a trusted storage-level write.
30"""
31
32import object_exchange
33import object_exchange_box as box
34
35
36def POST(request):
37 try:
38 if str(request.get("decision") or "") == "refuse":
39 return box.refuse_document(box.base_dir(), request.get("inbox_id") or "",
40 request.get("_identity"),
41 reason=str(request.get("note") or ""))
42 return box.resolve_confirmation(box.base_dir(), request.get("inbox_id") or "",
43 request.get("_identity"),
44 decision=str(request.get("decision") or ""),
45 note=str(request.get("note") or ""))
46 except box.Refusal as refusal:
47 return refusal.answer()
48 except object_exchange.ExchangeUnavailable as exc:
49 return {"status": 409, "code": "exchange_unavailable", "error": str(exc)}