Some template changes

refactor
Sander Ferdinand 6 years ago
parent 470173db63
commit 92eac2ee20
No known key found for this signature in database
GPG Key ID: 7BBC83D7A8810AAB

@ -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

@ -1,3 +1,5 @@
{% from 'proposal/macros/comment.html' import comment_entry %}
<div class="row">
<div class="col-md-12">
<div class="card my-6" id="incoming_txs">
@ -18,69 +20,14 @@
<input type="submit" value="add comment">
</form>
{% else %}
You need to be logged in to comment.
You need to be <a href="{{ url_for('login') }}">logged in</a> to comment.
<br>
{% endif %}
<br>
{% for c in proposal._comments %}
<!-- Single Comment -->
<div class="media mb-4 comment-container" id="comment-{{c.id}}">
<div class="votearrow" title="upvote"></div>
<div class="media-body">
<span class="username">
<a href="/user/{{ c.user.username }}">
{{c.user.username}}
{% if c.user.username == proposal.user.username %}
<small>[op]</small>
{% endif %}
{% if c.user.admin %}
<small>[admin]</small>
{% endif %}
</a>
</span>
<span class="date_posted">
<a href="/proposal/{{proposal.id}}#comment-{{c.id}}">
{{c.date_added.strftime('%Y-%m-%d %H:%M')}}
</a>
</span><br>
<span data-id="{{c.id}}" class="body" style="{% if c.automated %}color:blue;{% endif %};word-break: break-all;">{{c.message}}</span>
<br>
{% if not c.automated %}
<a class="reply" href="{{url_for('propsal_comment_reply', cid=c.id, pid=proposal.id)}}">reply</a>
{% endif %}
{% for _c in c.comments %}
<div class="media mt-4 comment-container" id="comment-{{_c.id}}">
<div class="votearrow" title="upvote"></div>
<div class="media-body" id="comment">
<span class="username">
<a href="/user/{{ _c.user.username }}">
{{_c.user.username}}
{% if _c.user.username == proposal.user.username %}
<small>[op]</small>
{% endif %}
{% if _c.user.admin %}
<small>[admin]</small>
{% endif %}
</a>
</span>
<span class="date_posted">
<a href="/proposal/{{proposal.id}}#comment-{{_c.id}}">
{{_c.date_added.strftime('%Y-%m-%d %H:%M')}}
</a>
</span>
<br>
<span data-id="{{_c.id}}" class="body" style="word-break: break-all;">
{{_c.message}}
</span>
</div>
</div>
{% endfor %}
</div>
</div>
{% for c in proposal._comments if not c.automated %}
{{ comment_entry(c, proposal) }}
{% endfor %}
</div>
</div>

@ -95,11 +95,14 @@
</div>
<div class="col-lg-8">
{{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 %}
<div class="progress">
<div class="progress-bar progress-warning progress-bar" style="width: {{proposal.balance['pct']}}%;">
</div>
@ -112,7 +115,7 @@
<div class="col-lg-8">
{{proposal.spends['spent']|round(3) or 0}} WOW Paid out
<div class="progress">
<div class="progress-bar progress-warning progress-bar" style="width: {{proposal.spends['spent_remaining_pct']}}%;">
<div class="progress-bar progress-warning progress-bar" style="width: {{proposal.spends['remaining_pct']}}%;">
</div>
</div>
<hr>
@ -201,36 +204,51 @@
{% endif %}
{% if proposal.spends['txs'] %}
{% if proposal.spends['txs'] %}
<div class="row">
<div class="col-md-12">
<div class="card my-6" id="incoming_txs">
<h5 class="card-header">Outgoing transactions <small>({{proposal.spends['txs']|length}})</small></h5>
<div class="card-body">
<ul class="list-group">
{% for tx in proposal.spends['txs'] %}
<li class="list-group-item">
{{tx['datetime'].strftime('%Y-%m-%d %H:%M')}}
<span style="float:right"><b>Blockheight</b>: {{tx['height']}}</span>
<br>
<a target="_blank" href="https://explore.wownero.com/tx/{{tx['txid']}}">{{tx['txid'][:32]}}...</a>
<span style="float:right;color:#890000;font-weight:bold;">
- {{tx['amount_human']|round(3)}} WOW
{% if 'amount_usd' in tx %}
<small style="color: black">
➞ $ {{tx['amount_usd']}}
</small>
{% endif %}
</span>
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
<!-- /.row -->
{% endif %}
{% from 'proposal/macros/comment.html' import comment_entry %}
<div class="row">
<div class="col-md-12">
<div class="card my-6" id="incoming_txs">
<h5 class="card-header">Outgoing transactions <small>({{proposal.spends['txs']|length}})</small></h5>
<div class="card-body">
<ul class="list-group">
{% for tx in proposal.spends['txs'] %}
<li class="list-group-item">
{{tx['datetime'].strftime('%Y-%m-%d %H:%M')}}
<span style="float:right"><b>Blockheight</b>: {{tx['height']}}</span>
<br>
<a target="_blank" href="https://explore.wownero.com/tx/{{tx['txid']}}">{{tx['txid'][:32]}}...</a>
<span style="float:right;color:#890000;font-weight:bold;">
- {{tx['amount_human']|round(3)}} WOW
{% if 'amount_usd' in tx %}
<small style="color: black">
➞ $ {{tx['amount_usd']}}
</small>
{% endif %}
</span>
</li>
{% endfor %}
</ul>
<h5 id="comments" class="card-header">Events</h5>
<div class="card-body comments-panel">
{% for c in proposal._comments if c.automated %}
{{ comment_entry(c, proposal) }}
{% endfor %}
</div>
</div>
</div>
</div>
<!-- /.row -->
{% endif %}
</div>
<script>

Loading…
Cancel
Save