better dates
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
<ul class="main-content">
|
<ul class="main-content">
|
||||||
<li class="grid_2">
|
<li class="grid_2">
|
||||||
<h1>History for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
<h1>History for {{ rower.user.first_name }} {{ rower.user.last_name }} from {{ startdate }} to {{ enddate }}</h1>
|
||||||
</li>
|
</li>
|
||||||
<li class="grid_2">
|
<li class="grid_2">
|
||||||
<a href="/rowers/history/?enddate={{ today|date:"Y-m-d" }}&startdate={{ lastseven|date:"Y-m-d" }}&workouttype={{ workouttype }}">Past 7 days</a>
|
<a href="/rowers/history/?enddate={{ today|date:"Y-m-d" }}&startdate={{ lastseven|date:"Y-m-d" }}&workouttype={{ workouttype }}">Past 7 days</a>
|
||||||
@@ -143,8 +143,10 @@
|
|||||||
<script>
|
<script>
|
||||||
$(function($) {
|
$(function($) {
|
||||||
console.log('loading script for chart');
|
console.log('loading script for chart');
|
||||||
|
var ed = '{{ senddate|date:"Y-m-d" }}'
|
||||||
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/history/user/{{ rower.user.id }}/data/?startdate={{ startdate|date:"Y-m-d" }}&{{ enddate|date:"Y-m-d" }}&workouttype={{ workouttype }}', function(json) {
|
console.log('End',ed);
|
||||||
|
console.log(window.location.protocol + '//'+window.location.host + '/rowers/history/user/{{ rower.user.id }}/data/?startdate={{ sstartdate|date:"Y-m-d" }}&enddate={{ senddate|date:"Y-m-d" }}&workouttype={{ workouttype }}')
|
||||||
|
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/history/user/{{ rower.user.id }}/data/?startdate={{ sstartdate|date:"Y-m-d" }}&enddate={{ senddate|date:"Y-m-d" }}&workouttype={{ workouttype }}', function(json) {
|
||||||
|
|
||||||
var script = json.script;
|
var script = json.script;
|
||||||
var div = json.div;
|
var div = json.div;
|
||||||
|
|||||||
@@ -4662,6 +4662,8 @@ def history_view(request,userid=0):
|
|||||||
|
|
||||||
if request.GET.get('startdate'):
|
if request.GET.get('startdate'):
|
||||||
startdate,enddate = get_dates_timeperiod(request)
|
startdate,enddate = get_dates_timeperiod(request)
|
||||||
|
sstartdate = startdate
|
||||||
|
senddate = enddate
|
||||||
activity_startdate = datetime.datetime(
|
activity_startdate = datetime.datetime(
|
||||||
startdate.year,startdate.month,startdate.day
|
startdate.year,startdate.month,startdate.day
|
||||||
).replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
).replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
||||||
@@ -4673,6 +4675,12 @@ def history_view(request,userid=0):
|
|||||||
activity_enddate = activity_enddate.replace(hour=23,minute=59,second=59).astimezone(usertimezone)
|
activity_enddate = activity_enddate.replace(hour=23,minute=59,second=59).astimezone(usertimezone)
|
||||||
activity_startdate = activity_enddate-datetime.timedelta(days=15)
|
activity_startdate = activity_enddate-datetime.timedelta(days=15)
|
||||||
activity_startdate = activity_startdate.replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
activity_startdate = activity_startdate.replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
||||||
|
sstartdate = datetime.date(year=activity_startdate.year,month=activity_startdate.month,
|
||||||
|
day=activity_startdate.day)
|
||||||
|
senddate = datetime.date(year=activity_enddate.year,month=activity_enddate.month,
|
||||||
|
day=activity_enddate.day)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typeselect = 'All'
|
typeselect = 'All'
|
||||||
if request.GET.get('workouttype'):
|
if request.GET.get('workouttype'):
|
||||||
@@ -4685,6 +4693,8 @@ def history_view(request,userid=0):
|
|||||||
'enddate':activity_enddate,
|
'enddate':activity_enddate,
|
||||||
'workouttype':typeselect})
|
'workouttype':typeselect})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
g_workouts = Workout.objects.filter(
|
g_workouts = Workout.objects.filter(
|
||||||
user=r,
|
user=r,
|
||||||
startdatetime__gte=activity_startdate,
|
startdatetime__gte=activity_startdate,
|
||||||
@@ -4693,6 +4703,7 @@ def history_view(request,userid=0):
|
|||||||
privacy='visible'
|
privacy='visible'
|
||||||
).order_by("-startdatetime")
|
).order_by("-startdatetime")
|
||||||
|
|
||||||
|
|
||||||
ids = [w.id for w in g_workouts]
|
ids = [w.id for w in g_workouts]
|
||||||
|
|
||||||
columns = ['hr','power','time']
|
columns = ['hr','power','time']
|
||||||
@@ -4772,6 +4783,8 @@ def history_view(request,userid=0):
|
|||||||
if firstmay>today:
|
if firstmay>today:
|
||||||
firstmay = datetime.datetime(year=today.year-1,month=5,day=1)
|
firstmay = datetime.datetime(year=today.year-1,month=5,day=1)
|
||||||
|
|
||||||
|
print(sstartdate,senddate,'history')
|
||||||
|
|
||||||
return render(request,'history.html',
|
return render(request,'history.html',
|
||||||
{
|
{
|
||||||
'tscript':tscript,
|
'tscript':tscript,
|
||||||
@@ -4793,6 +4806,8 @@ def history_view(request,userid=0):
|
|||||||
'today':today,
|
'today':today,
|
||||||
'workouttype':typeselect,
|
'workouttype':typeselect,
|
||||||
'firstmay':firstmay,
|
'firstmay':firstmay,
|
||||||
|
'sstartdate':sstartdate,
|
||||||
|
'senddate':senddate,
|
||||||
})
|
})
|
||||||
|
|
||||||
@login_required()
|
@login_required()
|
||||||
@@ -4801,8 +4816,10 @@ def history_view_data(request,userid=0):
|
|||||||
|
|
||||||
usertimezone = pytz.timezone(r.defaulttimezone)
|
usertimezone = pytz.timezone(r.defaulttimezone)
|
||||||
|
|
||||||
|
print(request.GET)
|
||||||
if request.GET.get('startdate'):
|
if request.GET.get('startdate'):
|
||||||
startdate,enddate = get_dates_timeperiod(request)
|
startdate = datetime.datetime.strptime(request.GET.get('startdate'),"%Y-%m-%d")
|
||||||
|
enddate = datetime.datetime.strptime(request.GET.get('enddate'),"%Y-%m-%d")
|
||||||
activity_startdate = datetime.datetime(
|
activity_startdate = datetime.datetime(
|
||||||
startdate.year,startdate.month,startdate.day
|
startdate.year,startdate.month,startdate.day
|
||||||
).replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
).replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
||||||
@@ -4815,6 +4832,8 @@ def history_view_data(request,userid=0):
|
|||||||
activity_startdate = activity_enddate-datetime.timedelta(days=15)
|
activity_startdate = activity_enddate-datetime.timedelta(days=15)
|
||||||
activity_startdate = activity_startdate.replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
activity_startdate = activity_startdate.replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typeselect = 'All'
|
typeselect = 'All'
|
||||||
if request.GET.get('workouttype'):
|
if request.GET.get('workouttype'):
|
||||||
typeselect = request.GET.get('workouttype')
|
typeselect = request.GET.get('workouttype')
|
||||||
@@ -4822,6 +4841,7 @@ def history_view_data(request,userid=0):
|
|||||||
if typeselect not in mytypes.checktypes:
|
if typeselect not in mytypes.checktypes:
|
||||||
typeselect = 'All'
|
typeselect = 'All'
|
||||||
|
|
||||||
|
|
||||||
g_workouts = Workout.objects.filter(
|
g_workouts = Workout.objects.filter(
|
||||||
user=r,
|
user=r,
|
||||||
startdatetime__gte=activity_startdate,
|
startdatetime__gte=activity_startdate,
|
||||||
|
|||||||
Reference in New Issue
Block a user