Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -385,7 +385,9 @@ class BalController:
|
||||
tx["heirsvalue"] = txs[txid].heirsvalue
|
||||
tx["description"] = txs[txid].description
|
||||
tx["willexecutor"] = copy_structure(txs[txid].willexecutor)
|
||||
tx["status"] = _("New")
|
||||
# Stored history: always English (translated only for display by
|
||||
# format_status_history); never _() here.
|
||||
tx["status"] = "New"
|
||||
tx["baltx_fees"] = txs[txid].tx_fees
|
||||
tx["time"] = creation_time
|
||||
tx["heirs"] = copy_structure(txs[txid].heirs)
|
||||
|
||||
@@ -1364,6 +1364,37 @@ class WillItem(Logger):
|
||||
# format_status_history() still translates them.
|
||||
LEGACY_STATUS_LABELS = (N_("New"),)
|
||||
|
||||
# Translations of "New" that test builds of the i18n work saved INTO the
|
||||
# status history (window.py / the CLI used ``_("New")`` when building).
|
||||
# They are mapped back to "New" on load so the history is language
|
||||
# neutral again. Keep in sync with the "New" msgstr of every catalog in
|
||||
# bal/locale (tests/test_core_status_language_neutral.py checks it).
|
||||
TRANSLATED_NEW_LABELS = ("Nuovo", "Nuevo")
|
||||
|
||||
# Fields that Willexecutors.get_willexecutor_transactions /
|
||||
# push_transactions_to_willexecutor used to write into the item's own
|
||||
# executor record (older versions); they are transient push data.
|
||||
TRANSIENT_PUSH_FIELDS = ("txs", "txsids", "broadcast_status")
|
||||
|
||||
@staticmethod
|
||||
def _untranslate_new_status(status):
|
||||
"""Map a translated leading "New" of a saved history back to "New"."""
|
||||
head, sep, rest = status.partition(".")
|
||||
if head in WillItem.TRANSLATED_NEW_LABELS:
|
||||
return "New" + sep + rest
|
||||
return status
|
||||
|
||||
@staticmethod
|
||||
def _without_transient_push_fields(we):
|
||||
"""Return ``we`` without the transient push fields (a copy if needed)."""
|
||||
if not isinstance(we, dict) or not any(
|
||||
k in we for k in WillItem.TRANSIENT_PUSH_FIELDS
|
||||
):
|
||||
return we
|
||||
return {
|
||||
k: v for k, v in we.items() if k not in WillItem.TRANSIENT_PUSH_FIELDS
|
||||
}
|
||||
|
||||
def set_status(self, status, value=True):
|
||||
"""Set a status flag and apply the related side effects.
|
||||
|
||||
@@ -1445,8 +1476,10 @@ class WillItem(Logger):
|
||||
w = data
|
||||
self.tx = Will.get_tx_from_any(w["tx"])
|
||||
self.heirs = w.get("heirs", None)
|
||||
self.we = w.get("willexecutor", None)
|
||||
self.status = w.get("status") or ""
|
||||
self.we = WillItem._without_transient_push_fields(
|
||||
w.get("willexecutor", None)
|
||||
)
|
||||
self.status = WillItem._untranslate_new_status(w.get("status") or "")
|
||||
self.description = w.get("description", None)
|
||||
self.time = w.get("time", None)
|
||||
self.change = w.get("change", None)
|
||||
|
||||
@@ -231,6 +231,13 @@ class Willexecutors:
|
||||
|
||||
@staticmethod
|
||||
def get_willexecutor_transactions(will, force=False):
|
||||
"""Group the valid, signed, not-yet-pushed will txs by will-executor.
|
||||
|
||||
Returns ``{url: executor_record}`` where each record gets ``txs`` (the
|
||||
raw txs, one per line) and ``txsids``.
|
||||
|
||||
The returned records are COPIES: the will items are never modified.
|
||||
"""
|
||||
willexecutors = {}
|
||||
for wid, willitem in will.items():
|
||||
if willitem.get_status("VALID"):
|
||||
@@ -240,10 +247,18 @@ class Willexecutors:
|
||||
url = willexecutor["url"]
|
||||
if willexecutor and Willexecutors.is_selected(willexecutor):
|
||||
if url not in willexecutors:
|
||||
willexecutor["txs"] = ""
|
||||
willexecutor["txsids"] = []
|
||||
willexecutor["broadcast_status"] = _("Waiting...")
|
||||
willexecutors[url] = willexecutor
|
||||
# Work on a COPY of the record: the item's
|
||||
# own ``we`` dict is saved in the wallet, so
|
||||
# the transient push fields below (raw txs,
|
||||
# txids and the - translated - broadcast
|
||||
# status shown in the push dialog) must
|
||||
# never end up in it (stored data must not
|
||||
# depend on the UI language, see bal/i18n.py).
|
||||
record = dict(willexecutor)
|
||||
record["txs"] = ""
|
||||
record["txsids"] = []
|
||||
record["broadcast_status"] = _("Waiting...")
|
||||
willexecutors[url] = record
|
||||
willexecutors[url]["txs"] += str(willitem.tx) + "\n"
|
||||
willexecutors[url]["txsids"].append(wid)
|
||||
|
||||
|
||||
@@ -551,7 +551,9 @@ class BalWindow:
|
||||
tx["heirsvalue"] = txs[txid].heirsvalue
|
||||
tx["description"] = txs[txid].description
|
||||
tx["willexecutor"] = copy_structure(txs[txid].willexecutor)
|
||||
tx["status"] = _("New")
|
||||
# Stored history: always English (translated only for display by
|
||||
# format_status_history); never _() here.
|
||||
tx["status"] = "New"
|
||||
tx["baltx_fees"] = txs[txid].tx_fees
|
||||
tx["time"] = creation_time
|
||||
tx["heirs"] = copy_structure(txs[txid].heirs)
|
||||
|
||||
Reference in New Issue
Block a user