mirror of
https://github.com/ansible/awx.git
synced 2026-05-10 02:47:36 -02:30
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:
@@ -257,10 +257,6 @@ class DashboardGraphView(APIView):
|
|||||||
period = request.QUERY_PARAMS.get('period', 'month')
|
period = request.QUERY_PARAMS.get('period', 'month')
|
||||||
job_type = request.QUERY_PARAMS.get('job_type', 'all')
|
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()
|
qs = User.objects.all()
|
||||||
user_unified_jobs = get_user_queryset(request.user, UnifiedJob)
|
user_unified_jobs = get_user_queryset(request.user, UnifiedJob)
|
||||||
user_hosts = get_user_queryset(request.user, Host)
|
user_hosts = get_user_queryset(request.user, Host)
|
||||||
@@ -322,9 +318,6 @@ class DashboardGraphView(APIView):
|
|||||||
this_inventory['sources'].append(this_source)
|
this_inventory['sources'].append(this_source)
|
||||||
dashboard_data['inventory'].append(this_inventory)
|
dashboard_data['inventory'].append(this_inventory)
|
||||||
|
|
||||||
# Setting it back
|
|
||||||
settings.USE_TZ = True
|
|
||||||
|
|
||||||
return Response(dashboard_data)
|
return Response(dashboard_data)
|
||||||
|
|
||||||
class ScheduleList(ListAPIView):
|
class ScheduleList(ListAPIView):
|
||||||
|
|||||||
@@ -122,6 +122,12 @@ class QuerySetStats(object):
|
|||||||
|
|
||||||
stat_list = []
|
stat_list = []
|
||||||
dt = start
|
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:
|
while dt < end:
|
||||||
idx = 0
|
idx = 0
|
||||||
value = 0
|
value = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user