Video Analysis Metrics Form renders but is not processed
This commit is contained in:
@@ -55,7 +55,7 @@ from rowingdata import (
|
|||||||
from rowingdata.csvparsers import HumonParser
|
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
|
from rowers.models import strokedatafields
|
||||||
|
|
||||||
#allowedcolumns = [item[0] for item in rowingmetrics]
|
#allowedcolumns = [item[0] for item in rowingmetrics]
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import rowers.mytypes as mytypes
|
|||||||
import datetime
|
import datetime
|
||||||
from django.forms import formset_factory
|
from django.forms import formset_factory
|
||||||
from rowers.utils import landingpages
|
from rowers.utils import landingpages
|
||||||
from rowers.metrics import axes
|
from rowers.metrics import axes, metricsgroups,rowingmetrics
|
||||||
from rowers.metrics import axlabels
|
from rowers.metrics import axlabels
|
||||||
|
|
||||||
formaxlabels = axlabels.copy()
|
formaxlabels = axlabels.copy()
|
||||||
@@ -57,6 +57,21 @@ class VideoAnalysisCreateForm(forms.Form):
|
|||||||
url = forms.CharField(max_length=255,required=True,label='YouTube Video URL')
|
url = forms.CharField(max_length=255,required=True,label='YouTube Video URL')
|
||||||
delay = forms.IntegerField(initial=0,label='Delay (seconds)')
|
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
|
# BillingForm form
|
||||||
class BillingForm(forms.Form):
|
class BillingForm(forms.Form):
|
||||||
amount = FlexibleDecimalField(required=True,decimal_places=2,
|
amount = FlexibleDecimalField(required=True,decimal_places=2,
|
||||||
|
|||||||
@@ -314,6 +314,8 @@ rowingmetrics = (
|
|||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
metricsgroups = list(set([d['group'] for n,d in rowingmetrics]))
|
||||||
|
|
||||||
dtypes = {}
|
dtypes = {}
|
||||||
|
|
||||||
for name,d in rowingmetrics:
|
for name,d in rowingmetrics:
|
||||||
|
|||||||
@@ -3721,11 +3721,14 @@ class BlogPost(models.Model):
|
|||||||
link = models.TextField(max_length=300)
|
link = models.TextField(max_length=300)
|
||||||
date = models.DateField()
|
date = models.DateField()
|
||||||
|
|
||||||
|
defaultgroups = ['basic']
|
||||||
|
|
||||||
class VideoAnalysis(models.Model):
|
class VideoAnalysis(models.Model):
|
||||||
name = models.CharField(default='', max_length=150,blank=True,null=True)
|
name = models.CharField(default='', max_length=150,blank=True,null=True)
|
||||||
video_id = models.CharField(default='',max_length=150)
|
video_id = models.CharField(default='',max_length=150)
|
||||||
delay = models.IntegerField(default=0)
|
delay = models.IntegerField(default=0)
|
||||||
workout = models.ForeignKey(Workout, on_delete=models.CASCADE)
|
workout = models.ForeignKey(Workout, on_delete=models.CASCADE)
|
||||||
|
metricsgroups = TemplateListField(default=defaultgroups)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ('video_id','workout')
|
unique_together = ('video_id','workout')
|
||||||
|
|||||||
@@ -63,10 +63,10 @@
|
|||||||
<li class="grid_4">
|
<li class="grid_4">
|
||||||
<p>Paste link to you tube video below</p>
|
<p>Paste link to you tube video below</p>
|
||||||
<p>Use the slider to locate start point for video on workout map</p>
|
<p>Use the slider to locate start point for video on workout map</p>
|
||||||
<p> Playing the video will advance the data in synchonization. Use the regular youtube controls
|
<p>Playing the video will advance the data in synchonization. Use the regular youtube controls
|
||||||
to move around in the video and play it.</p>
|
to move around in the video and play it.</p>
|
||||||
<p>You can make manual adjustments to the delay to fine tune the alignment.
|
<p>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.</p>
|
Once you are finished, check "Lock Video and Data" to lock the video and the data.</p>
|
||||||
<p>Once you are happy with the alignment, you can save the analysis, and share with other people.</p>
|
<p>Once you are happy with the alignment, you can save the analysis, and share with other people.</p>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -140,8 +140,8 @@
|
|||||||
// strokerate = spm[Math.round(datatime)];
|
// strokerate = spm[Math.round(datatime)];
|
||||||
// catchangle = ctch[Math.round(datatime)];
|
// catchangle = ctch[Math.round(datatime)];
|
||||||
{% for id, metric in metrics.items %}
|
{% for id, metric in metrics.items %}
|
||||||
{{ id }}_now = {{ id }}_values[Math.round(datatime)];
|
{{ id }}_now = {{ id }}_values[Math.round(datatime)];
|
||||||
// console.log(datatime,{{ id }}_now, "{{ metric.name }}")
|
// console.log(datatime,{{ id }}_now, "{{ metric.name }}")
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
document.getElementById("time").innerHTML = Math.round(videotime);
|
document.getElementById("time").innerHTML = Math.round(videotime);
|
||||||
@@ -210,7 +210,7 @@
|
|||||||
</span> {{ metric.unit }}
|
</span> {{ metric.unit }}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<li class="grid">
|
<li class="grid_2">
|
||||||
<canvas id="angles"></canvas>
|
<canvas id="angles"></canvas>
|
||||||
<script type="text/javascript" src="https://bernii.github.io/gauge.js/dist/gauge.js"></script>
|
<script type="text/javascript" src="https://bernii.github.io/gauge.js/dist/gauge.js"></script>
|
||||||
<script>
|
<script>
|
||||||
@@ -237,33 +237,26 @@
|
|||||||
gauge.set(-75);
|
gauge.set(-75);
|
||||||
</script>
|
</script>
|
||||||
</li>
|
</li>
|
||||||
<li class="grid_4">
|
</ul>
|
||||||
{% if form %}
|
<form enctype="multipart/form-data" action="" method="post">
|
||||||
{% if not video_id %}
|
<ul class="main-content">
|
||||||
<p>
|
{% if form %}
|
||||||
To load your video, paste the URL of your YouTube video in the form below,
|
<li class="grid_2">
|
||||||
and submit the form.
|
<table>
|
||||||
</p>
|
{{ form.as_table }}
|
||||||
{% else %}
|
</table>
|
||||||
<p>
|
{% csrf_token %}
|
||||||
Change parameters in the form and press Reload to see the result. When
|
{% if not analysis.id %}
|
||||||
you are ready to permanently save the video analysis, press Save.
|
<input type="submit" name="reload_button" value="Reload">
|
||||||
</p>
|
{% endif %}
|
||||||
{% endif %}
|
<input type="submit" name="save_button" value="Save">
|
||||||
<p>
|
</li>
|
||||||
<form enctype="multipart/form-data" action="" method="post">
|
<li class="grid_2">
|
||||||
<table>
|
<table>
|
||||||
{{ form.as_table }}
|
{{ metricsform.as_table }}
|
||||||
</table>
|
</table>
|
||||||
{% csrf_token %}
|
</li>
|
||||||
{% if not analysis.id %}
|
{% endif %}
|
||||||
<input type="submit" name="reload_button" value="Reload">
|
|
||||||
{% endif %}
|
|
||||||
<input type="submit" name="save_button" value="Save">
|
|
||||||
</form>
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
{% if analysis and user.is_authenticated and user == rower.user %}
|
{% if analysis and user.is_authenticated and user == rower.user %}
|
||||||
<p>
|
<p>
|
||||||
@@ -272,6 +265,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
</form>
|
||||||
<script>
|
<script>
|
||||||
// lock
|
// lock
|
||||||
var lock = document.getElementById("lock");
|
var lock = document.getElementById("lock");
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ from rowers.forms import (
|
|||||||
MetricsForm,DisqualificationForm,disqualificationreasons,
|
MetricsForm,DisqualificationForm,disqualificationreasons,
|
||||||
disqualifiers,SearchForm,BillingForm,PlanSelectForm,
|
disqualifiers,SearchForm,BillingForm,PlanSelectForm,
|
||||||
VideoAnalysisCreateForm,WorkoutSingleSelectForm,
|
VideoAnalysisCreateForm,WorkoutSingleSelectForm,
|
||||||
|
VideoAnalysisMetricsForm,
|
||||||
)
|
)
|
||||||
|
|
||||||
from django.urls import reverse, reverse_lazy
|
from django.urls import reverse, reverse_lazy
|
||||||
@@ -117,7 +118,7 @@ from rowers.models import (
|
|||||||
FavoriteForm,BaseFavoriteFormSet,SiteAnnouncement,BasePlannedSessionFormSet,
|
FavoriteForm,BaseFavoriteFormSet,SiteAnnouncement,BasePlannedSessionFormSet,
|
||||||
get_course_timezone,BaseConditionFormSet,
|
get_course_timezone,BaseConditionFormSet,
|
||||||
)
|
)
|
||||||
from rowers.metrics import rowingmetrics,defaultfavoritecharts,nometrics
|
from rowers.metrics import rowingmetrics,defaultfavoritecharts,nometrics,metricsgroups
|
||||||
from rowers import metrics as metrics
|
from rowers import metrics as metrics
|
||||||
from rowers import courses as courses
|
from rowers import courses as courses
|
||||||
import rowers.uploads as uploads
|
import rowers.uploads as uploads
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ def workout_video_view(request,id=''):
|
|||||||
# get video ID and offset
|
# get video ID and offset
|
||||||
if mayedit and request.method == 'POST':
|
if mayedit and request.method == 'POST':
|
||||||
form = VideoAnalysisCreateForm(request.POST)
|
form = VideoAnalysisCreateForm(request.POST)
|
||||||
|
metricsform = VideoAnalysisMetricsForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
video_id = form.cleaned_data['url']
|
video_id = form.cleaned_data['url']
|
||||||
try:
|
try:
|
||||||
@@ -91,9 +92,11 @@ def workout_video_view(request,id=''):
|
|||||||
'url': analysis.video_id,
|
'url': analysis.video_id,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
metricsform = VideoAnalysisMetricsForm(initial={'groups':['basic']})
|
||||||
video_id = analysis.video_id
|
video_id = analysis.video_id
|
||||||
else:
|
else:
|
||||||
form = None
|
form = None
|
||||||
|
metricsform = None
|
||||||
|
|
||||||
data, metrics, maxtime = dataprep.get_video_data(w)
|
data, metrics, maxtime = dataprep.get_video_data(w)
|
||||||
# create map
|
# create map
|
||||||
@@ -132,6 +135,7 @@ def workout_video_view(request,id=''):
|
|||||||
'maxtime':maxtime,
|
'maxtime':maxtime,
|
||||||
'metrics':metrics,
|
'metrics':metrics,
|
||||||
'locked': True,
|
'locked': True,
|
||||||
|
'metricsform':metricsform,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user