Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'releases/0.2' of github.com:tangentlabs/django-oscar in…

…to releases/0.2
  • Loading branch information...
commit 9bac51a5419f2b350d9922115cd223071e77d2a0 2 parents ada4790 + a03b96d
@codeinthehole codeinthehole authored
Showing with 8 additions and 3 deletions.
  1. +2 −2 oscar/apps/dashboard/tests.py
  2. +6 −1 oscar/apps/dashboard/views.py
View
4 oscar/apps/dashboard/tests.py
@@ -43,14 +43,14 @@ def test_dashboard_hourly_report_with_no_orders(self):
self.assertEquals(len(report['y_range']), 0)
self.assertEquals(report['max_revenue'], 0)
- def test_dashboard_hourly_report_with_orders(self):
+ def test_dashboard_hourly_report_with_orders(self):
create_order(total_incl_tax=D('34.05'), total_excl_tax=D('34.05'))
create_order(total_incl_tax=D('21.90'), total_excl_tax=D('21.90'))
report = IndexView().get_hourly_report()
self.assertEquals(len(report['order_total_hourly']), 24)
self.assertEquals(len(report['y_range']), 11)
- self.assertEquals(report['max_revenue'], D('55.95'))
+ self.assertEquals(report['max_revenue'], D('60'))
def test_dashboard_index_has_stats_vars_in_context(self):
response = self.client.get(reverse('dashboard:index'))
View
7 oscar/apps/dashboard/views.py
@@ -1,4 +1,4 @@
-from decimal import Decimal as D
+from decimal import Decimal as D, ROUND_UP
from datetime import datetime, timedelta
from django.views.generic import TemplateView
@@ -98,6 +98,11 @@ def get_hourly_report(self, hours=24, segments=10):
start_time = end_time
max_value = max([x['total_incl_tax'] for x in order_total_hourly])
+ divisor = 1
+ while divisor < max_value / 50:
+ divisor *= 10
+ max_value = (max_value / divisor).quantize(D('1'), rounding=ROUND_UP)
+ max_value *= divisor
if max_value:
segment_size = (max_value) / D('100.0')
for item in order_total_hourly:
Please sign in to comment.
Something went wrong with that request. Please try again.