instroke
This commit is contained in:
@@ -110,7 +110,7 @@ from rowers.forms import (
|
||||
VideoAnalysisMetricsForm, SurveyForm, HistorySelectForm,
|
||||
StravaChartForm, FitnessFitForm, PerformanceManagerForm,
|
||||
TrainingPlanBillingForm, InstantPlanSelectForm,
|
||||
TrainingZonesForm,
|
||||
TrainingZonesForm, InstrokeForm
|
||||
)
|
||||
|
||||
from django.urls import reverse, reverse_lazy
|
||||
@@ -239,6 +239,7 @@ from rowers.rows import handle_uploaded_file, handle_uploaded_image
|
||||
from rowers.plannedsessions import *
|
||||
from rowers.tasks import handle_makeplot, handle_otwsetpower, handle_sendemailtcx, handle_sendemailcsv
|
||||
from rowers.tasks import (
|
||||
instroke_static,
|
||||
fetch_rojabo_session,
|
||||
handle_sendemail_unrecognized, handle_sendemailnewcomment,
|
||||
handle_request_post,
|
||||
|
||||
@@ -2904,36 +2904,8 @@ def instroke_chart(request, id=0, metric=''): # pragma: no cover
|
||||
instrokemetrics = rowdata.get_instroke_columns()
|
||||
|
||||
if metric in instrokemetrics:
|
||||
f1 = w.csvfilename[6:-4]
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
imagename = f1+timestr+'.png'
|
||||
fullpathimagename = 'static/plots/'+imagename
|
||||
u = w.user.user
|
||||
r = getrower(u)
|
||||
fig1 = rowdata.get_plot_instroke(metric)
|
||||
canvas = FigureCanvas(fig1)
|
||||
canvas.print_figure('static/plots/'+imagename)
|
||||
plt.close(fig1)
|
||||
fig1.clf()
|
||||
gc.collect()
|
||||
|
||||
try:
|
||||
width, height = Image.open(fullpathimagename).size
|
||||
except:
|
||||
width = 1200
|
||||
height = 600
|
||||
|
||||
imgs = GraphImage.objects.filter(workout=w)
|
||||
if imgs.count() < 7:
|
||||
i = GraphImage(workout=w,
|
||||
creationdatetime=timezone.now(),
|
||||
filename=fullpathimagename,
|
||||
width=width, height=height)
|
||||
|
||||
i.save()
|
||||
else:
|
||||
messages.error(
|
||||
request, 'You have reached the maximum number of static images for this workout. Delete an image first')
|
||||
job = myqueue(queuelow,
|
||||
instroke_static,w, metric)
|
||||
|
||||
r = getrower(request.user)
|
||||
url = reverse(r.defaultlandingpage,
|
||||
@@ -2943,9 +2915,62 @@ def instroke_chart(request, id=0, metric=''): # pragma: no cover
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@permission_required('workout.change_workout', fn=get_workout_by_opaqueid, raise_exception=True)
|
||||
def instroke_chart_interactive(request, id=0): # pragma: no cover
|
||||
w = get_workoutuser(id, request)
|
||||
|
||||
rowdata = rrdata(csvfile=w.csvfilename)
|
||||
instrokemetrics = rowdata.get_instroke_columns()
|
||||
|
||||
form = InstrokeForm(choices=instrokemetrics)
|
||||
|
||||
script = ''
|
||||
div = ''
|
||||
|
||||
if request.method == 'POST':
|
||||
form = InstrokeForm(request.POST,choices=instrokemetrics)
|
||||
if form.is_valid():
|
||||
metric = form.cleaned_data['metric']
|
||||
spm_min = form.cleaned_data['spm_min']
|
||||
spm_max = form.cleaned_data['spm_max']
|
||||
data = rowdata.get_instroke_data(metric,
|
||||
spm_min=spm_min,
|
||||
spm_max=spm_max)
|
||||
script, div = instroke_interactive_chart(data, metric, w,
|
||||
spm_min,
|
||||
spm_max)
|
||||
|
||||
breadcrumbs = [
|
||||
{
|
||||
'url': '/rowers/list-workouts/',
|
||||
'name': 'Workouts'
|
||||
},
|
||||
{
|
||||
'url': get_workout_default_page(request, id),
|
||||
'name': w.name
|
||||
},
|
||||
{
|
||||
'url': reverse('instroke_view', kwargs={'id': id}),
|
||||
'name': 'In-Stroke Metrics'
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
return render(request,
|
||||
'instroke_interactive.html',
|
||||
{
|
||||
'workout': w,
|
||||
'rower': w.user,
|
||||
'active': 'nav-workouts',
|
||||
'breadcrumbs': breadcrumbs,
|
||||
'teams': get_my_teams(request.user),
|
||||
'instrokemetrics': instrokemetrics,
|
||||
'form':form,
|
||||
'the_script': script,
|
||||
'the_div': div,
|
||||
})
|
||||
|
||||
# erase column
|
||||
|
||||
|
||||
@permission_required('workout.change_workout', fn=get_workout_by_opaqueid, raise_exception=True)
|
||||
def workout_erase_column_view(request, id=0, column=''):
|
||||
r = getrower(request.user)
|
||||
|
||||
Reference in New Issue
Block a user