Fusion Metrics form only shows metrics that are available
This commit is contained in:
@@ -298,12 +298,19 @@ class FusionMetricChoiceForm(ModelForm):
|
||||
super(FusionMetricChoiceForm, self).__init__(*args, **kwargs)
|
||||
# need to add code to remove "empty" fields
|
||||
|
||||
id = self.instance.id
|
||||
df = dataprep.getrowdata_db(id=id)
|
||||
if self.instance.id is not None:
|
||||
id = self.instance.id
|
||||
df = dataprep.getrowdata_db(id=id)[0]
|
||||
|
||||
labeldict = {key:value for key,value in metricchoices}
|
||||
labeldict = {key:value for key,value in self.fields['columns'].choices}
|
||||
|
||||
for label in labeldict:
|
||||
if df[label].std() == 0:
|
||||
self.fields['columns'].choices.remove((label, labeldict[label]))
|
||||
for label in labeldict:
|
||||
if df.ix[:,label].std() == 0:
|
||||
try:
|
||||
formaxlabels.pop(label)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
metricchoices = list(sorted(formaxlabels.items(), key = lambda x:x[1]))
|
||||
self.fields['columns'].choices = metricchoices
|
||||
|
||||
|
||||
@@ -5079,7 +5079,7 @@ def workout_summary_restore_view(request,id,message="",successmessage=""):
|
||||
)
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
# Fuse two workouts
|
||||
# Fuse two workouts
|
||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||
def workout_fusion_view(request,id1=0,id2=1):
|
||||
try:
|
||||
@@ -5092,7 +5092,7 @@ def workout_fusion_view(request,id1=0,id2=1):
|
||||
except Workout.DoesNotExist:
|
||||
raise Http404("One of the workouts doesn't exist")
|
||||
|
||||
if request.method == 'POST':
|
||||
if request.method == 'POST':
|
||||
form = FusionMetricChoiceForm(request.POST,instance=w2)
|
||||
if form.is_valid():
|
||||
cd = form.cleaned_data
|
||||
|
||||
Reference in New Issue
Block a user