Skip to content

Commit

Permalink
add transactions to pools in user admin
Browse files Browse the repository at this point in the history
fixes #190
  • Loading branch information
bradjc committed May 15, 2016
1 parent 9b67375 commit 81d40a4
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
42 changes: 41 additions & 1 deletion chezbetty/templates/admin/pool.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

<tbody>
{% for pu in pool.users %}
<tr id="pool_user-{{ pu.id }}" class="{% if pu.enabled == False %}disabled-row{% endif %}">
<tr id="pool_user-{{ pu.id }}" class="{% if pu.enabled == False %}disabled-row{% endif %}">
<td>{{ pu.user|make_link|safe }}</td>
<td>
{{ button.onoff_switch('pool_user', 'enabled', pu.id, pu.enabled) }}
Expand Down Expand Up @@ -74,4 +74,44 @@
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Transaction History</h3>
</div>
<div class="panel-body">

<table class="table table-bordered">
<thead>
<tr>
<th></th>
<th>Date</th>
<th>Type</th>
<th class="right">Amount</th>
</tr>
</thead>

<tbody>

{% for event in events %}

<tr>
<td>{{ button.event(event.id) }}</td>
<td>{{ event.timestamp|pretty_date|safe }}</td>
<td>{{ event.type }}</td>
<td class="right">{{ event.transactions[0].amount|format_currency|safe }}</td>
</tr>

{% endfor %}
</tbody>
</table>

{% if events_total %}
<a href="/admin/pool/{{ pool.id }}?event_limit=0#event_history">
Displaying 1-{{ events|length }} of {{ events_total }}. Click to show all.</p>
</a>
{% endif %}

</div>
</div>

{% endblock %}
8 changes: 7 additions & 1 deletion chezbetty/views_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2327,9 +2327,15 @@ def admin_pools(request):
def admin_pool(request):
try:
pool = Pool.from_id(request.matchdict['pool_id'])

events, events_total = limitable_request(
request, pool.get_events, prefix='event', limit=10, count=True)

return {'pool': pool,
'pool_owner': User.from_id(pool.owner),
'users': User.all()}
'users': User.all(),
'events': events,
'events_total': events_total}
except Exception as e:
if request.debug: raise(e)
request.session.flash('Unable to find pool.', 'error')
Expand Down

0 comments on commit 81d40a4

Please sign in to comment.