From 6e69c292c6660601c833bea0ad8cf3c64dd6d4c2 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Tue, 12 Nov 2019 21:33:11 +0100
Subject: [PATCH] Video Analysis Metrics Form renders but is not processed
---
rowers/dataprep.py | 2 +-
rowers/forms.py | 17 +++++++-
rowers/metrics.py | 2 +
rowers/models.py | 3 ++
rowers/templates/embedded_video.html | 58 +++++++++++++---------------
rowers/views/statements.py | 3 +-
rowers/views/workoutviews.py | 4 ++
7 files changed, 54 insertions(+), 35 deletions(-)
diff --git a/rowers/dataprep.py b/rowers/dataprep.py
index c3723621..e197c39b 100644
--- a/rowers/dataprep.py
+++ b/rowers/dataprep.py
@@ -55,7 +55,7 @@ from rowingdata import (
from rowingdata.csvparsers import HumonParser
-from rowers.metrics import axes,calc_trimp,rowingmetrics,dtypes
+from rowers.metrics import axes,calc_trimp,rowingmetrics,dtypes,metricsgroups
from rowers.models import strokedatafields
#allowedcolumns = [item[0] for item in rowingmetrics]
diff --git a/rowers/forms.py b/rowers/forms.py
index be4adb45..ce3129e3 100644
--- a/rowers/forms.py
+++ b/rowers/forms.py
@@ -24,7 +24,7 @@ import rowers.mytypes as mytypes
import datetime
from django.forms import formset_factory
from rowers.utils import landingpages
-from rowers.metrics import axes
+from rowers.metrics import axes, metricsgroups,rowingmetrics
from rowers.metrics import axlabels
formaxlabels = axlabels.copy()
@@ -57,6 +57,21 @@ class VideoAnalysisCreateForm(forms.Form):
url = forms.CharField(max_length=255,required=True,label='YouTube Video URL')
delay = forms.IntegerField(initial=0,label='Delay (seconds)')
+metricsdescriptions = {}
+for m in metricsgroups:
+ metricsdescriptions[m] = m+' ('
+ for name,d in rowingmetrics:
+ if d['group']==m:
+ metricsdescriptions[m]+=d['verbose_name']+', '
+ metricsdescriptions[m]=metricsdescriptions[m][0:-2]+')'
+
+metricsgroupschoices = ((m,metricsdescriptions[m]) for m in metricsgroups)
+
+class VideoAnalysisMetricsForm(forms.Form):
+ groups = forms.MultipleChoiceField(label='Metrics Groups',
+ choices=metricsgroupschoices,
+ widget=forms.CheckboxSelectMultiple,)
+
# BillingForm form
class BillingForm(forms.Form):
amount = FlexibleDecimalField(required=True,decimal_places=2,
diff --git a/rowers/metrics.py b/rowers/metrics.py
index f8e53298..ef1c0c6a 100644
--- a/rowers/metrics.py
+++ b/rowers/metrics.py
@@ -314,6 +314,8 @@ rowingmetrics = (
)
+metricsgroups = list(set([d['group'] for n,d in rowingmetrics]))
+
dtypes = {}
for name,d in rowingmetrics:
diff --git a/rowers/models.py b/rowers/models.py
index 9e7c2f52..6d104f63 100644
--- a/rowers/models.py
+++ b/rowers/models.py
@@ -3721,11 +3721,14 @@ class BlogPost(models.Model):
link = models.TextField(max_length=300)
date = models.DateField()
+defaultgroups = ['basic']
+
class VideoAnalysis(models.Model):
name = models.CharField(default='', max_length=150,blank=True,null=True)
video_id = models.CharField(default='',max_length=150)
delay = models.IntegerField(default=0)
workout = models.ForeignKey(Workout, on_delete=models.CASCADE)
+ metricsgroups = TemplateListField(default=defaultgroups)
class Meta:
unique_together = ('video_id','workout')
diff --git a/rowers/templates/embedded_video.html b/rowers/templates/embedded_video.html
index f8d19b61..4cbfce56 100644
--- a/rowers/templates/embedded_video.html
+++ b/rowers/templates/embedded_video.html
@@ -63,10 +63,10 @@
Paste link to you tube video below
Use the slider to locate start point for video on workout map
- Playing the video will advance the data in synchonization. Use the regular youtube controls
+
Playing the video will advance the data in synchonization. Use the regular youtube controls
to move around in the video and play it.
You can make manual adjustments to the delay to fine tune the alignment.
- Once you are finished, check "Lock Video and Data" to lock the video and the data.
+ Once you are finished, check "Lock Video and Data" to lock the video and the data.
Once you are happy with the alignment, you can save the analysis, and share with other people.
{% endif %}
@@ -140,8 +140,8 @@
// strokerate = spm[Math.round(datatime)];
// catchangle = ctch[Math.round(datatime)];
{% for id, metric in metrics.items %}
- {{ id }}_now = {{ id }}_values[Math.round(datatime)];
- // console.log(datatime,{{ id }}_now, "{{ metric.name }}")
+ {{ id }}_now = {{ id }}_values[Math.round(datatime)];
+ // console.log(datatime,{{ id }}_now, "{{ metric.name }}")
{% endfor %}
document.getElementById("time").innerHTML = Math.round(videotime);
@@ -210,7 +210,7 @@
{{ metric.unit }}
{% endfor %}
-
+
-
- {% if form %}
- {% if not video_id %}
-
- To load your video, paste the URL of your YouTube video in the form below,
- and submit the form.
-
- {% else %}
-
- Change parameters in the form and press Reload to see the result. When
- you are ready to permanently save the video analysis, press Save.
-
- {% endif %}
-
-
-
- {% endif %}
-
+
+