Mercurial > public > sg101
diff gpp/messages/views.py @ 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 | 4b9970ad0edb |
children |
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, })