コード例 #1
0
ファイル: forms.py プロジェクト: ekush/commcare-hq
    def __init__(self, domain, report_type, *args, **kwargs):
        super(DataSourceForm, self).__init__(*args, **kwargs)
        self.domain = domain
        self.report_type = report_type

        self.app_source_helper = ApplicationDataSourceUIHelper()
        self.app_source_helper.bootstrap(self.domain)
        report_source_fields = self.app_source_helper.get_fields()
        report_source_help_texts = {
            "source_type":
            _("<strong>Form</strong>: display data from form submissions.<br/><strong>Case</strong>: display data from your cases. You must be using case management for this option."
              ),
            "application":
            _("Which application should the data come from?"),
            "source":
            _("Choose the case type or form from which to retrieve data for this report."
              ),
        }
        self.fields.update(report_source_fields)

        self.fields['chart_type'].required = self.report_type == "chart"

        self.helper = FormHelper()
        self.helper.form_class = "form-horizontal"
        self.helper.form_id = "report-builder-form"

        chart_type_crispy_field = None
        if self.report_type == 'chart':
            chart_type_crispy_field = FieldWithHelpBubble(
                'chart_type',
                help_bubble_text=
                _("<strong>Bar</strong> shows one vertical bar for each value in your case or form. <strong>Pie</strong> shows what percentage of the total each value is."
                  ))
        report_source_crispy_fields = []
        for k in report_source_fields.keys():
            if k in report_source_help_texts:
                report_source_crispy_fields.append(
                    FieldWithHelpBubble(
                        k, help_bubble_text=report_source_help_texts[k]))
            else:
                report_source_crispy_fields.append(k)

        self.helper.layout = crispy.Layout(
            crispy.Fieldset(
                _('{} Report'.format(self.report_type.capitalize())),
                FieldWithHelpBubble(
                    'report_name',
                    help_bubble_text=
                    _('Web users will see this name in the "Reports" section of CommCareHQ and can click to view the report'
                      )), chart_type_crispy_field),
            crispy.Fieldset(_('Data'), *report_source_crispy_fields),
            FormActions(
                crispy.ButtonHolder(
                    crispy.Submit(
                        'create_new_report_builder_btn',
                        _('Next'),
                    )), ),
        )
コード例 #2
0
ファイル: forms.py プロジェクト: ekush/commcare-hq
 def section_general(self):
     fields = [
         BootstrapMultiField(
             _("Default SMS Response"),
             InlineField(
                 "use_default_sms_response",
                 data_bind="value: use_default_sms_response",
             ),
             InlineField(
                 "default_sms_response",
                 css_class="input-xxlarge",
                 placeholder=_("Enter Default Response"),
                 data_bind="visible: showDefaultSMSResponse",
             ),
             help_bubble_text=_(
                 "Enable this option to provide a "
                 "default response when a user's incoming SMS does not "
                 "answer an open survey or match a known keyword."),
             css_id="default-sms-response-group",
         ),
         FieldWithHelpBubble(
             "use_restricted_sms_times",
             data_bind="value: use_restricted_sms_times",
             help_bubble_text=_(
                 "Use this option to limit the times "
                 "that SMS messages can be sent to users. Messages that "
                 "are sent outside these windows will remained queued "
                 "and will go out as soon as another window opens up."),
         ),
         BootstrapMultiField(
             "",
             HiddenFieldWithErrors(
                 "restricted_sms_times_json",
                 data_bind="value: restricted_sms_times_json"),
             crispy.Div(data_bind="template: {"
                        " name: 'ko-template-restricted-sms-times', "
                        " data: $data"
                        "}", ),
             data_bind="visible: showRestrictedSMSTimes",
         ),
         FieldWithHelpBubble(
             "send_to_duplicated_case_numbers",
             help_bubble_text=_(
                 "Enabling this option will send "
                 "outgoing-only messages to phone numbers registered "
                 "with more than one mobile worker or case. SMS surveys "
                 "and keywords will still only work for unique phone "
                 "numbers in your project."),
         ),
     ]
     return crispy.Fieldset(_("General Settings"), *fields)
コード例 #3
0
ファイル: forms.py プロジェクト: ekush/commcare-hq
 def container_fieldset(self):
     return crispy.Fieldset(
         _('Chart'),
         FieldWithHelpBubble(
             'group_by',
             help_bubble_text=
             _("The values of the selected property will be aggregated and shows as the sections of the pie chart."
               )), self.filter_fieldset)
コード例 #4
0
ファイル: forms.py プロジェクト: ekush/commcare-hq
 def section_registration(self):
     fields = [
         FieldWithHelpBubble(
             "sms_case_registration_enabled",
             help_bubble_text=_(
                 "When this option is enabled, a person "
                 "can send an SMS into the system saying 'join "
                 "[project]', where [project] is your project "
                 "space name, and the system will automatically "
                 "create a case tied to that person's phone number."),
             data_bind="value: sms_case_registration_enabled",
         ),
         crispy.Div(
             FieldWithHelpBubble(
                 "sms_case_registration_type",
                 placeholder=_("Enter a Case Type"),
                 help_bubble_text=_("Cases that self-register over SMS "
                                    "will be given this case type."),
             ),
             FieldWithHelpBubble(
                 "sms_case_registration_owner_id",
                 help_bubble_text=_(
                     "Cases that self-register over SMS "
                     "will be owned by this user or user group."),
             ),
             FieldWithHelpBubble(
                 "sms_case_registration_user_id",
                 help_bubble_text=_(
                     "The form submission for a "
                     "self-registration will belong to this user."),
             ),
             data_bind="visible: showRegistrationOptions",
         ),
         FieldWithHelpBubble(
             "sms_mobile_worker_registration_enabled",
             help_bubble_text=_(
                 "When this option is enabled, a person "
                 "can send an SMS into the system saying 'join "
                 "[project] worker [username]' (where [project] is your "
                 " project space and [username] is an optional username)"
                 ", and the system will add them as a mobile worker."),
         ),
     ]
     return crispy.Fieldset(_("Registration Settings"), *fields)
コード例 #5
0
ファイル: forms.py プロジェクト: tobiasmcnulty/commcare-hq
    def __init__(self, *args, **kwargs):
        super(ReprocessMessagingCaseUpdatesForm,
              self).__init__(*args, **kwargs)

        self.helper = FormHelper()
        self.helper.form_class = "form-horizontal"
        self.helper.form_id = 'reprocess-messaging-updates'
        self.helper.label_class = 'col-sm-3 col-md-2'
        self.helper.field_class = 'col-sm-9 col-md-8'
        self.helper.layout = crispy.Layout(
            FieldWithHelpBubble(
                'case_ids',
                help_bubble_text=_(
                    "Enter a space-separated list of case ids to reprocess. "
                    "Reminder rules will be rerun for the case, and the case's phone "
                    "number entries will be synced."),
            ), FormActions(crispy.Submit('submit', 'Submit')))
コード例 #6
0
ファイル: forms.py プロジェクト: ekush/commcare-hq
 def section_chat(self):
     fields = [
         BootstrapMultiField(
             _("Case Name Display"),
             InlineField(
                 "use_custom_case_username",
                 data_bind="value: use_custom_case_username",
             ),
             InlineField(
                 "custom_case_username",
                 css_class="input-large",
                 data_bind="visible: showCustomCaseUsername",
             ),
             help_bubble_text=_(
                 "By default, when chatting with a case, "
                 "the chat window will use the case's \"name\" case "
                 "property when displaying the case's name. To use a "
                 "different case property, specify it here."),
             css_id="custom-case-username-group",
         ),
         BootstrapMultiField(
             _("Message Counter"),
             InlineField(
                 "use_custom_message_count_threshold",
                 data_bind="value: use_custom_message_count_threshold",
             ),
             InlineField(
                 "custom_message_count_threshold",
                 css_class="input-large",
                 data_bind="visible: showCustomMessageCountThreshold",
             ),
             help_bubble_text=_(
                 "The chat window can use a counter to keep "
                 "track of how many messages are being sent and received "
                 "and highlight that number after a certain threshold is "
                 "reached. By default, the counter is disabled. To enable "
                 "it, enter the desired threshold here."),
             css_id="custom-message-count-threshold-group",
         ),
         FieldWithHelpBubble(
             "use_sms_conversation_times",
             data_bind="value: use_sms_conversation_times",
             help_bubble_text=_(
                 "When this option is enabled, the system "
                 "will not send automated SMS to chat recipients when "
                 "those recipients are in the middle of a conversation."),
         ),
         BootstrapMultiField(
             "",
             HiddenFieldWithErrors(
                 "sms_conversation_times_json",
                 data_bind="value: sms_conversation_times_json"),
             crispy.Div(data_bind="template: {"
                        " name: 'ko-template-sms-conversation-times', "
                        " data: $data"
                        "}", ),
             data_bind="visible: showSMSConversationTimes",
         ),
         crispy.Div(
             FieldWithHelpBubble(
                 "sms_conversation_length",
                 help_bubble_text=_(
                     "The number of minutes to wait "
                     "after receiving an incoming SMS from a chat "
                     "recipient before resuming automated SMS to that "
                     "recipient."),
             ),
             data_bind="visible: showSMSConversationTimes",
         ),
         FieldWithHelpBubble(
             "survey_traffic_option",
             help_bubble_text=_(
                 "This option allows you to hide a chat "
                 "recipient's survey questions and responses from chat "
                 "windows. There is also the option to show only invalid "
                 "responses to questions in the chat window, which could "
                 "be attempts to converse."),
         ),
         FieldWithHelpBubble(
             "count_messages_as_read_by_anyone",
             help_bubble_text=_(
                 "The chat window will mark unread "
                 "messages to the user viewing them. Use this option to "
                 "control whether a message counts as being read if it "
                 "is read by anyone, or if it counts as being read only "
                 "to the user who reads it."),
         ),
     ]
     if self._cchq_is_previewer:
         fields.append(
             BootstrapMultiField(
                 _("Chat Template"),
                 InlineField(
                     "use_custom_chat_template",
                     data_bind="value: use_custom_chat_template",
                 ),
                 InlineField(
                     "custom_chat_template",
                     data_bind="visible: showCustomChatTemplate",
                 ),
                 help_bubble_text=_(
                     "To use a custom template to render the "
                     "chat window, enter it here."),
                 css_id="custom-chat-template-group",
             ))
     attrs = {}
     if not self._cchq_is_previewer:
         attrs["style"] = "display: none;"
     return crispy.Fieldset(_("Chat Settings"), *fields, **attrs)