From 92eac2ee20e0343e5fa76fc6e813c8977f1b282a Mon Sep 17 00:00:00 2001 From: Sander Ferdinand Date: Sat, 20 Oct 2018 18:25:58 +0200 Subject: [PATCH] Some template changes --- funding/orm/orm.py | 10 ++-- funding/templates/comments.html | 63 ++------------------- funding/templates/proposal/proposal.html | 72 +++++++++++++++--------- 3 files changed, 56 insertions(+), 89 deletions(-) diff --git a/funding/orm/orm.py b/funding/orm/orm.py index 3114397..66af310 100644 --- a/funding/orm/orm.py +++ b/funding/orm/orm.py @@ -246,7 +246,9 @@ class Proposal(base): print('error; get_transfers_out; %d' % self.id) return rtn + data['remaining_pct'] = 0.0 prices = Summary.fetch_prices() + for tx in data['txs']: if prices: tx['amount_usd'] = coin_to_usd(amt=tx['amount_human'], btc_per_coin=prices['coin-btc'], usd_per_btc=prices['btc-usd']) @@ -259,10 +261,10 @@ class Proposal(base): data['pct'] = 0.0 data['spent'] = 0.0 - if data['spent']: - data['remaining_pct'] = 100 / float(data['sum'] / data['spent']) - else: - data['remaining_pct'] = 0.0 + cache_key_in = 'coin_balance_pid_%d' % self.id + data_in = cache.get(cache_key_in) + if data_in and data['spent']: + data['remaining_pct'] = 100 / float(data_in['sum'] / data['spent']) return data diff --git a/funding/templates/comments.html b/funding/templates/comments.html index a502051..a1bd5de 100644 --- a/funding/templates/comments.html +++ b/funding/templates/comments.html @@ -1,3 +1,5 @@ +{% from 'proposal/macros/comment.html' import comment_entry %} +
@@ -18,69 +20,14 @@ {% else %} - You need to be logged in to comment. + You need to be logged in to comment.
{% endif %}
- {% for c in proposal._comments %} - - + {% for c in proposal._comments if not c.automated %} + {{ comment_entry(c, proposal) }} {% endfor %}
diff --git a/funding/templates/proposal/proposal.html b/funding/templates/proposal/proposal.html index 1ea297b..bcd7cec 100644 --- a/funding/templates/proposal/proposal.html +++ b/funding/templates/proposal/proposal.html @@ -95,11 +95,14 @@
{{proposal.balance['available']|round(3) or 0 }} WOW Raised - {% if (proposal.funds_target-proposal.balance['available']|float|round(3)) > 0 %} - ({{ (proposal.funds_target-proposal.balance['available']|float|round(3)|int) }} WOW until goal) - {% else %} + {% set remaining = proposal.funds_target - proposal.balance['available']|float|round(3) %} + + {% if remaining > 0 %} + ({{ (proposal.funds_target - proposal.balance['available']|float|round(3)|int) }} WOW until goal) + {% elif remaining < 0 %} ({{ (proposal.balance['available']-proposal.funds_target|float|round(3)|int) }} WOW past goal!) {% endif %} +
@@ -112,7 +115,7 @@
{{proposal.spends['spent']|round(3) or 0}} WOW Paid out
-
+

@@ -201,36 +204,51 @@ {% endif %} -{% if proposal.spends['txs'] %} + {% if proposal.spends['txs'] %} +
+
+
+
Outgoing transactions ({{proposal.spends['txs']|length}})
+
+
    + {% 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 %} + +
  • + {% endfor %} +
+
+
+
+
+ + {% endif %} + + {% from 'proposal/macros/comment.html' import comment_entry %} +
-
Outgoing transactions ({{proposal.spends['txs']|length}})
-
-
    - {% 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 %} - -
  • - {% endfor %} -
+
Events
+
+ {% for c in proposal._comments if c.automated %} + {{ comment_entry(c, proposal) }} + {% endfor %}
- - {% endif %}