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 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]
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -314,6 +314,8 @@ rowingmetrics = (
|
||||
|
||||
)
|
||||
|
||||
metricsgroups = list(set([d['group'] for n,d in rowingmetrics]))
|
||||
|
||||
dtypes = {}
|
||||
|
||||
for name,d in rowingmetrics:
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -210,7 +210,7 @@
|
||||
</span> {{ metric.unit }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li class="grid">
|
||||
<li class="grid_2">
|
||||
<canvas id="angles"></canvas>
|
||||
<script type="text/javascript" src="https://bernii.github.io/gauge.js/dist/gauge.js"></script>
|
||||
<script>
|
||||
@@ -237,21 +237,11 @@
|
||||
gauge.set(-75);
|
||||
</script>
|
||||
</li>
|
||||
<li class="grid_4">
|
||||
{% if form %}
|
||||
{% if not video_id %}
|
||||
<p>
|
||||
To load your video, paste the URL of your YouTube video in the form below,
|
||||
and submit the form.
|
||||
</p>
|
||||
{% else %}
|
||||
<p>
|
||||
Change parameters in the form and press Reload to see the result. When
|
||||
you are ready to permanently save the video analysis, press Save.
|
||||
</p>
|
||||
{% endif %}
|
||||
<p>
|
||||
</ul>
|
||||
<form enctype="multipart/form-data" action="" method="post">
|
||||
<ul class="main-content">
|
||||
{% if form %}
|
||||
<li class="grid_2">
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
@@ -260,10 +250,13 @@
|
||||
<input type="submit" name="reload_button" value="Reload">
|
||||
{% endif %}
|
||||
<input type="submit" name="save_button" value="Save">
|
||||
</form>
|
||||
</p>
|
||||
{% endif %}
|
||||
</li>
|
||||
<li class="grid_2">
|
||||
<table>
|
||||
{{ metricsform.as_table }}
|
||||
</table>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li>
|
||||
{% if analysis and user.is_authenticated and user == rower.user %}
|
||||
<p>
|
||||
@@ -272,6 +265,7 @@
|
||||
{% endif %}
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
<script>
|
||||
// lock
|
||||
var lock = document.getElementById("lock");
|
||||
|
||||
@@ -60,6 +60,7 @@ from rowers.forms import (
|
||||
MetricsForm,DisqualificationForm,disqualificationreasons,
|
||||
disqualifiers,SearchForm,BillingForm,PlanSelectForm,
|
||||
VideoAnalysisCreateForm,WorkoutSingleSelectForm,
|
||||
VideoAnalysisMetricsForm,
|
||||
)
|
||||
|
||||
from django.urls import reverse, reverse_lazy
|
||||
@@ -117,7 +118,7 @@ from rowers.models import (
|
||||
FavoriteForm,BaseFavoriteFormSet,SiteAnnouncement,BasePlannedSessionFormSet,
|
||||
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 courses as courses
|
||||
import rowers.uploads as uploads
|
||||
|
||||
@@ -68,6 +68,7 @@ def workout_video_view(request,id=''):
|
||||
# get video ID and offset
|
||||
if mayedit and request.method == 'POST':
|
||||
form = VideoAnalysisCreateForm(request.POST)
|
||||
metricsform = VideoAnalysisMetricsForm(request.POST)
|
||||
if form.is_valid():
|
||||
video_id = form.cleaned_data['url']
|
||||
try:
|
||||
@@ -91,9 +92,11 @@ def workout_video_view(request,id=''):
|
||||
'url': analysis.video_id,
|
||||
}
|
||||
)
|
||||
metricsform = VideoAnalysisMetricsForm(initial={'groups':['basic']})
|
||||
video_id = analysis.video_id
|
||||
else:
|
||||
form = None
|
||||
metricsform = None
|
||||
|
||||
data, metrics, maxtime = dataprep.get_video_data(w)
|
||||
# create map
|
||||
@@ -132,6 +135,7 @@ def workout_video_view(request,id=''):
|
||||
'maxtime':maxtime,
|
||||
'metrics':metrics,
|
||||
'locked': True,
|
||||
'metricsform':metricsform,
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user