def __init__(self, *args, **kwargs):
     super(TemplateForm, self).__init__(*args, **kwargs)
     instance = kwargs.get('instance', None)
     if instance:
         self.help_text = ' and '.join(
             AnswerAccessDefinition.access_channels(
                 instance.answer_type))
         self.fields['answer_type'].help_text = self.help_text
     self.fields['answer_type'].choices = [
         (name, name) for name in AnswerAccessDefinition.answer_types(
             USSDAccess.choice_name())
         if name != AutoResponse.choice_name()
     ]
     self.fields['answer_type'].choices.insert(
         0, ('', '----Select Answer Type -----'))
     # key,val pair of supported access channels for each answer type
     self.answer_map = {}
     # not much needed since we are only restricting to USSD access
     definitions = AnswerAccessDefinition.objects.filter()
     for definiton in definitions:
         self.answer_map[definiton.answer_type] = self.answer_map.get(
             definiton.answer_type, [])
         self.answer_map[definiton.answer_type].append(
             definiton.channel)
     self.order_fields(['module', 'identifier', 'text', 'answer_type'])
Esempio n. 2
0
 def __init__(self, *args, **kwargs):
     super(QuestionTemplateForm, self).__init__(*args, **kwargs)
     self.fields.keyOrder = ['module', 'text', 'identifier', 'group', 'answer_type']
     instance = kwargs.get('instance', None)
     if instance:
         self.help_text = ' and '.join(AnswerAccessDefinition.access_channels(instance.answer_type))
         self.fields['answer_type'].help_text = self.help_text
     self.answer_map = {}
     definitions = AnswerAccessDefinition.objects.all()
     for defi in definitions:
         self.answer_map[defi.answer_type] = self.answer_map.get(defi.answer_type, [])
         self.answer_map[defi.answer_type].append(defi.channel)
Esempio n. 3
0
 def __init__(self, *args, **kwargs):
     super(QuestionTemplateForm, self).__init__(*args, **kwargs)
     self.fields.keyOrder = ['module', 'text', 'identifier', 'group', 'answer_type']
     instance = kwargs.get('instance', None)
     if instance:
         self.help_text = ' and '.join(AnswerAccessDefinition.access_channels(instance.answer_type))
         self.fields['answer_type'].help_text = self.help_text
     self.answer_map = {}
     definitions = AnswerAccessDefinition.objects.all()
     for defi in definitions:
         self.answer_map[defi.answer_type] = self.answer_map.get(defi.answer_type, [])
         self.answer_map[defi.answer_type].append(defi.channel)
Esempio n. 4
0
    def __init__(self, batch, data=None, initial=None, parent_question=None, instance=None):
        super(QuestionForm, self).__init__(data=data, initial=initial, instance=instance)
        self.fields['identifier'].label = "Variable name"
        self.fields['batch'].widget = forms.HiddenInput()
        self.fields['batch'].initial = batch.pk
        self.batch = batch
        #depending on type of ussd/odk access of batch restrict the answer type
        self.fields['answer_type'].choices = [choice for choice in self.fields['answer_type'].choices \
                                                    if choice[0] in batch.answer_types or choice[0] == '' ]
        if instance:
            self.help_text = ' and '.join(AnswerAccessDefinition.access_channels(instance.answer_type))
            self.fields['answer_type'].help_text = self.help_text
        self.answer_map = {}
        definitions = AnswerAccessDefinition.objects.all()
        for defi in definitions:
            self.answer_map[defi.answer_type] = self.answer_map.get(defi.answer_type, [])
            self.answer_map[defi.answer_type].append(defi.channel)


        self.parent_question = parent_question
Esempio n. 5
0
 def __init__(self, *args, **kwargs):
     super(TemplateForm, self).__init__(*args, **kwargs)
     instance = kwargs.get('instance', None)
     if instance:
         self.help_text = ' and '.join(
             AnswerAccessDefinition.access_channels(
                 instance.answer_type))
         self.fields['answer_type'].help_text = self.help_text
     self.fields['answer_type'].choices = [(name, name) for name in
                                           AnswerAccessDefinition.answer_types(USSDAccess.choice_name())
                                           if name != AutoResponse.choice_name()]
     self.fields['answer_type'].choices.insert(0,('','----Select Answer Type -----'))
     # key,val pair of supported access channels for each answer type
     self.answer_map = {}
     # not much needed since we are only restricting to USSD access
     definitions = AnswerAccessDefinition.objects.filter()
     for definiton in definitions:
         self.answer_map[definiton.answer_type] = self.answer_map.get(
             definiton.answer_type, [])
         self.answer_map[definiton.answer_type].append(
             definiton.channel)
     self.order_fields(['module', 'identifier', 'text', 'answer_type'])
Esempio n. 6
0
 def __init__(
         self,
         qset,
         data=None,
         initial=None,
         parent_question=None,
         instance=None,
         prev_question=None):
     super(QuestionForm, self).__init__(
         data=data, initial=initial, instance=instance)
     self.fields['identifier'].label = "Variable name"
     self.fields['qset'].widget = forms.HiddenInput()
     self.fields['qset'].initial = qset.pk
     self.qset = qset
     self.prev_question = prev_question
     # depending on type of ussd/odk access of qset restrict the answer
     # type
     self.fields['answer_type'].choices = [
         choice for choice in self.fields['answer_type'].choices if choice[0] in qset.answer_types]
     self.fields['answer_type'].choices.insert(
         0, ('', '----Select Answer Type----'))
     if instance:
         self.help_text = ' and '.join(AnswerAccessDefinition.access_channels(instance.answer_type))
         self.fields['answer_type'].help_text = self.help_text
     self.answer_map = {}
     definitions = AnswerAccessDefinition.objects.all()
     for defi in definitions:
         self.answer_map[defi.answer_type] = self.answer_map.get(defi.answer_type, [])
         self.answer_map[defi.answer_type].append(defi.channel)
     self.fields['response_validation'].icons = {'add': {'data-toggle': "modal",
                                                          'data-target': "#add_validation",
                                                          'id': 'add_validation_button',
                                                          'title': 'Add Validation'},
                                                 }
     self.parent_question = parent_question
     self.order_fields(['module', 'group', 'identifier',
                        'text', 'answer_type', 'mandatory'])
Esempio n. 7
0
 def __init__(
         self,
         qset,
         data=None,
         initial=None,
         parent_question=None,
         instance=None,
         prev_question=None):
     super(QuestionForm, self).__init__(
         data=data, initial=initial, instance=instance)
     self.fields['identifier'].label = "Variable name"
     self.fields['qset'].widget = forms.HiddenInput()
     self.fields['qset'].initial = qset.pk
     self.qset = qset
     self.prev_question = prev_question
     # depending on type of ussd/odk access of qset restrict the answer
     # type
     self.fields['answer_type'].choices = [
         choice for choice in self.fields['answer_type'].choices if choice[0] in qset.answer_types]
     self.fields['answer_type'].choices.insert(
         0, ('', '----Select Answer Type----'))
     if instance:
         self.help_text = ' and '.join(AnswerAccessDefinition.access_channels(instance.answer_type))
         self.fields['answer_type'].help_text = self.help_text
     self.answer_map = {}
     definitions = AnswerAccessDefinition.objects.all()
     for defi in definitions:
         self.answer_map[defi.answer_type] = self.answer_map.get(defi.answer_type, [])
         self.answer_map[defi.answer_type].append(defi.channel)
     self.fields['response_validation'].icons = {'add': {'data-toggle': "modal",
                                                          'data-target': "#add_validation",
                                                          'id': 'add_validation_button',
                                                          'title': 'Add Validation'},
                                                 }
     self.parent_question = parent_question
     self.order_fields(['module', 'group', 'identifier',
                        'text', 'answer_type', 'mandatory'])