From 25caa397fdcebdaef7d2aac77017fd7df610694a Mon Sep 17 00:00:00 2001 From: Sander Ferdinand Date: Thu, 25 Oct 2018 22:26:23 +0200 Subject: [PATCH] Jinja2 macro for transaction items --- .../proposal/macros/transaction.html | 28 ++++++++++++++ funding/templates/proposal/proposal.html | 38 ++----------------- 2 files changed, 31 insertions(+), 35 deletions(-) create mode 100644 funding/templates/proposal/macros/transaction.html diff --git a/funding/templates/proposal/macros/transaction.html b/funding/templates/proposal/macros/transaction.html new file mode 100644 index 0000000..3b2866e --- /dev/null +++ b/funding/templates/proposal/macros/transaction.html @@ -0,0 +1,28 @@ +{% macro tx_item(tx) %} +
  • + + {{tx['datetime'].strftime('%Y-%m-%d %H:%M')}} + + + + Blockheight: {{tx['height']}} +
    + + {{tx['txid'][:32]}}... + + {% if tx['type'] == 'in' %} + + + {% else %} + - + {% endif %} + + {{tx['amount_human']|round(3)}} WOW + + {% if 'amount_usd' in tx %} + + ➞ $ {{tx['amount_usd']}} + + {% endif %} + +
  • +{% endmacro %} diff --git a/funding/templates/proposal/proposal.html b/funding/templates/proposal/proposal.html index bcd7cec..bff2ed4 100644 --- a/funding/templates/proposal/proposal.html +++ b/funding/templates/proposal/proposal.html @@ -165,12 +165,7 @@ {% include 'comments.html' %} - + {% from 'proposal/macros/transaction.html' import tx_item %} {% if proposal.balance['txs'] %}
    @@ -180,20 +175,7 @@
      {% for tx in proposal.balance['txs'] %} -
    • - {{tx['datetime'].strftime('%Y-%m-%d %H:%M')}} - Blockheight: {{tx['height']}} -
      - {{tx['txid'][:32]}}... - - + {{tx['amount_human']|round(3)}} WOW - {% if 'amount_usd' in tx %} - - ➞ $ {{tx['amount_usd']}} - - {% endif %} - -
    • + {{ tx_item(tx) }} {% endfor %}
    @@ -203,7 +185,6 @@ {% endif %} - {% if proposal.spends['txs'] %}
    @@ -212,20 +193,7 @@
      {% for tx in proposal.spends['txs'] %} -
    • - {{tx['datetime'].strftime('%Y-%m-%d %H:%M')}} - Blockheight: {{tx['height']}} -
      - {{tx['txid'][:32]}}... - - - {{tx['amount_human']|round(3)}} WOW - {% if 'amount_usd' in tx %} - - ➞ $ {{tx['amount_usd']}} - - {% endif %} - -
    • + {{ tx_item(tx) }} {% endfor %}