Work around a bug in django 1.4 and 1.5 for qsstats that would not allow

it to work with USE_TZ = True
This commit is contained in:
Matthew Jones 2014-07-08 10:24:29 -04:00
parent 1a7f3d17d6
commit 1590ce1762
2 changed files with 6 additions and 7 deletions

View File

@ -257,10 +257,6 @@ class DashboardGraphView(APIView):
period = request.QUERY_PARAMS.get('period', 'month')
job_type = request.QUERY_PARAMS.get('job_type', 'all')
# Working around a django 1.5 bug:
# https://code.djangoproject.com/ticket/17260
settings.USE_TZ = False
qs = User.objects.all()
user_unified_jobs = get_user_queryset(request.user, UnifiedJob)
user_hosts = get_user_queryset(request.user, Host)
@ -322,9 +318,6 @@ class DashboardGraphView(APIView):
this_inventory['sources'].append(this_source)
dashboard_data['inventory'].append(this_inventory)
# Setting it back
settings.USE_TZ = True
return Response(dashboard_data)
class ScheduleList(ListAPIView):

View File

@ -122,6 +122,12 @@ class QuerySetStats(object):
stat_list = []
dt = start
try:
from django.utils.timezone import utc
dt = dt.replace(tzinfo=utc)
end = end.replace(tzinfo=utc)
except ImportError:
pass
while dt < end:
idx = 0
value = 0