Private
Public Access
1
0

histo_all

This commit is contained in:
Sander Roosendaal
2018-10-08 14:10:26 +02:00
parent 320bc860c5
commit b0748831ad
4 changed files with 294 additions and 264 deletions

View File

@@ -15,30 +15,6 @@ from django.forms import formset_factory
from utils import landingpages
from metrics import axes
class SelectWidget(Select):
"""
Subclass of Django's select widget that allows disabling options.
"""
def __init__(self, *args, **kwargs):
self._disabled_choices = []
super(SelectWidget, self).__init__(*args, **kwargs)
@property
def disabled_choices(self):
return self._disabled_choices
@disabled_choices.setter
def disabled_choices(self, other):
self._disabled_choices = other
def create_option(self, name, value, label, selected, index, subindex=None, attrs=None):
option_dict = super(SelectWidget, self).create_option(
name, value, label, selected, index, subindex=subindex, attrs=attrs
)
if value in self.disabled_choices:
option_dict['attrs']['disabled'] = 'disabled'
return option_dict
# login form
class LoginForm(forms.Form):
@@ -963,11 +939,11 @@ class FlexAxesForm(forms.Form):
xaxis = forms.ChoiceField(
choices=axchoices,label='X-Axis',widget=SelectWidget,required=True)
choices=axchoices,label='X-Axis',required=True)
yaxis1 = forms.ChoiceField(
choices=yaxchoices,label='Left Axis',widget=SelectWidget,required=True)
choices=yaxchoices,label='Left Axis',required=True)
yaxis2 = forms.ChoiceField(
choices=yaxchoices2,label='Right Axis',widget=SelectWidget,required=True)
choices=yaxchoices2,label='Right Axis',required=True)
def __init__(self,request,*args,**kwargs):
super(FlexAxesForm, self).__init__(*args, **kwargs)