aboutsummaryrefslogtreecommitdiffstats
path: root/servo/forms
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2015-08-15 16:26:50 +0300
committerFilipp Lepalaan <filipp@mac.com>2015-08-15 16:26:50 +0300
commit06fc5a6b43744799060ce8fdaa78a2ecb034802c (patch)
tree1789000e325834245964fbaa452f634694203887 /servo/forms
parentf38838154defe15e0b2d043c19f6985484993423 (diff)
downloadServo-06fc5a6b43744799060ce8fdaa78a2ecb034802c.tar.gz
Servo-06fc5a6b43744799060ce8fdaa78a2ecb034802c.tar.bz2
Servo-06fc5a6b43744799060ce8fdaa78a2ecb034802c.zip
Added symptom/issue fields
Diffstat (limited to 'servo/forms')
-rw-r--r--servo/forms/repairs.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/servo/forms/repairs.py b/servo/forms/repairs.py
index 8459e52..b821ea9 100644
--- a/servo/forms/repairs.py
+++ b/servo/forms/repairs.py
@@ -67,12 +67,13 @@ class GsxRepairForm(forms.ModelForm):
model = Repair
exclude = []
widgets = {
- 'device' : forms.HiddenInput(),
+ 'device': forms.HiddenInput(),
'parts': forms.CheckboxSelectMultiple(),
'unit_received_at': DateTimePickerInput(attrs={'readonly': 'readonly'})
}
def __init__(self, *args, **kwargs):
+ from servo.lib.utils import empty
super(GsxRepairForm, self).__init__(*args, **kwargs)
repair = kwargs['instance']
techs = User.techies.filter(location=repair.order.location)
@@ -84,13 +85,25 @@ class GsxRepairForm(forms.ModelForm):
self.fields['parts'].initial = repair.order.get_parts()
if not repair.can_mark_complete:
- del self.fields['mark_complete']
- del self.fields['replacement_sn']
+ del(self.fields['mark_complete'])
+ del(self.fields['replacement_sn'])
choices = Template.templates()
for f in ('notes', 'symptom', 'diagnosis'):
self.fields[f].widget = AutocompleteTextarea(choices=choices)
+ symptom_codes = self.instance.get_symptom_code_choices()
+ self.fields['symptom_code'] = forms.ChoiceField(choices=symptom_codes,
+ label=_('Symptom group'))
+
+ if empty(self.instance.symptom_code):
+ # default to the first choice
+ self.instance.symptom_code = symptom_codes[0][0]
+
+ issue_codes = self.instance.get_issue_code_choices()
+ self.fields['issue_code'] = forms.ChoiceField(choices=issue_codes,
+ label=_('Issue code'))
+
def clean(self, *args, **kwargs):
cd = super(GsxRepairForm, self).clean(*args, **kwargs)
if self.instance.has_serialized_parts():