# HG changeset patch # User Brian Neal # Date 1331414686 21600 # Node ID 7cec8d6f95816e7bc62bf4f801bd421f9742dcf3 # Parent 0a8e6a9ccf538df309145c06ca1868c1a6479c49 For bitbucket issue #7, provide a bar graph indication of inbox and outbox usage. diff -r 0a8e6a9ccf53 -r 7cec8d6f9581 gpp/messages/views.py --- 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, }) diff -r 0a8e6a9ccf53 -r 7cec8d6f9581 gpp/templates/messages/inbox_tab.html --- 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 %}

Your Inbox is empty.

{% endif %} +{% include 'messages/usage_graph.html' with box_name='inbox' %} diff -r 0a8e6a9ccf53 -r 7cec8d6f9581 gpp/templates/messages/outbox_tab.html --- 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 %}

Your Outbox is empty.

{% endif %} +{% include 'messages/usage_graph.html' with box_name='outbox' %} diff -r 0a8e6a9ccf53 -r 7cec8d6f9581 gpp/templates/messages/usage_graph.html --- /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 @@ +
+You are using {{ pct_used }}% of your {{ box_name }}. +
+
+
+