Private
Public Access
1
0

added buttons to fusion

This commit is contained in:
Sander Roosendaal
2017-03-12 09:48:13 +01:00
parent 1e5d0a0b83
commit d9f59011b3
6 changed files with 241 additions and 7 deletions

View File

@@ -6,6 +6,8 @@ from django.contrib.auth.models import User
from django.contrib.admin.widgets import AdminDateWidget
from django.forms.extras.widgets import SelectDateWidget
from django.utils import timezone,translation
from django.forms import ModelForm
import dataprep
import datetime
@@ -261,7 +263,7 @@ from rowers.interactiveplots import axlabels
formaxlabels = axlabels.copy()
formaxlabels.pop('None')
parchoices = list(sorted(axlabels.items(), key = lambda x:x[1]))
parchoices = list(sorted(formaxlabels.items(), key = lambda x:x[1]))
class ChartParamChoiceForm(forms.Form):
@@ -275,9 +277,13 @@ class ChartParamChoiceForm(forms.Form):
teamid = forms.IntegerField(widget=forms.HiddenInput())
formaxlabels.pop('time')
metricchoices = list(sorted(axlabels.items(), key = lambda x:x[1]))
metricchoices = list(sorted(formaxlabels.items(), key = lambda x:x[1]))
class FusionMetricChoiceForm(forms.Form):
class FusionMetricChoiceForm(ModelForm):
class Meta:
model = Workout
fields = []
posneg = (
('pos','Workout 2 starts after Workout 1'),
('neg','Workout 2 starts before Workout 1'),
@@ -287,3 +293,17 @@ class FusionMetricChoiceForm(forms.Form):
widget=forms.CheckboxSelectMultiple())
posneg = forms.ChoiceField(choices=posneg,initial='pos')
offset = forms.DurationField(label='Time Offset',initial=datetime.timedelta())
def __init__(self, *args, **kwargs):
super(FusionMetricChoiceForm, self).__init__(*args, **kwargs)
# need to add code to remove "empty" fields
id = self.instance.id
df = dataprep.getrowdata_db(id=id)
labeldict = {key:value for key,value in metricchoices}
for label in labeldict:
if df[label].std() == 0:
self.fields['columns'].choices.remove((label, labeldict[label]))