##// END OF EJS Templates
Fix TX_ref for codes & windows lines...
Juan C. Espinoza -
r149:b369cf929a93
parent child
Show More
@@ -9,12 +9,13 from apps.main.forms import add_empty_choice
9 9 from .models import RCConfiguration, RCLine, RCLineType, RCLineCode
10 10 from .widgets import KmUnitWidget, KmUnitHzWidget, KmUnitDcWidget, UnitKmWidget, DefaultWidget, CodesWidget, HiddenWidget, HCheckboxSelectMultiple
11 11
12 def create_choices_from_model(model, conf_id, all=False):
12 def create_choices_from_model(model, conf_id, all_choice=False):
13 13
14 14 if model=='RCLine':
15 15 instance = RCConfiguration.objects.get(pk=conf_id)
16 16 choices = [(line.pk, line.get_name()) for line in instance.get_lines(line_type__name='tx')]
17 choices = add_empty_choice(choices, label='All')
17 if all_choice:
18 choices = add_empty_choice(choices, label='All')
18 19 else:
19 20 instance = globals()[model]
20 21 choices = instance.objects.all().values_list('pk', 'name')
@@ -310,8 +311,12 class RCLineEditForm(forms.ModelForm):
310 311 else:
311 312 help_text = ''
312 313
313 if 'model' in params[label]:
314 self.fields[label] = forms.ChoiceField(choices=create_choices_from_model(params[label]['model'], conf.id),
314 if 'model' in params[label]:
315 if line.line_type.name=='tr':
316 all_choice = True
317 else:
318 all_choice = False
319 self.fields[label] = forms.ChoiceField(choices=create_choices_from_model(params[label]['model'], conf.id, all_choice=all_choice),
315 320 initial=value,
316 321 widget=forms.Select(attrs={'name':'%s|%s|%s' % (count, line.id, label)}),
317 322 help_text=help_text)
General Comments 0
You need to be logged in to leave comments. Login now