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}")))
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();'))))
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'), 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( "", 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'), 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."), ), 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)
def setup_crispy(self): self.helper = FormHelper() self.helper.form_class = 'form form-horizontal' self.helper.label_class = 'col-sm-2 col-md-2' self.helper.field_class = 'col-sm-5 col-md-5' self.helper.form_method = 'POST' self.helper.layout = crispy.Layout( crispy.Fieldset( _("Default Gateways"), hqcrispy.B3MultiField( _("Default Gateway by Prefix"), 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' ), ), )
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)) self.fields['hq_api_id'].choices = backend_choices self.helper = FormHelper() self.helper.label_class = 'col-sm-3 col-md-4 col-lg-2' self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6' self.helper.form_class = "form form-horizontal" self.helper.layout = crispy.Layout( hqcrispy.B3MultiField( _("Create Another Gateway"), InlineField('action'), Div(InlineField('hq_api_id'), 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-success', type='submit', style="margin-left:5px;" ), css_class='col-sm-3 col-md-2 col-lg-2'), ), )
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", ), ), )
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'), 'phone_number', ), crispy.Fieldset( _("Mailing Address"), 'first_line', 'second_line', 'city', 'state_province_region', 'postal_code', crispy.Field('country', css_class="input-large", 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.") ), ), )
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}")))
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' ), 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."), ), hqcrispy.B3MultiField( "", 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( 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( 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", field_class='col-sm-6 col-md-9 col-lg-9' ) ) return crispy.Fieldset( _("Chat Settings"), *fields )
def __init__(self, *args, **kwargs): if 'domain' not in kwargs: raise Exception("Expected domain in kwargs") self.domain = kwargs.pop('domain') super(AddAutomaticCaseUpdateRuleForm, self).__init__(*args, **kwargs) # 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>' if AUTO_CASE_UPDATES.enabled(self.domain): self.allow_updates_without_closing() self.set_case_type_choices(self.initial.get('case_type')) 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 = '#' self.helper.layout = Layout( Fieldset( _("Basic Information"), Field( 'name', ng_model='name', ), Field( 'case_type', ng_model='case_type', ), 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', ), Field( 'action', ng_model='action', ), Div( Field( 'update_property_name', ng_model='update_property_name', css_class='case-property-typeahead', ), Field( 'update_property_value', ng_model='update_property_value', ), ng_show='showUpdateProperty()', ), ), 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', ), ), )