示例#1
0
 def section_internal(self):
     return crispy.Fieldset(
         _("Internal Settings (Dimagi Only)"),
         hqcrispy.B3MultiField(
             _("Override Daily Outbound SMS Limit"),
             crispy.Div(InlineField(
                 'override_daily_outbound_sms_limit',
                 data_bind='value: override_daily_outbound_sms_limit',
             ),
                        css_class='col-sm-4'),
             crispy.Div(
                 InlineField('custom_daily_outbound_sms_limit'),
                 data_bind=
                 "visible: override_daily_outbound_sms_limit() === '%s'" %
                 ENABLED,
                 css_class='col-sm-8'),
         ),
         hqcrispy.B3MultiField(
             _("Chat Template"),
             crispy.Div(InlineField(
                 "use_custom_chat_template",
                 data_bind="value: use_custom_chat_template",
             ),
                        css_class='col-sm-4'),
             crispy.Div(InlineField(
                 "custom_chat_template",
                 data_bind="visible: showCustomChatTemplate",
             ),
                        css_class='col-sm-8'),
             help_bubble_text=_("To use a custom template to render the "
                                "chat window, enter it here."),
             css_id="custom-chat-template-group",
         ),
     )
示例#2
0
 def __init__(self, *args, **kwargs):
     super(TelerivetOutgoingSMSForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'form form-horizontal'
     self.helper.label_class = 'col-sm-2 col-md-1'
     self.helper.field_class = 'col-sm-4 col-md-3'
     self.helper.layout = Layout(
         Div(
             hqcrispy.B3MultiField(
                 _("API Key"),
                 Div(hqcrispy.MultiInlineField('api_key',
                                               ng_model='apiKey')),
                 get_rmi_error_placeholder('apiKeyError'),
                 ng_class="{'has-error': apiKeyError}"),
             hqcrispy.B3MultiField(
                 _("Project ID"),
                 Div(
                     hqcrispy.MultiInlineField('project_id',
                                               ng_model='projectId')),
                 get_rmi_error_placeholder('projectIdError'),
                 ng_class="{'has-error': projectIdError}"),
             hqcrispy.B3MultiField(
                 _("Phone ID"),
                 Div(
                     hqcrispy.MultiInlineField('phone_id',
                                               ng_model='phoneId')),
                 get_rmi_error_placeholder('phoneIdError'),
                 ng_class="{'has-error': phoneIdError}")))
示例#3
0
 def __init__(self, *args, **kwargs):
     super(FinalizeGatewaySetupForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'form form-horizontal'
     self.helper.label_class = 'col-sm-3 col-md-2'
     self.helper.field_class = 'col-sm-3 col-md-2'
     self.helper.layout = Layout(
         Div(
             hqcrispy.B3MultiField(
                 _("Name"),
                 Div(hqcrispy.MultiInlineField('name', ng_model='name')),
                 get_rmi_error_placeholder('nameError'),
                 ng_class="{'has-error': nameError}"),
             hqcrispy.B3MultiField(
                 _("Set as default gateway"),
                 Div(
                     hqcrispy.MultiInlineField('set_as_default',
                                               ng_model='setAsDefault',
                                               style='margin-left: 0px;')),
                 get_rmi_error_placeholder('setAsDefaultError'),
                 ng_class="{'has-error': setAsDefaultError}"),
             FormActions(
                 StrictButton(_("Complete"),
                              id="id_create_backend",
                              css_class='btn-success',
                              ng_click='createBackend();'))))
示例#4
0
 def section_general(self):
     fields = [
         hqcrispy.B3MultiField(
             _("Default SMS Response"),
             crispy.Div(InlineField(
                 "use_default_sms_response",
                 data_bind="value: use_default_sms_response",
             ),
                        css_class='col-sm-4'),
             crispy.Div(InlineField(
                 "default_sms_response",
                 css_class="input-xxlarge",
                 placeholder=_("Enter Default Response"),
                 data_bind="visible: showDefaultSMSResponse",
             ),
                        css_class='col-sm-8'),
             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",
             field_class='col-sm-6 col-md-9 col-lg-9'),
         hqcrispy.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."),
         ),
         hqcrispy.B3MultiField(
             "",
             hqcrispy.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",
             field_class='col-md-10 col-lg-10'),
         hqcrispy.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."),
         ),
         hqcrispy.FieldWithHelpBubble(
             'sms_survey_date_format',
             help_bubble_text=_("Choose the format in which date questions "
                                "should be answered in SMS surveys."),
         ),
     ]
     return crispy.Fieldset(_("General Settings"), *fields)
示例#5
0
 def __init__(self, *args, **kwargs):
     super(TelerivetOutgoingSMSForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'form form-horizontal'
     self.helper.label_class = 'col-sm-2 col-md-1'
     self.helper.field_class = 'col-sm-4 col-md-3'
     self.helper.layout = Layout(
         Div(
             hqcrispy.B3MultiField(
                 _("API Key"),
                 Div(
                     hqcrispy.MultiInlineField(
                         'api_key',
                         data_bind='value: apiKey',
                     )),
                 crispy.Div(
                     css_class="help-block",
                     data_bind="visible: apiKeyError, text: apiKeyError",
                 ),
                 data_bind="css: {'has-error': apiKeyError}",
             ),
             hqcrispy.B3MultiField(
                 _("Project ID"),
                 Div(
                     hqcrispy.MultiInlineField(
                         'project_id',
                         data_bind='value: projectId',
                     )),
                 crispy.Div(
                     css_class="help-block",
                     data_bind=
                     "visible: projectIdError, text: projectIdError",
                 ),
                 data_bind="css: {'has-error': projectIdError}",
             ),
             hqcrispy.B3MultiField(
                 _("Phone ID"),
                 Div(
                     hqcrispy.MultiInlineField(
                         'phone_id',
                         data_bind='value: phoneId',
                     )),
                 crispy.Div(
                     css_class="help-block",
                     data_bind="visible: phoneIdError, text: phoneIdError",
                 ),
                 data_bind="css: {'has-error': phoneIdError}",
             )))
示例#6
0
    def __init__(self, *args, **kwargs):
        from corehq.apps.notifications.views import ManageNotificationView
        super(NotificationCreationForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()

        self.helper.form_method = 'POST'
        self.helper.form_class = 'form-horizontal'
        self.helper.form_action = '#'

        self.helper.label_class = 'col-sm-3 col-md-2'
        self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6'

        self.helper.layout = crispy.Layout(
            crispy.Field('content'),
            crispy.Field('url'),
            crispy.Field('type'),
            hqcrispy.B3MultiField("Domain Specific",
                                  crispy.Field('domain_specific')),
            crispy.Field('domains'),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    _("Submit Information"),
                    type="submit",
                    css_class="btn btn-primary",
                    name="submit",
                ),
                hqcrispy.LinkButton(
                    _("Cancel"),
                    reverse(ManageNotificationView.urlname),
                    css_class="btn btn-default",
                    name="cancel",
                ),
            ),
        )
示例#7
0
 def __init__(self, *args, **kwargs):
     super(TelerivetPhoneNumberForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'form form-horizontal'
     self.helper.label_class = 'col-sm-2 col-md-1'
     self.helper.field_class = 'col-sm-4 col-md-3'
     self.helper.layout = Layout(
         Div(
             hqcrispy.B3MultiField(
                 _("Test Phone Number"),
                 Div(
                     hqcrispy.MultiInlineField(
                         'test_phone_number',
                         ng_model='testPhoneNumber'
                     )
                 ),
                 get_rmi_error_placeholder('testPhoneNumberError'),
                 Div(
                     StrictButton(
                         _("Send"),
                         id='id_send_sms_button',
                         css_class='btn btn-success',
                         ng_click='sendTestSMS();'
                     )
                 ),
                 ng_class="{'has-error': testPhoneNumberError}"
             )
         )
     )
示例#8
0
 def __init__(self, *args, **kwargs):
     super(TelerivetPhoneNumberForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'form form-horizontal'
     self.helper.label_class = 'col-sm-2 col-md-1'
     self.helper.field_class = 'col-sm-4 col-md-3'
     self.helper.layout = Layout(
         Div(
             hqcrispy.B3MultiField(
                 _("Test Phone Number"),
                 Div(
                     hqcrispy.MultiInlineField(
                         'test_phone_number',
                         data_bind='value: testPhoneNumber',
                     )),
                 crispy.Div(
                     css_class="help-block",
                     data_bind=
                     "visible: testPhoneNumberError, text: testPhoneNumberError",
                 ),
                 Div(
                     StrictButton(
                         "",
                         id='id_send_sms_button',
                         css_class='btn',
                         data_bind=
                         "text: sendSmsButtonText, click: sendTestSMS, "
                         "css: {'btn-primary': !sendSmsButtonError(), "
                         "'btn-danger': sendSmsButtonError()}",
                     )),
                 data_bind="css: {'has-error': testPhoneNumberError}",
             )))
示例#9
0
    def __init__(self, *args, **kwargs):
        super(CheckboxesForm, self).__init__(*args, **kwargs)
        self.helper = hqcrispy.HQFormHelper()

        self.helper.form_method = 'POST'
        self.helper.form_action = '#'

        self.helper.layout = crispy.Layout(
            crispy.Fieldset(
                _("Basic Information"),
                hqcrispy.B3MultiField(
                    _("Send email when complete"),
                    "send_email",
                ),
                crispy.Field('recipient'),
                crispy.Field('send_to_self'),
            ),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    _("Save"),
                    type="submit",
                    css_class="btn btn-primary",
                ),
                hqcrispy.LinkButton(
                    _("Cancel"),
                    '#',
                    css_class="btn btn-default",
                ),
            ),
        )
示例#10
0
 def setup_crispy(self):
     self.helper = HQFormHelper()
     self.helper.form_method = 'POST'
     self.helper.layout = crispy.Layout(
         crispy.Fieldset(
             _("Default Gateways"),
             hqcrispy.B3MultiField(
                 _("Default Gateway by Prefix"),
                 hqcrispy.ErrorsOnlyField('backend_map'),
                 crispy.Div(
                     data_bind="template: {"
                               " name: 'ko-template-backend-map', "
                               " data: $data"
                               "}"
                 ),
             ),
             'catchall_backend_id',
         ),
         hqcrispy.FormActions(
             StrictButton(
                 _("Save"),
                 type="submit",
                 css_class='btn-primary'
             ),
         ),
     )
示例#11
0
    def __init__(self, is_superuser=False, *args, **kwargs):
        super(InitiateAddSMSBackendForm, self).__init__(*args, **kwargs)

        from corehq.messaging.smsbackends.telerivet.models import SQLTelerivetBackend
        backend_classes = get_sms_backend_classes()
        backend_choices = []
        for api_id, klass in backend_classes.items():
            if is_superuser or api_id == SQLTelerivetBackend.get_api_id():
                friendly_name = klass.get_generic_name()
                backend_choices.append((api_id, friendly_name))
        backend_choices = sorted(backend_choices,
                                 key=lambda backend: backend[1])
        self.fields['hq_api_id'].choices = backend_choices

        self.helper = HQFormHelper()
        self.helper.layout = crispy.Layout(
            hqcrispy.B3MultiField(
                _("Create Another Gateway"),
                InlineField('action'),
                Div(InlineField('hq_api_id', css_class="ko-select2"),
                    css_class='col-sm-6 col-md-6 col-lg-4'),
                Div(StrictButton(mark_safe(
                    '<i class="fa fa-plus"></i> Add Another Gateway'),
                                 css_class='btn-primary',
                                 type='submit',
                                 style="margin-left:5px;"),
                    css_class='col-sm-3 col-md-2 col-lg-2'),
            ), )
示例#12
0
 def __init__(self, *args, **kwargs):
     super(FinalizeGatewaySetupForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_class = 'form form-horizontal'
     self.helper.label_class = 'col-sm-3 col-md-2'
     self.helper.field_class = 'col-sm-3 col-md-2'
     self.helper.layout = Layout(
         Div(
             hqcrispy.B3MultiField(
                 _("Name"),
                 Div(
                     hqcrispy.MultiInlineField(
                         'name',
                         data_bind='value: name',
                     )),
                 crispy.Div(
                     css_class="help-block",
                     data_bind="visible: nameError, text: nameError",
                 ),
                 data_bind="css: {'has-error': nameError}",
             ),
             hqcrispy.B3MultiField(
                 _("Set as default gateway"),
                 Div(
                     hqcrispy.MultiInlineField(
                         'set_as_default',
                         data_bind='value: setAsDefault',
                         style='margin-left: 0px;')),
                 crispy.Div(
                     css_class="help-block",
                     data_bind=
                     "visible: setAsDefaultError, text: setAsDefaultError",
                 ),
                 data_bind="css: {'has-error': setAsDefaultError}",
             ),
             FormActions(
                 StrictButton(
                     "",
                     id="id_create_backend",
                     css_class='btn-primary',
                     data_bind=
                     "text: backendButtonText, click: createBackend, disable: creatingBackend,"
                     "css: {'btn-primary': !backendButtonError(), "
                     "'btn-danger': backendButtonError()}",
                 ))))
示例#13
0
    def __init__(self, account, domain, creating_user, data=None, *args, **kwargs):
        super(ConfirmExtraUserChargesForm, self).__init__(account, domain, creating_user, data=data, *args, **kwargs)
        self.fields['confirm_product_agreement'].label = _(
            'I have read and agree to the <a href="%(pa_url)s" target="_blank">'
            'Software Product Subscription Agreement</a>.'
        ) % {'pa_url': reverse('product_agreement')}

        from corehq.apps.users.views.mobile import MobileWorkerListView
        self.helper.label_class = 'col-sm-3 col-md-2'
        self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6'
        self.helper.layout = crispy.Layout(
            crispy.Fieldset(
                _("Basic Information"),
                'company_name',
                'first_name',
                'last_name',
                crispy.Field('email_list', css_class='input-xxlarge ko-email-select2'),
                'phone_number',
            ),
            crispy.Fieldset(
                 _("Mailing Address"),
                'first_line',
                'second_line',
                'city',
                'state_province_region',
                'postal_code',
                crispy.Field('country', css_class="input-large ko-country-select2",
                             data_countryname=COUNTRIES.get(self.current_country, '')),
            ),
            hqcrispy.B3MultiField(
                '',
                crispy.Field('confirm_product_agreement'),
            ),
            hqcrispy.FormActions(
                crispy.HTML(
                    '<a href="%(user_list_url)s" class="btn btn-default">%(text)s</a>' % {
                        'user_list_url': reverse(MobileWorkerListView.urlname, args=[self.domain]),
                        'text': _("Back to Mobile Workers List")
                    }
                ),
                StrictButton(
                    _("Confirm Billing Information"),
                    type="submit",
                    css_class='btn btn-primary disabled',
                    disabled="disabled",
                    css_id="submit-button-pa",
                ),
                crispy.HTML(
                    '<p class="help-inline" id="submit-button-help-qa" style="vertical-align: '
                    'top; margin-top: 5px; margin-bottom: 0px;">%s</p>' % _("Please agree to the Product Subscription "
                                                                            "Agreement above before continuing.")
                ),
            ),
        )
示例#14
0
    def __init__(self, data, *args, **kwargs):
        self.domain = kwargs.pop('domain')
        kwargs['initial'] = self.initial_data
        super(GaenOtpServerSettingsForm, self).__init__(data, *args, **kwargs)

        self.helper = hqcrispy.HQFormHelper()
        self.helper.form_method = 'POST'
        self.helper.layout = crispy.Layout(
            hqcrispy.B3MultiField(
                _("OTP Callouts"),
                hqcrispy.InlineField('is_enabled'),
            ), crispy.Div(crispy.Field('server_url'), ),
            crispy.Div(crispy.Field('auth_token'), ),
            hqcrispy.FormActions(
                crispy.ButtonHolder(Submit('submit', _("Update")))))
示例#15
0
    def __init__(self, data, *args, **kwargs):
        self.domain = kwargs.pop('domain')
        kwargs['initial'] = self.initial_data
        super(DialerSettingsForm, self).__init__(data, *args, **kwargs)

        self.helper = hqcrispy.HQFormHelper()
        self.helper.form_method = 'POST'
        self.helper.layout = crispy.Layout(
            hqcrispy.B3MultiField(
                _("Telephony Services"),
                hqcrispy.InlineField('is_enabled'),
            ), crispy.Div(crispy.Field('aws_instance_id'), ),
            crispy.Div(crispy.Field('dialer_page_header'), ),
            crispy.Div(crispy.Field('dialer_page_subheader'), ),
            hqcrispy.FormActions(
                crispy.ButtonHolder(Submit('submit', _("Update")))))
示例#16
0
    def __init__(self, data, *args, **kwargs):
        self.domain = kwargs.pop('domain')
        kwargs['initial'] = self.initial_data
        super(HmacCalloutSettingsForm, self).__init__(data, *args, **kwargs)

        self.helper = hqcrispy.HQFormHelper()
        self.helper.form_method = 'POST'
        self.helper.layout = crispy.Layout(
            hqcrispy.B3MultiField(
                _("Signed Callout Config"),
                hqcrispy.InlineField('is_enabled'),
            ), crispy.Div(crispy.Field('destination_url'), ),
            crispy.Div(crispy.Field('api_key'), ),
            crispy.Div(crispy.Field('api_secret'), ),
            hqcrispy.FormActions(
                crispy.ButtonHolder(Submit('submit', _("Update")))))
示例#17
0
 def __init__(self, *args, **kwargs):
     super(ConvertTranslationsForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_method = 'post'
     self.helper.layout = crispy.Layout(
         hqcrispy.B3MultiField(
             "",
             crispy.Div(crispy.Field(
                 'upload_file',
                 data_bind="value: file",
             ),
                        css_class='col-sm-4'),
         ),
         StrictButton(
             ugettext_lazy('Convert'),
             css_class='btn-primary',
             type='submit',
         ),
     )
示例#18
0
    def __init__(self, data, *args, **kwargs):
        self._domain = kwargs.pop('domain')
        super(SimprintsIntegrationForm, self).__init__(data, *args, **kwargs)

        self.helper = hqcrispy.HQFormHelper()
        self.helper.form_method = 'POST'
        self.helper.layout = crispy.Layout(
            hqcrispy.B3MultiField(
                _("Simprints Integration"),
                hqcrispy.InlineField('is_enabled',
                                     data_bind="checked: isEnabled"),
            ),
            crispy.Div(crispy.Field('project_id',
                                    data_bind="value: projectId"),
                       crispy.Field('user_id', data_bind="value: userId"),
                       crispy.Field('module_id', data_bind="value: moduleId"),
                       data_bind="visible: isEnabled"),
            hqcrispy.FormActions(
                crispy.ButtonHolder(Submit('submit', gettext_lazy("Update")))))
示例#19
0
    def __init__(self, *args, **kwargs):
        if 'domain' not in kwargs:
            raise Exception("Expected domain in kwargs")
        self.domain = kwargs.pop('domain')
        self.enhancements_enabled = AUTO_CASE_UPDATE_ENHANCEMENTS.enabled(
            self.domain)
        super(AddAutomaticCaseUpdateRuleForm, self).__init__(*args, **kwargs)

        if not self.enhancements_enabled:
            # Always set the value of filter_on_server_modified to true when the
            # enhancement toggle is not set
            self.data = self.data.copy()
            self.initial['filter_on_server_modified'] = 'true'
            self.data['filter_on_server_modified'] = 'true'

        # We can't set these fields to be required because they are displayed
        # conditionally and we'll confuse django validation if we make them
        # required. However, we should show the asterisk for consistency, since
        # when they are displayed they are required.
        self.fields['update_property_name'].label = _(
            "Property") + '<span class="asteriskField">*</span>'
        self.fields['update_property_value'].label = _(
            "Value") + '<span class="asteriskField">*</span>'
        self.helper = FormHelper()
        self.helper.form_class = 'form form-horizontal'
        self.helper.label_class = 'col-sm-3 col-md-2'
        self.helper.field_class = 'col-sm-4 col-md-3'
        self.helper.form_method = 'POST'
        self.helper.form_action = '#'

        if self.enhancements_enabled:
            self.allow_updates_without_closing()

        _update_property_fields = [
            _f for _f in [
                Field(
                    'update_property_name',
                    ng_model='update_property_name',
                    css_class='case-property-typeahead',
                ),
                Field(
                    'property_value_type',
                    ng_model='property_value_type',
                ) if self.enhancements_enabled else None,
                Field(
                    'update_property_value',
                    ng_model='update_property_value',
                )
            ] if _f
        ]

        _basic_info_fields = [
            _f for _f in [
                Field(
                    'name',
                    ng_model='name',
                ),
                Field(
                    'case_type',
                    ng_model='case_type',
                ),
                Field(
                    'filter_on_server_modified',
                    ng_model='filter_on_server_modified',
                ) if self.enhancements_enabled else None,
                hqcrispy.B3MultiField(
                    _("Close Case") + '<span class="asteriskField">*</span>',
                    Div(
                        hqcrispy.MultiInlineField(
                            'server_modified_boundary',
                            ng_model='server_modified_boundary',
                        ),
                        css_class='col-sm-6',
                    ),
                    Div(
                        HTML('<label class="control-label">%s</label>' %
                             _('days after the case was last modified.')),
                        css_class='col-sm-6',
                    ),
                    help_bubble_text=_(
                        "This will close the case if it has been "
                        "more than the chosen number of days since "
                        "the case was last modified. Cases are "
                        "checked against this rule weekly."),
                    css_id='server_modified_boundary_multifield',
                    label_class=self.helper.label_class,
                    field_class='col-sm-8 col-md-6',
                    ng_show='showServerModifiedBoundaryField()',
                ),
                Field(
                    'action',
                    ng_model='action',
                ),
                Div(*_update_property_fields, ng_show='showUpdateProperty()')
            ] if _f
        ]

        self.set_case_type_choices(self.initial.get('case_type'))
        self.helper.layout = Layout(
            Fieldset(_("Basic Information"), *_basic_info_fields),
            Fieldset(
                _("Filter Cases to Close (Optional)"),
                Field(
                    'conditions',
                    type='hidden',
                    ng_value='conditions',
                ),
                Div(ng_include='', src="'conditions.tpl'"),
            ),
            FormActions(
                StrictButton(
                    _("Save"),
                    type='submit',
                    css_class='btn btn-primary col-sm-offset-1',
                ), ),
        )
示例#20
0
 def section_chat(self):
     fields = [
         hqcrispy.B3MultiField(
             _("Case Name Display"),
             crispy.Div(InlineField(
                 "use_custom_case_username",
                 data_bind="value: use_custom_case_username",
             ),
                        css_class='col-sm-4'),
             crispy.Div(InlineField(
                 "custom_case_username",
                 css_class="input-large",
                 data_bind="visible: showCustomCaseUsername",
             ),
                        css_class='col-sm-8'),
             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",
             field_class='col-sm-6 col-md-9 col-lg-9'),
         hqcrispy.B3MultiField(
             _("Message Counter"),
             crispy.Div(InlineField(
                 "use_custom_message_count_threshold",
                 data_bind="value: use_custom_message_count_threshold",
             ),
                        css_class='col-sm-4'),
             crispy.Div(InlineField(
                 "custom_message_count_threshold",
                 css_class="input-large",
                 data_bind="visible: showCustomMessageCountThreshold",
             ),
                        css_class='col-sm-8'),
             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",
             field_class='col-sm-6 col-md-9 col-lg-9'),
         hqcrispy.FieldWithHelpBubble(
             "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."),
         ),
         hqcrispy.B3MultiField(
             "",
             hqcrispy.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",
             label_class='hide',
             field_class='col-md-12 col-lg-10'),
         crispy.Div(
             hqcrispy.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",
         ),
         hqcrispy.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."),
         ),
         hqcrispy.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."),
         ),
     ]
     return crispy.Fieldset(_("Chat Settings"), *fields)
示例#21
0
    def __init__(self, *args, **kwargs):
        if 'domain' in kwargs:
            self.domain = kwargs.pop('domain')

        self.process_structured_sms = False
        if 'process_structured' in kwargs:
            self.process_structured_sms = kwargs.pop('process_structured')

        super(KeywordForm, self).__init__(*args, **kwargs)

        self.fields['sender_content_type'].choices = self.content_type_choices
        self.fields[
            'other_recipient_content_type'].choices = self.content_type_choices

        self.fields['other_recipient_id'].choices = self.group_choices
        self.fields[
            'sender_app_and_form_unique_id'].choices = self.form_choices
        self.fields[
            'other_recipient_app_and_form_unique_id'].choices = self.form_choices
        self.fields[
            'structured_sms_app_and_form_unique_id'].choices = self.form_choices

        from corehq.apps.reminders.views import KeywordsListView
        self.helper = FormHelper()
        self.helper.form_class = "form form-horizontal"
        self.helper.label_class = 'col-sm-3 col-md-2'
        self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6'

        layout_fields = [
            crispy.Fieldset(
                _('Basic Information'),
                crispy.Field(
                    'keyword',
                    data_bind="value: keyword, "
                    "valueUpdate: 'afterkeydown', "
                    "event: {keyup: updateExampleStructuredSMS}",
                ),
                crispy.Field(
                    'description',
                    data_bind="text: description",
                ),
            ),
        ]
        if self.process_structured_sms:
            layout_fields.append(
                crispy.Fieldset(
                    _("Structured Message Options"),
                    crispy.Field(
                        'structured_sms_app_and_form_unique_id',
                        data_bind="value: structuredSmsAppAndFormUniqueId",
                        css_class="hqwebapp-select2",
                    ),
                    hqcrispy.B3MultiField(
                        _("Delimiters"),
                        crispy.Div(
                            crispy.Div(InlineField(
                                twbscrispy.PrependedText(
                                    'use_custom_delimiter',
                                    '',
                                    data_bind="checked: useCustomDelimiter, "
                                    "click: updateExampleStructuredSMS"),
                                block_css_class="span2",
                            ),
                                       css_class='col-md-4 col-lg-4'),
                            crispy.Div(InlineField(
                                'delimiter',
                                data_bind="value: delimiter, "
                                "valueUpdate: 'afterkeydown', "
                                "event: {keyup: updateExampleStructuredSMS},"
                                "visible: useCustomDelimiter",
                                block_css_class="span4",
                            ),
                                       css_class='col-md-4 col-lg-4')),
                    ),
                    hqcrispy.B3MultiField(
                        _("Named Answers"),
                        crispy.Div(InlineField(
                            twbscrispy.PrependedText(
                                'use_named_args',
                                '',
                                data_bind="checked: useNamedArgs, "
                                "click: updateExampleStructuredSMS"), ),
                                   css_class='col-md-4 col-lg-4'),
                        hqcrispy.ErrorsOnlyField('named_args'),
                        crispy.Div(data_bind="template: {"
                                   " name: 'ko-template-named-args', "
                                   " data: $data"
                                   "}, "
                                   "visible: useNamedArgs", ),
                    ),
                    hqcrispy.B3MultiField(
                        _("Joining Characters"),
                        crispy.Div(
                            crispy.Div(InlineField(
                                twbscrispy.PrependedText(
                                    'use_named_args_separator',
                                    '',
                                    data_bind="checked: useNamedArgsSeparator, "
                                    "click: updateExampleStructuredSMS"), ),
                                       css_class='col-md-4 col-lg-4'),
                            crispy.Div(InlineField(
                                'named_args_separator',
                                data_bind="value: namedArgsSeparator, "
                                "valueUpdate: 'afterkeydown', "
                                "event: {keyup: updateExampleStructuredSMS},"
                                "visible: useJoiningCharacter",
                            ),
                                       css_class='col-md-6 col-lg-4')),
                        data_bind="visible: useNamedArgs",
                    ),
                    hqcrispy.B3MultiField(
                        _("Example Structured Message"),
                        crispy.HTML('<pre style="background: white;" '
                                    'data-bind="text: exampleStructuredSms">'
                                    '</pre>'),
                    ),
                ), )
        layout_fields.extend([
            crispy.Fieldset(
                _("Response"),
                crispy.Field(
                    'sender_content_type',
                    data_bind="value: senderContentType",
                ),
                crispy.Div(
                    crispy.Field(
                        'sender_message',
                        data_bind="text: senderMessage",
                    ),
                    data_bind="visible: isMessageSMS",
                ),
                crispy.Div(
                    crispy.Field(
                        'sender_app_and_form_unique_id',
                        data_bind="value: senderAppAndFormUniqueId",
                        css_class="hqwebapp-select2",
                    ),
                    data_bind="visible: isMessageSurvey",
                ),
                crispy.Field(
                    'other_recipient_content_type',
                    data_bind="value: otherRecipientContentType",
                ),
                hqcrispy.B3MultiField(
                    "",
                    crispy.Div(
                        crispy.HTML(
                            '<h4 style="margin-bottom: 20px;">%s</h4>' %
                            _("Recipient Information"), ),
                        crispy.Field(
                            'other_recipient_type',
                            data_bind="value: otherRecipientType",
                        ),
                        crispy.Div(
                            crispy.Field(
                                'other_recipient_id',
                                data_bind="value: otherRecipientId",
                            ),
                            data_bind="visible: showRecipientGroup",
                        ),
                        crispy.Div(
                            crispy.Field(
                                'other_recipient_message',
                                data_bind="value: otherRecipientMessage",
                            ),
                            data_bind=
                            "visible: otherRecipientContentType() == 'sms'",
                        ),
                        crispy.Div(
                            crispy.Field(
                                'other_recipient_app_and_form_unique_id',
                                data_bind=
                                "value: otherRecipientAppAndFormUniqueId",
                                css_class="hqwebapp-select2",
                            ),
                            data_bind=
                            "visible: otherRecipientContentType() == 'survey'",
                        ),
                        css_class="well",
                        data_bind="visible: notifyOthers",
                    ),
                ),
            ),
            crispy.Fieldset(
                _("Advanced Options"),
                twbscrispy.PrependedText(
                    'override_open_sessions',
                    '',
                    data_bind="checked: overrideOpenSessions",
                ),
                'allow_keyword_use_by',
            ),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    _("Save"),
                    css_class='btn-primary',
                    type='submit',
                ),
                crispy.HTML(
                    '<a href="%s" class="btn btn-default">Cancel</a>' %
                    reverse(KeywordsListView.urlname, args=[self.domain]))),
        ])
        self.helper.layout = crispy.Layout(*layout_fields)
示例#22
0
    def __init__(self, project, request_user, *args, **kwargs):
        super(NewMobileWorkerForm, self).__init__(*args, **kwargs)
        email_string = "@{}.commcarehq.org".format(project.name)
        max_chars_username = 80 - len(email_string)
        self.project = project
        self.domain = self.project.name
        self.request_user = request_user
        self.can_access_all_locations = request_user.has_permission(
            self.domain, 'access_all_locations')
        if not self.can_access_all_locations:
            self.fields['location_id'].required = True

        if self.project.strong_mobile_passwords:
            # Use normal text input so auto-generated strong password is visible
            self.fields['new_password'].widget = forms.TextInput()
            self.fields['new_password'].help_text = mark_safe_lazy(
                string_concat(
                    '<i class="fa fa-warning"></i>',
                    ugettext_lazy(
                        'This password is automatically generated. Please copy it or create your own. It will not be shown again.'
                    ), '<br />'))

        if project.uses_locations:
            self.fields['location_id'].widget = forms.Select()
            location_field = crispy.Field(
                'location_id',
                data_bind='value: location_id',
                data_query_url=reverse('location_search', args=[self.domain]),
            )
        else:
            location_field = crispy.Hidden(
                'location_id',
                '',
                data_bind='value: location_id',
            )

        self.helper = HQModalFormHelper()
        self.helper.form_tag = False
        self.helper.layout = Layout(
            Fieldset(
                _('Basic Information'),
                crispy.Div(crispy.Field(
                    'username',
                    data_bind="value: username, valueUpdate: 'keyup'",
                    maxlength=max_chars_username,
                ),
                           data_bind='''
                        css: {
                            'has-pending': $root.usernameAvailabilityStatus() === $root.STATUS.PENDING,
                            'has-success': $root.usernameAvailabilityStatus() === $root.STATUS.SUCCESS,
                            'has-warning': $root.usernameAvailabilityStatus() === $root.STATUS.WARNING,
                            'has-error': $root.usernameAvailabilityStatus() === $root.STATUS.ERROR,
                        },
                    '''),
                crispy.Field(
                    'first_name',
                    data_bind='value: first_name',
                ),
                crispy.Field(
                    'last_name',
                    data_bind='value: last_name',
                ),
                location_field,
                crispy.Div(hqcrispy.B3MultiField(
                    _("Password"),
                    InlineField(
                        'new_password',
                        data_bind="value: password, valueUpdate: 'input'",
                    ),
                    crispy.HTML('''
                            <p class="help-block" data-bind="if: $root.isSuggestedPassword">
                                <i class="fa fa-warning"></i> {suggested}
                            </p>
                            <p class="help-block" data-bind="ifnot: $root.isSuggestedPassword()">
                                <!-- ko if: $root.passwordStatus() === $root.STATUS.SUCCESS -->
                                    <i class="fa fa-check"></i> {strong}
                                <!-- /ko -->
                                <!-- ko ifnot: $root.useDraconianSecurity() -->
                                    <!-- ko if: $root.passwordStatus() === $root.STATUS.WARNING -->
                                        {almost}
                                    <!-- /ko -->
                                    <!-- ko if: $root.passwordStatus() === $root.STATUS.ERROR -->
                                        <i class="fa fa-warning"></i> {weak}
                                    <!-- /ko -->
                                <!-- /ko -->

                                <!-- ko if: $root.useDraconianSecurity() -->
                                    <!-- ko if: $root.passwordStatus() === $root.STATUS.ERROR -->
                                        <i class="fa fa-warning"></i> {rules}
                                    <!-- /ko -->
                                <!-- /ko -->
                            </p>
                        '''.format(
                        suggested=_(
                            "This password is automatically generated. Please copy it or create "
                            "your own. It will not be shown again."),
                        strong=_("Good Job! Your password is strong!"),
                        almost=
                        _("Your password is almost strong enough! Try adding numbers or symbols!"
                          ),
                        weak=
                        _("Your password is too weak! Try adding numbers or symbols!"
                          ),
                        rules=_(
                            "Password Requirements: 1 special character, 1 number, 1 capital letter, "
                            "minimum length of 8 characters."),
                    )),
                    required=True,
                ),
                           data_bind='''
                        css: {
                            'has-success': $root.passwordStatus() === $root.STATUS.SUCCESS,
                            'has-warning': $root.passwordStatus() === $root.STATUS.WARNING,
                            'has-error': $root.passwordStatus() === $root.STATUS.ERROR,
                        }
                    '''),
            ))
示例#23
0
    def __init__(self, project, request_user, *args, **kwargs):
        super(NewMobileWorkerForm, self).__init__(*args, **kwargs)
        email_string = "@{}.{}".format(project.name, settings.HQ_ACCOUNT_ROOT)
        max_chars_username = 80 - len(email_string)
        self.project = project
        self.domain = self.project.name
        self.request_user = request_user
        self.can_access_all_locations = request_user.has_permission(self.domain, 'access_all_locations')
        if not self.can_access_all_locations:
            self.fields['location_id'].required = True

        if self.project.strong_mobile_passwords:
            # Use normal text input so auto-generated strong password is visible
            self.fields['new_password'].widget = forms.TextInput()
            self.fields['new_password'].help_text = mark_safe_lazy(
                format_lazy(
                    '<i class="fa fa-warning"></i>{}<br />',
                    ugettext_lazy(
                        'This password is automatically generated. '
                        'Please copy it or create your own. It will not be shown again.'),
                )
            )

        if project.uses_locations:
            self.fields['location_id'].widget = forms.Select()
            location_field = crispy.Field(
                'location_id',
                data_bind='value: location_id',
                data_query_url=reverse('location_search', args=[self.domain]),
            )
        else:
            location_field = crispy.Hidden(
                'location_id',
                '',
                data_bind='value: location_id',
            )

        self.two_stage_provisioning_enabled = TWO_STAGE_USER_PROVISIONING.enabled(self.domain)
        if self.two_stage_provisioning_enabled:
            confirm_account_field = crispy.Field(
                'force_account_confirmation',
                data_bind='checked: force_account_confirmation',
            )
            email_field = crispy.Div(
                crispy.Field(
                    'email',
                    data_bind="value: email, valueUpdate: 'keyup'",
                ),
                data_bind='''
                    css: {
                        'has-error': $root.emailStatus() === $root.STATUS.ERROR,
                    },
                '''
            )
            send_email_field = crispy.Field(
                'send_account_confirmation_email',
                data_bind='checked: send_account_confirmation_email, enable: sendConfirmationEmailEnabled',
            )
        else:
            confirm_account_field = crispy.Hidden(
                'force_account_confirmation',
                '',
                data_bind='value: force_account_confirmation',
            )
            email_field = crispy.Hidden(
                'email',
                '',
                data_bind='value: email',
            )
            send_email_field = crispy.Hidden(
                'send_account_confirmation_email',
                '',
                data_bind='value: send_account_confirmation_email',
            )


        self.helper = HQModalFormHelper()
        self.helper.form_tag = False
        self.helper.layout = Layout(
            Fieldset(
                _('Basic Information'),
                crispy.Div(
                    crispy.Field(
                        'username',
                        data_bind="value: username, valueUpdate: 'keyup'",
                        maxlength=max_chars_username,
                    ),
                    data_bind='''
                        css: {
                            'has-pending': $root.usernameAvailabilityStatus() === $root.STATUS.PENDING,
                            'has-success': $root.usernameAvailabilityStatus() === $root.STATUS.SUCCESS,
                            'has-warning': $root.usernameAvailabilityStatus() === $root.STATUS.WARNING,
                            'has-error': $root.usernameAvailabilityStatus() === $root.STATUS.ERROR,
                        },
                    '''
                ),
                crispy.Field(
                    'first_name',
                    data_bind='value: first_name',
                ),
                crispy.Field(
                    'last_name',
                    data_bind='value: last_name',
                ),
                location_field,
                confirm_account_field,
                email_field,
                send_email_field,
                crispy.Div(
                    hqcrispy.B3MultiField(
                        _("Password"),
                        InlineField(
                            'new_password',
                            data_bind="value: password, valueUpdate: 'input', enable: passwordEnabled",
                        ),
                        crispy.HTML('''
                            <p class="help-block" data-bind="if: $root.isSuggestedPassword">
                                <i class="fa fa-warning"></i> {suggested}
                            </p>
                            <p class="help-block" data-bind="ifnot: $root.isSuggestedPassword()">
                                <!-- ko ifnot: $root.skipStandardValidations() -->
                                    <!-- ko if: $root.passwordStatus() === $root.STATUS.SUCCESS -->
                                        <i class="fa fa-check"></i> {strong}
                                    <!-- /ko -->
                                    <!-- ko if: $root.passwordStatus() === $root.STATUS.WARNING -->
                                        {almost}
                                    <!-- /ko -->
                                    <!-- ko if: $root.passwordStatus() === $root.STATUS.ERROR -->
                                        <i class="fa fa-warning"></i> {weak}
                                    <!-- /ko -->
                                <!-- /ko -->

                                <!-- ko if: $root.skipStandardValidations() -->
                                    <i class="fa fa-info-circle"></i> {custom_warning}
                                <!-- /ko -->
                                <!-- ko if: $root.passwordStatus() === $root.STATUS.DISABLED -->
                                    <i class="fa fa-warning"></i> {disabled}
                                <!-- /ko -->
                            </p>
                        '''.format(
                            suggested=_("This password is automatically generated. Please copy it or create "
                                "your own. It will not be shown again."),
                            strong=_("Good Job! Your password is strong!"),
                            almost=_("Your password is almost strong enough! Try adding numbers or symbols!"),
                            weak=_("Your password is too weak! Try adding numbers or symbols!"),
                            custom_warning=_(settings.CUSTOM_PASSWORD_STRENGTH_MESSAGE),
                            disabled=_("Setting a password is disabled. "
                                       "The user will set their own password on confirming their account email."),
                        )),
                        required=True,
                    ),
                    data_bind='''
                        css: {
                            'has-success': $root.passwordStatus() === $root.STATUS.SUCCESS,
                            'has-warning': $root.passwordStatus() === $root.STATUS.WARNING,
                            'has-error': $root.passwordStatus() === $root.STATUS.ERROR,
                        }
                    ''' if not has_custom_clean_password() else ''
                ),
            )
        )