diff --git a/funding/bin/daemon.py b/funding/bin/daemon.py index f21ffee..cc89bbc 100644 --- a/funding/bin/daemon.py +++ b/funding/bin/daemon.py @@ -102,7 +102,8 @@ class Daemon: } data = self._make_request(data) - data = data['result'].get('in', []) + data = data['result'] + data = data.get('in', []) + data.get('pool', []) # filter by current proposal txs = [tx for tx in data if tx.get('address') == address['address']] @@ -130,13 +131,14 @@ class Daemon: data = { "method": "get_transfers", - "params": {"pool": True, "out": True, "account_index": index}, + "params": {"pool": False, "out": True, "account_index": index}, "jsonrpc": "2.0", "id": "0", } data = self._make_request(data) - data = data['result'].get('out', []) + data = data['result'] + data = data.get('out', []) + data.get('pool', []) # filter by current proposal txs = [tx for tx in data if tx.get('address') == address['address']] @@ -150,10 +152,10 @@ class Daemon: } def _make_request(self, data): - if self.username: - if self.password: - r = requests.post(self.url, auth=HTTPDigestAuth(settings.RPC_USERNAME, settings.RPC_PASSWORD), json=data, headers=self.headers) - else: - r = requests.post(self.url, json=data, headers=self.headers) + options = {'json': data, 'headers': self.headers} + if self.username and self.password: + options['auth'] = HTTPDigestAuth(settings.RPC_USERNAME, settings.RPC_PASSWORD) + + r = requests.post(self.url, **options) r.raise_for_status() - return r.json() \ No newline at end of file + return r.json() diff --git a/funding/bin/utils.py b/funding/bin/utils.py index 3ba8672..0602b91 100644 --- a/funding/bin/utils.py +++ b/funding/bin/utils.py @@ -30,7 +30,7 @@ class Summary: 'coin-btc': coin_btc_value(), 'btc-usd': price_cmc_btc_usd() } - cache.set(cache_key, data=data, expiry=7200) + cache.set(cache_key, data=data, expiry=1200) g.coin_prices = data return data diff --git a/funding/cache.py b/funding/cache.py index 1878a9e..b5c308f 100644 --- a/funding/cache.py +++ b/funding/cache.py @@ -57,5 +57,5 @@ class WowCache: except: return {} - def set(self, key: str, data: dict, expiry = 300): + def set(self, key: str, data: dict, expiry=300): self._cache.set(key, json.dumps(data, default=json_encoder), ex=expiry) diff --git a/funding/orm/orm.py b/funding/orm/orm.py index 6ccc5a7..66af310 100644 --- a/funding/orm/orm.py +++ b/funding/orm/orm.py @@ -196,7 +196,7 @@ class Proposal(base): if not isinstance(data, dict): print('error; get_transfers_in; %d' % self.id) return rtn - cache.set(cache_key, data=data, expiry=300) + cache.set(cache_key, data=data, expiry=60) except Exception as ex: print('error; get_transfers_in; %d' % self.id) return rtn @@ -241,12 +241,14 @@ class Proposal(base): if not isinstance(data, dict): print('error; get_transfers_out; %d' % self.id) return rtn - cache.set(cache_key, data=data, expiry=300) + cache.set(cache_key, data=data, expiry=60) except: 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/static/css/wow.css b/funding/static/css/wow.css index b1944a6..50151aa 100644 --- a/funding/static/css/wow.css +++ b/funding/static/css/wow.css @@ -135,12 +135,12 @@ body { } .table-hover tbody tr:hover { - background-color: rgba(0,0,0,.075); + background-color: rgba(0,0,0,.055); } .table th, .table td { - border-top: 1px solid #008926; - padding-top: .3rem; + border-top: 1px solid #00000029; + padding-top: .65rem; } .table-tilted{ @@ -169,7 +169,7 @@ body { } .table thead th { - border-bottom: 1px solid #008926 !important; + border-bottom: 1px solid #00000029 !important; border-top: none; font-size: 14px; } @@ -612,4 +612,8 @@ ul.b { .proposal_qr{ margin-top:8px; margin-bottom:8px; +} + +.table-proposal tr { + background: #00000005; } \ No newline at end of file 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/macros/table.html b/funding/templates/proposal/macros/table.html index 5d1c372..8efc515 100644 --- a/funding/templates/proposal/macros/table.html +++ b/funding/templates/proposal/macros/table.html @@ -2,7 +2,7 @@ - + {% if _proposals and _proposals[0].status >= 2 %} diff --git a/funding/templates/proposal/proposal.html b/funding/templates/proposal/proposal.html index 05a82cc..bcd7cec 100644 --- a/funding/templates/proposal/proposal.html +++ b/funding/templates/proposal/proposal.html @@ -51,7 +51,6 @@ {% endif %}

-
{% if proposal.status in [2,3] %}
@@ -96,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 %} +
@@ -113,7 +115,7 @@
{{proposal.spends['spent']|round(3) or 0}} WOW Paid out
-
+

@@ -124,12 +126,11 @@
-

-
+
Donation address:
{% if proposal.addr_donation %}{{ proposal.addr_donation }}{% else %}None generated yet{% endif %}
@@ -203,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 %}
{{title}}{{title}} Username Date