def __init__(self, *args, **kwargs): super(SubscribeSMSForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = 'form form-horizontal' self.helper.label_class = 'col-sm-2 col-md-2 col-lg-2' self.helper.field_class = 'col-sm-2 col-md-2 col-lg-2' self.helper.layout = crispy.Layout( crispy.Fieldset( _('Subscribe settings'), twbscrispy.PrependedText('stock_out_facilities', ''), twbscrispy.PrependedText('stock_out_commodities', ''), twbscrispy.PrependedText('stock_out_rates', ''), twbscrispy.PrependedText('non_report', '')), hqcrispy.FormActions( twbscrispy.StrictButton( _("Update settings"), type="submit", css_class="btn-primary", ), ))
def __init__(self, *args, **kwargs): submit_label = kwargs.pop('submit_label', "Update") fieldset_title = kwargs.pop('fieldset_title', ugettext_lazy("Edit Group Membership")) super(MultipleSelectionForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_id = 'id-scheduledReportForm' 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.form_tag = False self.helper.layout = crispy.Layout( crispy.Fieldset( fieldset_title, crispy.Field('selected_ids', css_class="hide"), ), hqcrispy.FormActions( crispy.ButtonHolder(Submit('submit', submit_label))))
def __init__(self, project, user_id, **kwargs): super(SetUserPasswordForm, self).__init__(**kwargs) self.project = project initial_password = '' if self.project.strong_mobile_passwords: self.fields['new_password1'].widget = forms.TextInput() self.fields['new_password1'].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 /><span data-bind="text: passwordHelp, css: color">')) initial_password = _generate_strong_password() self.helper = FormHelper() self.helper.form_method = 'POST' self.helper.form_tag = False 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.form_action = reverse("change_password", args=[project.name, user_id]) self.helper.layout = crispy.Layout( crispy.Fieldset( _("Reset Password for Mobile Worker"), crispy.Field( 'new_password1', data_bind= "initializeValue: password, value: password, valueUpdate: 'input'", value=initial_password, ), crispy.Field( 'new_password2', value=initial_password, ), hqcrispy.FormActions( crispy.ButtonHolder(Submit('submit', _('Reset Password')))), css_class="check-password", ), )
def __init__(self, *args, **kwargs): super(AddPhoneNumberForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = 'form form-horizontal' 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.layout = crispy.Layout( Fieldset( _('Add a Phone Number'), 'form_type', twbscrispy.PrependedText('phone_number', '+', type='tel', pattern='\d+')), hqcrispy.FormActions( StrictButton( _('Add Number'), css_class='btn-primary disable-on-submit', type='submit', )))
def __init__(self, *args, **kwargs): domain = kwargs.pop('domain') super(IndicatorTestForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_action = reverse('sms_indicators', args=[domain]) self.helper.form_class = "form form-horizontal" self.helper.label_class = 'col-sm-3 col-md-4 col-lg-2' self.helper.field_class = 'col-sm-10 col-md-10 col-lg-10' self.helper.layout = crispy.Layout( crispy.Field('users', css_class='sms-typeahead'), crispy.Field('indicator'), hqcrispy.FormActions( twbscrispy.StrictButton( _("Test"), type="submit", css_class="btn-primary", ), ), )
def __init__(self, domain, instance=None, read_only=False, *args, **kwargs): super(ConfigurableReportEditForm, self).__init__(instance, read_only, *args, **kwargs) self.fields['config_id'] = ReportDataSourceField(domain=domain) 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-9' self.helper.layout = crispy.Layout( crispy.Fieldset( _("Report Configuration"), 'config_id', 'title', 'visible', 'description', 'aggregation_columns', 'filters', 'columns', 'configured_charts', 'sort_expression', 'soft_rollout', ), ) # Restrict edit for static reports if not read_only: self.helper.layout.append( hqcrispy.FormActions( twbscrispy.StrictButton( _("Save Changes"), type="submit", css_class="btn btn-primary", ), ))
def __init__(self, *args, **kwargs): super(Dhis2ConnectionForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = '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' self.helper.layout = crispy.Layout( crispy.Fieldset( _('Edit DHIS2 connection'), crispy.Field('server_url'), crispy.Field('username'), crispy.Field('password'), ), hqcrispy.FormActions( StrictButton( _("Update DHIS2 connection"), type="submit", css_class='btn-primary', )), )
def _initialize_crispy_layout(self): self.helper = FormHelper(self) self.helper.form_class = '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' self.helper.offset_class = 'col-sm-offset-3 col-md-offset-2' self.helper.layout = crispy.Layout( crispy.Fieldset( 'Forwarding Settings', *self.get_ordered_crispy_form_fields() ), hqcrispy.FormActions( twbscrispy.StrictButton( _("Start Forwarding"), type="submit", css_class='btn-primary', ) ) )
def __init__(self, domain, *args, **kwargs): self.domain = domain super(ConfigurableDataSourceEditForm, self).__init__(*args, **kwargs) if toggles.LOCATIONS_IN_UCR.enabled(domain): choices = self.fields['referenced_doc_type'].choices choices.append( ('Location', _('locations')) ) self.fields['referenced_doc_type'].choices = choices 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-9' self.helper.layout = crispy.Layout( crispy.Fieldset( _("Edit Data Source"), 'table_id', 'referenced_doc_type', 'display_name', 'description', 'base_item_expression', 'configured_filter', 'configured_indicators', 'named_expressions', 'named_filters', 'backend_id', ), hqcrispy.FormActions( twbscrispy.StrictButton( _("Save Changes"), type="submit", css_class="btn btn-primary", ), ), )
def __init__(self, *args, **kwargs): from .views import StockLevelsView domain = kwargs.pop('domain') self.helper = FormHelper() self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-sm-3 col-md-4 col-lg-2' self.helper.field_class = 'col-sm-4 col-md-5 col-lg-3' self.helper.layout = Layout( Fieldset(_('Stock Levels'), 'stock_emergency_level', 'stock_understock_threshold', 'stock_overstock_threshold') if not LOCATION_TYPE_STOCK_RATES.enabled(domain) else Fieldset( _('Stock Levels'), ButtonHolder( HTML('<a href="{}" class="btn btn-primary">{}</a>'.format( reverse(StockLevelsView.urlname, args=[domain]), _('Configure Stock Levels')))), ), Fieldset( _('Consumption Settings'), PrependedText('use_auto_consumption', ''), 'consumption_min_transactions', 'consumption_min_window', 'consumption_optimal_window', PrependedText('individual_consumption_defaults', ''), ), Fieldset( _('Phone Settings'), PrependedText('sync_consumption_fixtures', ''), ), hqcrispy.FormActions( ButtonHolder(Submit('submit', ugettext_lazy('Submit'))))) from corehq.apps.locations.views import LocationImportView url = reverse(LocationImportView.urlname, args=[domain]) forms.Form.__init__(self, *args, **kwargs) self.fields['individual_consumption_defaults'].help_text = _( "This is configured by <a href='{url}'>bulk importing your organization structure</a>." ).format(url=url)
def __init__(self, from_domain, app_id, *args, **kwargs): export_zipped_apps_enabled = kwargs.pop('export_zipped_apps_enabled', False) super(CopyApplicationForm, self).__init__(*args, **kwargs) fields = ['domain', 'name'] if app_id: app = get_app(from_domain, app_id) if app: self.fields['name'].initial = app.name if export_zipped_apps_enabled: self.fields['gzip'] = forms.FileField(required=False) fields.append('gzip') 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.layout = Layout( Fieldset(_('Copy Application'), *fields), Hidden('app', app_id), hqcrispy.FormActions( StrictButton(_('Copy'), type='submit', css_class='btn-primary')))
def __init__(self, **kwargs): super(HQPhoneNumberForm, self).__init__(**kwargs) self.helper = FormHelper() self.helper.form_class = 'form form-horizontal' 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.layout = crispy.Layout( crispy.Fieldset('', 'number'), hqcrispy.FormActions( twbscrispy.StrictButton( _("Back"), css_class='btn-default', type='submit', value='method', name="wizard_goto_step", ), twbscrispy.StrictButton( _('Next'), css_class='btn-primary', type='submit', )))
def __init__(self, data=None, cchq_domain=None, cchq_is_previewer=False, *args, **kwargs): self._cchq_domain = cchq_domain self._cchq_is_previewer = cchq_is_previewer super(SettingsForm, self).__init__(data, *args, **kwargs) self.populate_dynamic_choices() self.helper = FormHelper() self.helper.form_class = "form form-horizontal" self.helper.label_class = 'col-sm-2 col-md-2 col-lg-2' self.helper.field_class = 'col-sm-2 col-md-3 col-lg-3' self.helper.layout = crispy.Layout( self.section_general, self.section_registration, self.section_chat, hqcrispy.FormActions( twbscrispy.StrictButton( _("Save"), type="submit", css_class="btn-primary", ), ), ) self.restricted_sms_times_widget_context = { "template_name": "ko-template-restricted-sms-times", "explanation_text": _("SMS will only be sent when any of the following is true:"), "ko_array_name": "restricted_sms_times", "remove_window_method": "$parent.removeRestrictedSMSTime", "add_window_method": "addRestrictedSMSTime", } self.sms_conversation_times_widget_context = { "template_name": "ko-template-sms-conversation-times", "explanation_text": _("Automated SMS will be suppressed during " "chat conversations when any of the following " "is true:"), "ko_array_name": "sms_conversation_times", "remove_window_method": "$parent.removeSMSConversationTime", "add_window_method": "addSMSConversationTime", }
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, *args, **kwargs): super(OpenClinicaSettingsForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = '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' self.helper.layout = crispy.Layout( crispy.Fieldset( _('Edit OpenClinica settings'), twbscrispy.PrependedText('is_ws_enabled', ''), crispy.Field('url'), crispy.Field('username'), crispy.Field('password'), crispy.Field('protocol_id'), crispy.Field('metadata'), ), hqcrispy.FormActions( StrictButton( _("Update OpenClinica settings"), type="submit", css_class='btn-primary', )), )
def __init__(self, *args, **kwargs): super(ForwardingRuleForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = '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' self.helper.layout = crispy.Layout( crispy.Fieldset( _('Forwarding Rule Options'), 'forward_type', crispy.Div( 'keyword', css_id="keyword_row", css_class='hide', ), 'backend_id', hqcrispy.FormActions( twbscrispy.StrictButton( _("Submit"), type="submit", css_class="btn btn-primary", ), ), ))
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): self.user = kwargs.pop('user', None) if not self.user: raise UpdateMyAccountInfoForm.MyAccountInfoFormException( "Expected to be passed a user kwarg") self.username = self.user.username api_key = kwargs.pop('api_key') if 'api_key' in kwargs else None super(UpdateMyAccountInfoForm, self).__init__(*args, **kwargs) username_controls = [] if self.username: username_controls.append( hqcrispy.StaticField(ugettext_lazy('Username'), self.username)) api_key_controls = [ hqcrispy.StaticField(ugettext_lazy('API Key'), api_key), hqcrispy.FormActions(twbscrispy.StrictButton( ugettext_lazy('Generate API Key'), type="button", id='generate-api-key', css_class='btn-default', ), css_class="form-group"), ] self.fields['language'].label = ugettext_lazy("My Language") self.new_helper = cb3_helper.FormHelper() self.new_helper.form_method = 'POST' self.new_helper.form_class = 'form-horizontal' self.new_helper.attrs = { 'name': 'user_information', } self.new_helper.label_class = 'col-sm-3 col-md-2 col-lg-2' self.new_helper.field_class = 'col-sm-9 col-md-8 col-lg-6' basic_fields = [ cb3_layout.Div(*username_controls), hqcrispy.Field('first_name'), hqcrispy.Field('last_name'), hqcrispy.Field('email'), ] if self.set_email_opt_out: basic_fields.append(twbscrispy.PrependedText('email_opt_out', '')) self.new_helper.layout = cb3_layout.Layout( cb3_layout.Fieldset(ugettext_lazy("Basic"), *basic_fields), (hqcrispy.FieldsetAccordionGroup if self.collapse_other_options else cb3_layout.Fieldset)( ugettext_lazy("Other Options"), hqcrispy.Field('language'), cb3_layout.Div(*api_key_controls), ), hqcrispy.FormActions( twbscrispy.StrictButton( ugettext_lazy("Update My Information"), type='submit', css_class='btn-primary', )))