Mercurial > public > sg101
changeset 568:7cec8d6f9581
For bitbucket issue #7, provide a bar graph indication of inbox and outbox
usage.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 10 Mar 2012 15:24:46 -0600 |
parents | 0a8e6a9ccf53 |
children | 3fe2eced1be7 |
files | gpp/messages/views.py gpp/templates/messages/inbox_tab.html gpp/templates/messages/outbox_tab.html gpp/templates/messages/usage_graph.html |
diffstat | 4 files changed, 18 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/gpp/messages/views.py Wed Mar 07 18:12:02 2012 -0600 +++ b/gpp/messages/views.py Sat Mar 10 15:24:46 2012 -0600 @@ -48,11 +48,15 @@ Checks the message box count against MSG_BOX_LIMIT. Emits a message to the user if the quota is exceeded. + Returns the percent used as an integer between 0-100. + """ if count >= MSG_BOX_LIMIT: django_messages.warning(request, "Your %s is full. Please delete some messages." % box_name) + return 100 * count / MSG_BOX_LIMIT + @login_required def index(request, tab=None): @@ -93,7 +97,8 @@ return HttpResponseForbidden() msg_list = Message.objects.inbox(request.user) - _quota_check('inbox', msg_list.count(), request) + msg_count = msg_list.count() + pct_used = _quota_check('inbox', msg_count, request) paginator = Paginator(msg_list, MSGS_PER_PAGE) try: @@ -104,6 +109,7 @@ return render(request, 'messages/inbox_tab.html', { 'msgs': msgs, 'url': reverse('messages-inbox'), + 'pct_used': pct_used, }) @@ -116,7 +122,8 @@ return HttpResponseForbidden() msg_list = Message.objects.outbox(request.user) - _quota_check('outbox', msg_list.count(), request) + msg_count = msg_list.count() + pct_used = _quota_check('outbox', msg_count, request) paginator = Paginator(msg_list, MSGS_PER_PAGE) try: @@ -127,6 +134,7 @@ return render(request, 'messages/outbox_tab.html', { 'msgs': msgs, 'url': reverse('messages-outbox'), + 'pct_used': pct_used, })
--- a/gpp/templates/messages/inbox_tab.html Wed Mar 07 18:12:02 2012 -0600 +++ b/gpp/templates/messages/inbox_tab.html Sat Mar 10 15:24:46 2012 -0600 @@ -38,3 +38,4 @@ {% else %} <p><em>Your Inbox is empty.</em></p> {% endif %} +{% include 'messages/usage_graph.html' with box_name='inbox' %}
--- a/gpp/templates/messages/outbox_tab.html Wed Mar 07 18:12:02 2012 -0600 +++ b/gpp/templates/messages/outbox_tab.html Sat Mar 10 15:24:46 2012 -0600 @@ -40,3 +40,4 @@ {% else %} <p><em>Your Outbox is empty.</em></p> {% endif %} +{% include 'messages/usage_graph.html' with box_name='outbox' %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/templates/messages/usage_graph.html Sat Mar 10 15:24:46 2012 -0600 @@ -0,0 +1,6 @@ +<div> +You are using {{ pct_used }}% of your {{ box_name }}. +<div style="width: 200px; height: 20px; border: 1px solid black;"> + <div style="width: {{ pct_used }}%; height: 100%; background-color: #87b6d9;"></div> +</div> +</div>