示例#1
0
    def __init__(self, *args, **kwargs):
        from servo.lib.utils import empty
        super(GsxRepairForm, self).__init__(*args, **kwargs)
        repair = self.instance
        techs = User.techies.filter(location=repair.order.location)
        c = [(u.tech_id, u.get_full_name()) for u in techs]
        c.insert(0, ('', '-------------------',))
        self.fields['tech_id'] = forms.ChoiceField(choices=c,
                                                   required=False,
                                                   label=_('Technician'))
        self.fields['parts'].initial = repair.order.get_parts()

        if repair.can_mark_complete is False:
            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'))
示例#2
0
    def __init__(self, *args, **kwargs):
        from servo.lib.utils import empty
        super(GsxRepairForm, self).__init__(*args, **kwargs)
        repair = self.instance
        techs = User.techies.filter(location=repair.order.location)
        c = [(u.tech_id, u.get_full_name()) for u in techs]
        c.insert(0, ('', '-------------------',))
        self.fields['tech_id'] = forms.ChoiceField(choices=c,
                                                   required=False,
                                                   label=_('Technician'))
        self.fields['parts'].initial = repair.order.get_parts()

        if repair.can_mark_complete is False:
            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'))
示例#3
0
文件: notes.py 项目: filipp/Servo
 def __init__(self, *args, **kwargs):
     super(NoteForm, self).__init__(*args, **kwargs)
     note = kwargs['instance']
     self.fields['sender'] = forms.ChoiceField(
         label=_('From'),
         choices=note.get_sender_choices(),
         widget=forms.Select(attrs={'class': 'span12'})
     )
     self.fields['body'].widget = AutocompleteTextarea(
         rows=20,
         choices=Template.templates()
     )
示例#4
0
文件: notes.py 项目: earlbalai/Servo
    def __init__(self, *args, **kwargs):
        super(NoteForm, self).__init__(*args, **kwargs)
        note = kwargs['instance']
        self.fields['sender'] = forms.ChoiceField(
            label=_('From'),
            choices=note.get_sender_choices(),
            widget=forms.Select(attrs={'class': 'span12'}))

        self.fields['body'].widget = AutocompleteTextarea(
            rows=20, choices=Template.templates())

        if note.order:
            url = reverse('notes-render_template', args=[note.order.pk])
            self.fields['body'].widget.attrs['data-url'] = url
示例#5
0
    def __init__(self, *args, **kwargs):
        super(NoteForm, self).__init__(*args, **kwargs)
        note = kwargs['instance']
        self.fields['sender'] = forms.ChoiceField(
            label=_('From'),
            choices=note.get_sender_choices(),
            widget=forms.Select(attrs={'class': 'span12'})
        )

        self.fields['body'].widget = AutocompleteTextarea(
            rows=20,
            choices=Template.templates()
        )

        if note.order:
            url = reverse('notes-render_template', args=[note.order.pk])
            self.fields['body'].widget.attrs['data-url'] = url