Private
Public Access
1
0

prototype history page

This commit is contained in:
Sander Roosendaal
2020-05-05 17:58:30 +02:00
parent 68d238b962
commit e7b3c7df0f
5 changed files with 76 additions and 4 deletions

View File

@@ -4654,12 +4654,33 @@ class AlertDelete(DeleteView):
@login_required()
def history_view(request,userid=0):
r = getrequestrower(request,userid=userid)
form = HistorySelectForm()
usertimezone = pytz.timezone(r.defaulttimezone)
activity_enddate = timezone.now()
activity_enddate = activity_enddate.replace(hour=23,minute=59,second=59).astimezone(usertimezone)
activity_startdate = activity_enddate-datetime.timedelta(days=15)
activity_startdate = activity_startdate.replace(hour=0,minute=0,second=0)
typeselect = 'All'
if request.method=='POST':
form = HistorySelectForm(request.POST)
if form.is_valid():
startdate = form.cleaned_data['startdate']
enddate = form.cleaned_data['enddate']
typeselect = form.cleaned_data['workouttype']
activity_startdate = datetime.datetime(
startdate.year,startdate.month,startdate.day
).replace(hour=0,minute=0,second=0).astimezone(usertimezone)
activity_enddate = datetime.datetime(
enddate.year,enddate.month,enddate.day
).replace(hour=23,minute=59,second=59).astimezone(usertimezone)
g_workouts = Workout.objects.filter(
user=r,
@@ -4679,6 +4700,13 @@ def history_view(request,userid=0):
# meters, duration per workout type
wtypes = list(set([w.workouttype for w in g_workouts]))
typechoices = [("All","All")]
for wtype in wtypes:
typechoices.append((wtype,mytypes.workouttypes_ordered[wtype]))
form.fields['workouttype'].choices = typechoices
listofdicts = []
for wtype in wtypes:
@@ -4699,8 +4727,14 @@ def history_view(request,userid=0):
ddict['nrworkouts'] = a_workouts.count()
listofdicts.append(ddict)
# interactive hr pie chart
totalscript,totaldiv = interactive_hr_piechart(df,r,'All Workouts')
if typeselect == 'All':
totalscript,totaldiv = interactive_hr_piechart(df,r,'All Workouts')
else:
a_workouts = g_workouts.filter(workouttype=typeselect)
ddf = getsmallrowdata_db(columns,ids=[w.id for w in a_workouts])
totalscript, totaldiv = interactive_hr_piechart(ddf,r,mytypes.workouttypes_ordered[typeselect])
# interactive power pie chart
@@ -4737,4 +4771,5 @@ def history_view(request,userid=0):
'typedicts':listofdicts,
'totalscript':totalscript,
'totaldiv':totaldiv,
'form':form,
})