##// END OF EJS Templates
Improve abs pattern views, templates and plots....
Improve abs pattern views, templates and plots. git-svn-id: http://jro-dev.igp.gob.pe/svn/jro_hard/radarsys/trunk/webapp@203 aa17d016-51d5-4e8b-934c-7b2bbb1bbe71

File last commit:

r172:a641bec15a9b
r180:d4783015f56a
Show More
forms.py
382 lines | 15.3 KiB | text/x-python | PythonLexer
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 import os
Juan C. Espinoza
Add rc config mods...
r23 import json
Miguel Urco
Campaign has been added to RadarSys Model...
r13 from django import forms
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 from django.utils.safestring import mark_safe
from apps.main.models import Device
from apps.main.forms import add_empty_choice
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 from .models import RCConfiguration, RCLine, RCLineType, RCLineCode
Juan C. Espinoza
Update RC app (add support for mix configurations, bug plotting window line, )...
r107 from .widgets import KmUnitWidget, KmUnitHzWidget, KmUnitDcWidget, UnitKmWidget, DefaultWidget, CodesWidget, HiddenWidget, HCheckboxSelectMultiple
Juan C. Espinoza
Updates to models, views & forms for CR...
r25
Juan C. Espinoza
Fix TX_ref for codes & windows lines...
r149 def create_choices_from_model(model, conf_id, all_choice=False):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 if model=='RCLine':
instance = RCConfiguration.objects.get(pk=conf_id)
Juan C. Espinoza
Update RC app (add support for mix configurations, bug plotting window line, )...
r107 choices = [(line.pk, line.get_name()) for line in instance.get_lines(line_type__name='tx')]
Juan C. Espinoza
Fix TX_ref for codes & windows lines...
r149 if all_choice:
choices = add_empty_choice(choices, label='All')
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 else:
instance = globals()[model]
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 choices = instance.objects.all().values_list('pk', 'name')
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 return choices
Juan C. Espinoza
Update RC models, views, templates & statics...
r45
class ExtFileField(forms.FileField):
"""
Same as forms.FileField, but you can specify a file extension whitelist.
>>> from django.core.files.uploadedfile import SimpleUploadedFile
>>>
>>> t = ExtFileField(ext_whitelist=(".pdf", ".txt"))
>>>
>>> t.clean(SimpleUploadedFile('filename.pdf', 'Some File Content'))
>>> t.clean(SimpleUploadedFile('filename.txt', 'Some File Content'))
>>>
>>> t.clean(SimpleUploadedFile('filename.exe', 'Some File Content'))
Traceback (most recent call last):
...
ValidationError: [u'Not allowed filetype!']
"""
def __init__(self, *args, **kwargs):
extensions = kwargs.pop("extensions")
self.extensions = [i.lower() for i in extensions]
super(ExtFileField, self).__init__(*args, **kwargs)
def clean(self, *args, **kwargs):
data = super(ExtFileField, self).clean(*args, **kwargs)
filename = data.name
ext = os.path.splitext(filename)[1]
ext = ext.lower()
if ext not in self.extensions:
Juan C. Espinoza
- Update rc app...
r79 raise forms.ValidationError('Not allowed file type: %s' % ext)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update RC models, views, templates & statics...
r45
Miguel Urco
Campaign has been added to RadarSys Model...
r13 class RCConfigurationForm(forms.ModelForm):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 def __init__(self, *args, **kwargs):
super(RCConfigurationForm, self).__init__(*args, **kwargs)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 instance = getattr(self, 'instance', None)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 if instance and instance.pk:
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 devices = Device.objects.filter(device_type__name='rc')
Juan C. Espinoza
- Update rc app...
r79 if instance.experiment:
Juan C. Espinoza
Update RC app (add support for mix configurations, bug plotting window line, )...
r107 self.fields['experiment'].widget.attrs['read_only'] = True
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 #self.fields['experiment'].widget.choices = [(instance.experiment.id, instance.experiment)]
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 self.fields['device'].widget.choices = [(device.id, device) for device in devices]
Juan C. Espinoza
- Update rc app...
r79 self.fields['ipp'].widget = KmUnitHzWidget(attrs={'km2unit':instance.km2unit})
self.fields['clock'].widget.attrs['readonly'] = True
self.fields['time_before'].label = mark_safe(self.fields['time_before'].label)
self.fields['time_after'].label = mark_safe(self.fields['time_after'].label)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update several views and models in main app...
r85 if 'initial' in kwargs and 'experiment' in kwargs['initial'] and kwargs['initial']['experiment'] not in (0, '0'):
Juan C. Espinoza
- Add sequence mode in mix configurations....
r116 self.fields['experiment'].widget.attrs['readonly'] = True
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Miguel Urco
Campaign has been added to RadarSys Model...
r13 class Meta:
model = RCConfiguration
Juan C. Espinoza
Fix mix RC configurations for different ipp's...
r112 exclude = ('type', 'parameters', 'status', 'total_units', 'mix')
Juan C. Espinoza
Add rc config mods...
r23
Juan C. Espinoza
- Update rc app...
r79 def clean(self):
form_data = super(RCConfigurationForm, self).clean()
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 if 'clock_divider' in form_data:
if form_data['clock_divider']<1:
self.add_error('clock_divider', 'Invalid Value')
else:
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 if form_data['ipp']*(20./3*(form_data['clock_in']/form_data['clock_divider']))%10!=0:
Juan C. Espinoza
- Update rc app...
r79 self.add_error('ipp', 'Invalid IPP units={}'.format(form_data['ipp']*(20./3*(form_data['clock_in']/form_data['clock_divider']))))
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 return form_data
Juan C. Espinoza
Update RC app (add support for mix configurations, bug plotting window line, )...
r107
Juan C. Espinoza
- Add sequence mode in mix configurations....
r116 def save(self):
conf = super(RCConfigurationForm, self).save()
conf.total_units = conf.ipp*conf.ntx*conf.km2unit
conf.save()
return conf
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update RC app (add support for mix configurations, bug plotting window line, )...
r107
class RCMixConfigurationForm(forms.Form):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update RC app (add support for mix configurations, bug plotting window line, )...
r107 clock_in = forms.CharField(widget=forms.HiddenInput())
clock_divider = forms.CharField(widget=forms.HiddenInput())
name = forms.CharField()
experiment = forms.ChoiceField()
Juan C. Espinoza
Fix mix RC configurations for different ipp's...
r112 mode = forms.ChoiceField(widget=forms.RadioSelect(),
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 choices=[(0, 'Parallel'), (1, 'Sequence')],
Juan C. Espinoza
Fix mix RC configurations for different ipp's...
r112 initial=0)
Juan C. Espinoza
Update RC app (add support for mix configurations, bug plotting window line, )...
r107 operation = forms.ChoiceField(widget=forms.RadioSelect(),
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 choices=[(0, 'OR'), (1, 'XOR'), (2, 'AND'), (3, 'NAND')],
Juan C. Espinoza
Update RC app (add support for mix configurations, bug plotting window line, )...
r107 initial=1)
delay = forms.CharField()
mask = forms.MultipleChoiceField(choices=[(0, 'L1'),(1, 'L2'),(2, 'L3'),(3, 'L4'),(4, 'L5'),(5, 'L6'),(6, 'L7'),(7, 'L8')],
widget=HCheckboxSelectMultiple())
result = forms.CharField(required=False,
widget=forms.Textarea(attrs={'readonly':True, 'rows':5, 'class':'tabuled'}))
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update RC app (add support for mix configurations, bug plotting window line, )...
r107 def __init__(self, *args, **kwargs):
confs = kwargs.pop('confs', [])
if confs:
km2unit = confs[0].km2unit
clock_in = confs[0].clock_in
clock_divider = confs[0].clock_divider
else:
km2unit = clock_in = clock_divider = 0
super(RCMixConfigurationForm, self).__init__(*args, **kwargs)
self.fields['experiment'].choices = [(conf.pk, '{} | {}'.format(conf.pk, conf.name)) for conf in confs]
self.fields['delay'].widget = KmUnitWidget(attrs = {'km2unit':km2unit})
self.fields['clock_in'].initial = clock_in
self.fields['clock_divider'].initial = clock_divider
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Add rc config mods...
r23 class RCLineForm(forms.ModelForm):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 def __init__(self, *args, **kwargs):
self.extra_fields = kwargs.pop('extra_fields', [])
super(RCLineForm, self).__init__(*args, **kwargs)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 if 'initial' in kwargs and 'line_type' in kwargs['initial']:
line_type = RCLineType.objects.get(pk=kwargs['initial']['line_type'])
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 if 'code_id' in kwargs['initial']:
model_initial = kwargs['initial']['code_id']
else:
model_initial = 0
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 params = json.loads(line_type.params)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 for label, value in self.extra_fields.items():
if label=='params':
continue
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 if 'model' in params[label]:
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 self.fields[label] = forms.ChoiceField(choices=create_choices_from_model(params[label]['model'],
Juan C. Espinoza
- Update rc app...
r79 kwargs['initial']['rc_configuration']),
initial=model_initial)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 else:
if label=='codes' and 'code_id' in kwargs['initial']:
self.fields[label] = forms.CharField(initial=RCLineCode.objects.get(pk=kwargs['initial']['code_id']).codes)
else:
self.fields[label] = forms.CharField(initial=value['value'])
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 if label=='codes':
self.fields[label].widget = CodesWidget()
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 if self.data:
line_type = RCLineType.objects.get(pk=self.data['line_type'])
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 if 'code_id' in self.data:
model_initial = self.data['code_id']
else:
model_initial = 0
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 params = json.loads(line_type.params)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 for label, value in self.extra_fields.items():
if label=='params':
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 continue
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 if 'model' in params[label]:
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 self.fields[label] = forms.ChoiceField(choices=create_choices_from_model(params[label]['model'],
Juan C. Espinoza
- Update rc app...
r79 self.data['rc_configuration']),
initial=model_initial)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 else:
Juan C. Espinoza
- Update rc app...
r79 if label=='codes' and 'code' in self.data:
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 self.fields[label] = forms.CharField(initial=self.data['codes'])
Juan C. Espinoza
- Update rc app...
r79 else:
self.fields[label] = forms.CharField(initial=self.data[label])
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 if label=='codes':
self.fields[label].widget = CodesWidget()
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Add rc config mods...
r23 class Meta:
model = RCLine
fields = ('rc_configuration', 'line_type', 'channel')
widgets = {
'channel': forms.HiddenInput(),
}
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 def clean(self):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 form_data = self.cleaned_data
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 if 'code' in self.data and self.data['TX_ref']=="0":
Juan C. Espinoza
- Update rc app...
r79 self.add_error('TX_ref', 'Choose a valid TX reference')
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Avoid add mix line type to RC configurations...
r142 if RCLineType.objects.get(pk=self.data['line_type']).name=='mix':
self.add_error('line_type', 'Invalid Line type')
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 return form_data
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
def save(self):
Juan C. Espinoza
Add rc config mods...
r23 line = super(RCLineForm, self).save()
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Add rc config mods...
r23 #auto add channel
line.channel = RCLine.objects.filter(rc_configuration=line.rc_configuration).count()-1
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Add rc config mods...
r23 #auto add position for TX, TR & CODE
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 if line.line_type.name in ('tx', ):
Juan C. Espinoza
Add rc config mods...
r23 line.position = RCLine.objects.filter(rc_configuration=line.rc_configuration, line_type=line.line_type).count()-1
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 #save extra fields in params
Juan C. Espinoza
Add rc config mods...
r23 params = {}
Juan C. Espinoza
- Update rc app...
r79 for label, value in self.extra_fields.items():
if label=='params':
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 params['params'] = []
Juan C. Espinoza
- Update rc app...
r79 elif label=='codes':
params[label] = [s for s in self.data[label].split('\r\n') if s]
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 else:
Juan C. Espinoza
- Update rc app...
r79 params[label] = self.data[label]
Juan C. Espinoza
Add rc config mods...
r23 line.params = json.dumps(params)
line.save()
return
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Add rc config mods...
r23 class RCLineViewForm(forms.Form):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Add rc config mods...
r23 def __init__(self, *args, **kwargs):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Add rc config mods...
r23 extra_fields = kwargs.pop('extra_fields')
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 line = kwargs.pop('line')
subform = kwargs.pop('subform', False)
Juan C. Espinoza
Add rc config mods...
r23 super(RCLineViewForm, self).__init__(*args, **kwargs)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 if subform:
params = json.loads(line.line_type.params)['params']
else:
params = json.loads(line.line_type.params)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Add rc config mods...
r23 for label, value in extra_fields.items():
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 if label=='params':
continue
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 if 'ref' in label:
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 if value in (0, '0'):
value = 'All'
else:
value = RCLine.objects.get(pk=value).get_name()
Juan C. Espinoza
- Update rc app...
r79 elif label=='code':
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 value = RCLineCode.objects.get(pk=value).name
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
self.fields[label] = forms.CharField(initial=value)
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 if 'widget' in params[label]:
Juan C. Espinoza
- Update rc app...
r79 km2unit = line.rc_configuration.km2unit
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 if params[label]['widget']=='km':
Juan C. Espinoza
- Update rc app...
r79 self.fields[label].widget = KmUnitWidget(attrs={'line':line, 'km2unit':km2unit, 'disabled':True})
elif params[label]['widget']=='unit':
self.fields[label].widget = UnitKmWidget(attrs={'line':line, 'km2unit':km2unit, 'disabled':True})
elif params[label]['widget']=='dc':
self.fields[label].widget = KmUnitDcWidget(attrs={'line':line, 'km2unit':km2unit, 'disabled':True})
elif params[label]['widget']=='codes':
self.fields[label].widget = CodesWidget(attrs={'line':line, 'km2unit':km2unit, 'disabled':True})
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 else:
Juan C. Espinoza
- Update rc app...
r79 self.fields[label].widget = DefaultWidget(attrs={'disabled':True})
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 class RCLineEditForm(forms.ModelForm):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 def __init__(self, *args, **kwargs):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 extra_fields = kwargs.pop('extra_fields', [])
conf = kwargs.pop('conf', False)
line = kwargs.pop('line')
subform = kwargs.pop('subform', False)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Updates to models, views & forms for CR...
r25 super(RCLineEditForm, self).__init__(*args, **kwargs)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 if subform is not False:
params = json.loads(line.line_type.params)['params']
count = subform
else:
params = json.loads(line.line_type.params)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 count = -1
Juan C. Espinoza
- Update rc app...
r79 for label, value in extra_fields.items():
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 if label in ('params',):
continue
if 'help' in params[label]:
help_text = params[label]['help']
else:
help_text = ''
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Fix TX_ref for codes & windows lines...
r149 if 'model' in params[label]:
if line.line_type.name=='tr':
all_choice = True
else:
all_choice = False
self.fields[label] = forms.ChoiceField(choices=create_choices_from_model(params[label]['model'], conf.id, all_choice=all_choice),
Juan C. Espinoza
- Update rc app...
r79 initial=value,
widget=forms.Select(attrs={'name':'%s|%s|%s' % (count, line.id, label)}),
help_text=help_text)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
else:
Juan C. Espinoza
- Update rc app...
r79 self.fields[label] = forms.CharField(initial=value, help_text=help_text)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
if label in ('code', ):
self.fields[label].widget = HiddenWidget(attrs={'name':'%s|%s|%s' % (count, line.id, label)})
Juan C. Espinoza
- Update rc app...
r79 elif 'widget' in params[label]:
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 km2unit = line.rc_configuration.km2unit
if params[label]['widget']=='km':
Juan C. Espinoza
- Update rc app...
r79 self.fields[label].widget = KmUnitWidget(attrs={'line':line, 'km2unit':km2unit, 'name':'%s|%s|%s' % (count, line.id, label)})
elif params[label]['widget']=='unit':
self.fields[label].widget = UnitKmWidget(attrs={'line':line, 'km2unit':km2unit, 'name':'%s|%s|%s' % (count, line.id, label)})
elif params[label]['widget']=='dc':
self.fields[label].widget = KmUnitDcWidget(attrs={'line':line, 'km2unit':km2unit, 'name':'%s|%s|%s' % (count, line.id, label)})
elif params[label]['widget']=='codes':
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 self.fields[label].widget = CodesWidget(attrs={'line':line, 'km2unit':km2unit, 'name':'%s|%s|%s' % (count, line.id, label)})
Fiorella Quino
updating repository....
r158 else:
self.fields[label].widget = DefaultWidget(attrs={'line':line, 'name':'%s|%s|%s' % (count, line.id, label)})
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 class Meta:
model = RCLine
exclude = ('rc_configuration', 'line_type', 'channel', 'position', 'params', 'pulses')
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 class RCSubLineEditForm(forms.Form):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 def __init__(self, *args, **kwargs):
extra_fields = kwargs.pop('extra_fields')
count = kwargs.pop('count')
line = kwargs.pop('line')
super(RCSubLineEditForm, self).__init__(*args, **kwargs)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172 for label, value in extra_fields.items():
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 self.fields[label] = forms.CharField(initial=value,
widget=forms.TextInput(attrs={'name':'%s|%s|%s' % (count, line, label)}))
class RCImportForm(forms.Form):
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
Update RC models, views, templates & statics...
r45 file_name = ExtFileField(extensions=['.racp', '.json', '.dat'])
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
class RCLineCodesForm(forms.ModelForm):
Juan C. Espinoza
- Update rc app...
r79 def __init__(self, *args, **kwargs):
super(RCLineCodesForm, self).__init__(*args, **kwargs)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 if 'initial' in kwargs:
self.fields['code'] = forms.ChoiceField(choices=RCLineCode.objects.all().values_list('pk', 'name'),
initial=kwargs['initial']['code'])
if 'instance' in kwargs:
self.fields['code'] = forms.ChoiceField(choices=RCLineCode.objects.all().values_list('pk', 'name'),
initial=kwargs['instance'].pk)
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 self.fields['codes'].widget = CodesWidget()
Juan C. Espinoza
Update code for django 1.10, python 3 and latest third party packages, review operation view ...
r172
Juan C. Espinoza
- Update rc app...
r79 class Meta:
model = RCLineCode
exclude = ('name',)