示例#1
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",
                ),
            ),
        )
示例#2
0
 def __init__(self, request, *args, **kwargs):
     super(UpdateIncrementalExportForm, self).__init__(*args, **kwargs)
     self.domain = request.domain
     self.fields['id'] = forms.CharField(widget=forms.HiddenInput())
     self.fields['export_instance_id'] = forms.ChoiceField(
         label=_('Case Data Export'),
         choices=_get_case_data_export_choices(request),
     )
     self.fields['connection_settings'].queryset = ConnectionSettings.objects.filter(domain=self.domain)
     self.helper = HQFormHelper()
     self.helper.layout = crispy.Layout(
         crispy.Field('id'),
         crispy.Field('name'),
         crispy.Field('export_instance_id'),
         crispy.Field('connection_settings'),
         crispy.Field('active'),
         hqcrispy.FormActions(
             twbscrispy.StrictButton(
                 ugettext_lazy("Update"),
                 css_class='btn btn-primary',
                 type='submit',
             ),
             crispy.HTML('<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>'),
             css_class="modal-footer",
         )
     )
示例#3
0
    def __init__(self, domain_object, location, *args, **kwargs):
        self.domain_object = domain_object
        self.location = location
        super(UsersAtLocationForm, self).__init__(
            initial={'selected_ids': self.get_users_at_location()},
            prefix="users", *args, **kwargs
        )

        from corehq.apps.reports.filters.api import MobileWorkersOptionsView
        self.fields['selected_ids'].widget.set_url(
            reverse(MobileWorkersOptionsView.urlname, args=(self.domain_object.name,))
        )
        self.fields['selected_ids'].widget.set_initial(self.get_users_at_location())
        self.helper = FormHelper()
        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(
                _("Specify Workers at this Location"),
                crispy.Field('selected_ids'),
            ),
            hqcrispy.FormActions(
                crispy.ButtonHolder(
                    Submit('submit', ugettext_lazy("Update Location Membership"))
                )
            )
        )
示例#4
0
 def form_actions(self):
     return hqcrispy.FormActions(
         twbscrispy.StrictButton(
             ugettext_lazy('Request Access'),
             type='submit',
             css_class='btn-primary',
         ))
示例#5
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'
             ),
         ),
     )
示例#6
0
    def __init__(self, domain, *args, **kwargs):
        super(AddTransifexBlacklistForm, self).__init__(*args, **kwargs)
        self.helper = hqcrispy.HQFormHelper()

        self.fields['app_id'].choices = tuple(
            (app.id, app.name) for app in get_brief_apps_in_domain(domain))
        form_fields = [
            hqcrispy.Field('app_id'),
            hqcrispy.Field('module_id'),
            hqcrispy.Field('field_type'),
            hqcrispy.Field('field_name'),
            hqcrispy.Field('display_text'),
            hqcrispy.Field('domain'),
            hqcrispy.Field('action'),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    ugettext_lazy("Add"),
                    type="submit",
                    css_class="btn-primary disable-on-submit",
                ))
        ]
        self.helper.layout = crispy.Layout(
            crispy.Fieldset(ugettext_lazy("Add translation to blacklist"),
                            *form_fields), )
        self.fields['action'].initial = 'blacklist'
        self.fields['domain'].initial = domain
示例#7
0
    def __init__(self, *args, **kwargs):
        if 'domain' not in kwargs:
            raise Exception('Expected kwargs: domain')
        self.domain = kwargs.pop('domain')
        require_email = kwargs.pop('require_email', False)

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

        if require_email:
            self.fields['email'].required = True

        self.helper = FormHelper()
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-xs-4'
        self.helper.field_class = 'col-xs-8'
        layout_fields = [
            crispy.Fieldset(
                _('Register'),
                crispy.Field('username', placeholder='sam123'),
                crispy.Field('password'),
                crispy.Field('password2'),
                crispy.Field('email'),
            ),
            hqcrispy.FormActions(
                StrictButton(
                    _('Register'),
                    css_class='btn-primary',
                    type='submit',
                )),
        ]
        self.helper.layout = crispy.Layout(*layout_fields)
示例#8
0
    def __init__(self, *args, **kwargs):
        super(ExampleUserLoginForm, self).__init__(*args, **kwargs)

        # Here's what makes the form a Crispy Form and adds in a few Bootstrap classes
        self.helper = hqcrispy.HQFormHelper()

        # This is the layout of the form where we can explicitly specify the
        # order of fields and group fields into fieldsets.
        self.helper.layout = crispy.Layout(
            crispy.Fieldset(
                # This is the title for the group of fields that follows:
                _("Basic Information"),
                'full_name',  # crispy.Field is used as the default display component
                crispy.Field(
                    'email'),  # effectively the same as the line above
                'password',
                'password_repeat',
            ),
            crispy.Fieldset(
                _("Advanced Information"),
                'is_staff',
                twbscrispy.PrependedText('phone_number',
                                         '+',
                                         placeholder='15555555555'),
            ),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(_("Create User"),
                                        type='submit',
                                        css_class='btn-primary'),
                twbscrispy.StrictButton(_("Cancel"), css_class='btn-default'),
            ),
        )
示例#9
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",
                ),
            ),
        )
示例#10
0
    def __init__(self, domain, config, *args, **kwargs):
        self.domain = domain
        self.config = config

        def _to_initial(config):
            initial = copy.copy(config._doc)
            initial['schedule_interval'] = config.schedule.interval
            if config.template_variables:
                initial['application'] = config.template_variables[0].app_id
                initial['source'] = config.template_variables[0].source_id
                initial['time_range'] = config.template_variables[0].time_range
            return initial

        super(PerformanceMessageEditForm,
              self).__init__(initial=_to_initial(config), *args, **kwargs)

        self.fields['recipient_id'] = GroupField(domain=domain,
                                                 label=_('Recipient Group'))

        self.app_source_helper = ApplicationDataSourceUIHelper(
            enable_cases=False)
        self.app_source_helper.bootstrap(self.domain)
        data_source_fields = self.app_source_helper.get_fields()
        self.fields.update(data_source_fields)

        self.helper = _get_default_form_helper()
        form_layout = self.fields.keys()
        form_layout.append(
            hqcrispy.FormActions(
                StrictButton(
                    _("Save Changes"),
                    type="submit",
                    css_class="btn btn-primary",
                ), ))
        self.helper.layout = Layout(*form_layout)
示例#11
0
 def __init__(self, **kwargs):
     super(HQTwoFactorMethodForm, self).__init__(**kwargs)
     if not settings.ALLOW_PHONE_AS_DEFAULT_TWO_FACTOR_DEVICE:
         # Block people from setting up the phone method as their default
         phone_methods = [
             method for method, _ in get_available_phone_methods()
         ]
         self.fields['method'].choices = [
             (method, display_name)
             for method, display_name in self.fields['method'].choices
             if method not in phone_methods
         ]
     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'
     # Next button is defined first so the enter key triggers it
     self.helper.layout = crispy.Layout(
         crispy.Fieldset(
             '', crispy.Div(crispy.Field('method'), css_class='radio')),
         hqcrispy.FormActions(
             twbscrispy.StrictButton(
                 _('Next'),
                 css_class='btn-primary',
                 type='submit',
             ),
             twbscrispy.StrictButton(
                 _("Back"),
                 css_class='btn-default',
                 type='submit',
                 value='welcome_setup',
                 name="wizard_goto_step",
             ),
         ))
示例#12
0
 def __init__(self, *args, **kwargs):
     button_text = kwargs.pop('button_text', _("Create SMS Gateway"))
     self._cchq_domain = kwargs.pop('domain')
     self._cchq_backend_id = kwargs.pop('backend_id')
     super(BackendForm, 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.form_method = 'POST'
     self.helper.layout = crispy.Layout(
         crispy.Fieldset(_('General Settings'), *self.general_fields),
         self.gateway_specific_fields,
         crispy.Fieldset(
             _("Phone Numbers"),
             crispy.Div(data_bind="template: {"
                        " name: 'ko-load-balancing-template', "
                        " data: $data"
                        "}", ),
             data_bind="visible: use_load_balancing",
         ),
         hqcrispy.FormActions(
             StrictButton(button_text,
                          type="submit",
                          css_class='btn-primary'), ),
     )
示例#13
0
    def __init__(self, domain, *args, **kwargs):
        super(AppTranslationsForm, self).__init__(*args, **kwargs)
        self.domain = domain
        self.helper = FormHelper()
        self.helper.form_tag = False
        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.fields['app_id'].choices = tuple((app.id, app.name) for app in get_brief_apps_in_domain(domain))
        if settings.TRANSIFEX_DETAILS:
            self.fields['transifex_project_slug'].choices = (
                tuple((slug, slug)
                      for slug in settings.TRANSIFEX_DETAILS.get('project').get(domain))
            )
        self.helper.layout = Layout(
            'app_id',
            'version',
            'use_version_postfix',
            'update_resource',
            'transifex_project_slug',
            hqcrispy.Field('source_lang', css_class="ko-select2"),
            hqcrispy.Field('target_lang', css_class="ko-select2"),
            'action',
            'lock_translations',
            'perform_translated_check',
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    ugettext_lazy("Submit"),
                    type="submit",
                    css_class="btn btn-primary btn-lg disable-on-submit",
                )
            )
        )
示例#14
0
    def __init__(self, *args, **kwargs):
        button_text = kwargs.pop('button_text', _("Create SMS Gateway"))
        self.domain = kwargs.pop('domain')
        self.backend_id = kwargs.pop('backend_id')
        super(BackendForm, self).__init__(*args, **kwargs)
        self.helper = HQFormHelper()
        self.helper.form_method = 'POST'
        self.helper.layout = crispy.Layout(
            crispy.Fieldset(_('General Settings'), *self.general_fields),
            self.gateway_specific_fields,
            crispy.Fieldset(
                _("Phone Numbers"),
                crispy.Div(data_bind="template: {"
                           " name: 'ko-load-balancing-template', "
                           " data: $data"
                           "}", ),
                data_bind="visible: use_load_balancing",
            ),
            hqcrispy.FormActions(
                StrictButton(button_text,
                             type="submit",
                             css_class='btn-primary'), ),
        )

        if self.backend_id:
            #   When editing, don't allow changing the name because name might be
            # referenced as a contact-level backend preference.
            #   By setting disabled to True, Django makes sure the value won't change
            # even if something else gets posted.
            self.fields['name'].disabled = True
示例#15
0
    def __init__(self, initial, **kwargs):
        self.user = initial.pop('user')
        super(DisableUserForm, self).__init__(initial=initial, **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'

        action = _("Disable") if self.user.is_active else _("Enable")
        css_class = 'btn-danger' if self.user.is_active else 'btn-primary'
        self.helper.layout = crispy.Layout(
            crispy.Field('reason'),
            crispy.Field('reset_password'),
            hqcrispy.FormActions(
                crispy.Submit(
                    "submit",
                    action,
                    css_class="btn %s" % css_class,
                ),
                css_class='modal-footer',
            ),
        )
示例#16
0
    def __init__(self, domain_object, location, *args, **kwargs):
        self.domain_object = domain_object
        self.location = location
        fieldset_title = kwargs.pop('fieldset_title',
                                    ugettext_lazy("Edit Group Membership"))
        submit_label = kwargs.pop('submit_label',
                                  ugettext_lazy("Update Membership"))

        super(UsersAtLocationForm,
              self).__init__(initial={'selected_ids': self.users_at_location},
                             *args,
                             **kwargs)

        from corehq.apps.reports.filters.api import MobileWorkersOptionsView
        self.fields['selected_ids'].widget.set_url(
            reverse(MobileWorkersOptionsView.urlname,
                    args=(self.domain_object.name, )))
        self.fields['selected_ids'].widget.set_initial(self.users_at_location)
        self.helper = FormHelper()
        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'),
            ),
            hqcrispy.FormActions(
                crispy.ButtonHolder(Submit('submit', submit_label))))
示例#17
0
    def __init__(self, domain, *args, **kwargs):
        super(AppTranslationsForm, self).__init__(*args, **kwargs)
        self.domain = domain
        self.helper = FormHelper()
        self.helper.form_tag = False
        self.helper.label_class = 'col-sm-4 col-md-4 col-lg-3'
        self.helper.field_class = 'col-sm-6 col-md-6 col-lg-5'

        self.fields['app_id'].choices = tuple(
            (app.id, app.name) for app in get_brief_apps_in_domain(domain))
        projects = TransifexProject.objects.filter(domain=domain).all()
        if projects:
            self.fields['transifex_project_slug'].choices = (tuple(
                (project.slug, project) for project in projects))
        form_fields = self.form_fields()
        self.helper.layout = crispy.Layout(
            crispy.Fieldset("", *form_fields),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    ugettext_lazy("Submit"),
                    type="submit",
                    css_class="btn btn-primary disable-on-submit",
                    onclick="return confirm('%s')" %
                    ugettext_lazy("Please confirm that you want to proceed?")))
        )
        self.fields['action'].initial = self.form_action
示例#18
0
    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 None,
            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)
示例#19
0
    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',
                )
            ),
        )
示例#20
0
    def __init__(self, *args, **kwargs):
        super(AdvancedPrimeRestoreCacheForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-lg-2'
        self.helper.field_class = 'col-lg-4'
        self.helper.form_method = 'post'
        self.helper.form_action = '.'

        self.helper.layout = crispy.Layout(
            crispy.Field('check_cache_only', data_ng_model='check_cache_only'),
            crispy.Div('version',
                       'cache_timeout',
                       'overwrite_cache',
                       data_ng_hide='check_cache_only'),
            crispy.Field('all_users', data_ng_model='all_users'),
            'domain',
            crispy.Div('users', data_ng_hide='all_users'),
            hqcrispy.FormActions(
                StrictButton(
                    "Submit",
                    css_class="btn-primary",
                    type="submit",
                ), ),
        )
示例#21
0
    def __init__(self, *args, **kwargs):
        self.domain = kwargs.pop('domain')
        super(CommCareUserFilterForm, self).__init__(*args, **kwargs)

        roles = UserRole.by_domain(self.domain)
        self.fields['role_id'].choices = [('', _('All Roles'))] + [
            (role._id, role.name or _('(No Name)')) for role in roles
        ]

        self.helper = FormHelper()
        self.helper.form_method = 'GET'
        self.helper.form_id = 'user-filters'
        self.helper.form_class = 'form-horizontal'
        self.helper.form_action = reverse('download_commcare_users',
                                          args=[self.domain])

        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_text_inline = True

        self.helper.layout = crispy.Layout(
            crispy.Fieldset(
                _("Filter and Download Users"),
                crispy.Field('role_id'),
                crispy.Field('search_string'),
            ),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    _("Download All Users"),
                    type="submit",
                    css_class="btn btn-primary submit_button",
                )),
        )
示例#22
0
    def __init__(self, domain, *args, **kwargs):
        self.domain = domain
        super(ConsumptionForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_tag = False
        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'

        layout = []
        products = SQLProduct.active_objects.filter(domain=domain)
        for product in products:
            field_name = 'default_%s' % product.product_id
            display = _('Default %(product_name)s') % {'product_name': product.name}
            layout.append(field_name)
            self.fields[field_name] = forms.DecimalField(
                label=display,
                required=False,
                initial=get_default_monthly_consumption(
                    self.domain,
                    product.product_id,
                    None,
                    None
                )
            )

        layout.append(hqcrispy.FormActions(
            ButtonHolder(
                Submit('submit', ugettext_lazy('Update Default Consumption Info'))
            )
        ))
        self.helper.layout = Layout(*layout)
示例#23
0
 def __init__(self, request, domain, email, *args, **kwargs):
     self.domain = domain
     self.email = email
     super(HostedCCZForm, self).__init__(*args, **kwargs)
     self.fields['link_id'].choices = self.link_choices()
     self.fields['app_id'].choices = self.app_id_choices()
     self.helper = HQFormHelper()
     if request.GET.get('app_id'):
         self.fields['app_id'].initial = request.GET.get('app_id')
     if request.GET.get('link_id'):
         self.fields['link_id'].initial = request.GET.get('link_id')
     if request.GET.get('status'):
         self.fields['status'].initial = request.GET.get('status')
     self.helper.layout = crispy.Layout(
         crispy.Field('link_id',
                      css_class="hqwebapp-select2",
                      id="link-id-select"),
         crispy.Field('app_id',
                      css_class="hqwebapp-select2",
                      id='app-id-search-select'),
         crispy.Field('version', id='version-input'),
         crispy.Field('profile_id', id='build-profile-id-input'),
         crispy.Field('file_name'), crispy.Field('note'),
         crispy.Field('status'),
         hqcrispy.FormActions(
             crispy.ButtonHolder(
                 crispy.Button('search',
                               ugettext_lazy("Search"),
                               data_bind="click: search"),
                 crispy.Button('clear',
                               ugettext_lazy("Clear"),
                               data_bind="click: clear"),
                 Submit('submit', ugettext_lazy("Create")))))
示例#24
0
    def __init__(self, user, *args, **kwargs):

        super(HQPasswordChangeForm, self).__init__(user, *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(
            crispy.Fieldset(
                _('Specify New Password'),
                'old_password',
                crispy.Field(
                    'new_password1',
                    data_bind="value: password, valueUpdate: 'input'",
                ),
                'new_password2',
                css_class="check-password",
            ),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    _('Change Password'),
                    css_class='btn-primary',
                    type='submit',
                )),
        )
示例#25
0
    def __init__(self, *args, **kwargs):
        super(SelectControlDemoForm, self).__init__(*args, **kwargs)
        # note that we apply choices to a field AFTER the call to super
        self.fields['language'].choices = _language_resource()
        self.fields['genres'].choices = _genre_resource()

        self.helper = FormHelper()
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-sm-3 col-md-2 col-lg-2'
        self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6'

        self.helper.layout = crispy.Layout(
            crispy.Fieldset(
                _("Standard Selects"),
                'office',
                'colors',
                'language',
                'genres',
            ),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(_("Update Selects"),
                                        type='submit',
                                        css_class='btn-primary'),
                offsets='col-sm-offset-3 col-md-offset-2 col-lg-offset-2',
            ),
        )
示例#26
0
    def __init__(self, domain, *args, **kwargs):
        super(ConfigurableDataSourceFromAppForm,
              self).__init__(*args, **kwargs)
        self.app_source_helper = ApplicationDataSourceUIHelper()
        self.app_source_helper.bootstrap(domain)
        report_source_fields = self.app_source_helper.get_fields()
        self.fields.update(report_source_fields)
        self.helper = FormHelper()
        self.helper.form_id = "data-source-config"

        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(_("Create Data Source from Application"),
                            *list(report_source_fields)),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    _("Create Data Source"),
                    type="submit",
                    css_class="btn btn-primary",
                ), ),
        )
示例#27
0
    def __init__(self, *args, **kwargs):
        super(BasicCrispyForm, 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.Fieldset(
                _("Basic Information"),
                crispy.Field('first_name'),
                crispy.Field('favorite_color'),
            ),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    _("Submit Information"),
                    type="submit",
                    css_class="btn btn-primary",
                ),
                hqcrispy.LinkButton(
                    _("Cancel"),
                    '#',
                    css_class="btn btn-default",
                ),
            ),
        )
示例#28
0
    def __init__(self, initial, **kwargs):
        self.username = initial.pop('username')
        super(DisableTwoFactorForm, self).__init__(initial=initial, **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.Fieldset(
                _("Basic Information"),
                crispy.Field('username'),
                crispy.Field('verification_mode'),
                crispy.Field('via_who'),
                crispy.Field('disable_for_days'),
            ),
            hqcrispy.FormActions(
                crispy.Submit(
                    "disable",
                    _("Disable"),
                    css_class="btn btn-danger",
                ),
                css_class='modal-footer',
            ),
        )
示例#29
0
    def __init__(self, *args, **kwargs):
        super(BasicCrispyForm, 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"),
                crispy.Field('first_name'),
                crispy.Field('favorite_color'),
            ),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    _("Save"),
                    type="submit",
                    css_class="btn btn-primary",
                ),
                hqcrispy.LinkButton(
                    _("Cancel"),
                    '#',
                    css_class="btn btn-default",
                ),
            ),
        )
示例#30
0
    def __init__(self,
                 account,
                 domain,
                 creating_user,
                 data=None,
                 *args,
                 **kwargs):
        super(ConfirmExtraUserChargesForm, self).__init__(account,
                                                          domain,
                                                          creating_user,
                                                          data=data,
                                                          *args,
                                                          **kwargs)

        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 accounting-email-select2',
                    data_initial=json.dumps(self.initial.get('email_list'))),
                'phone_number',
            ),
            crispy.Fieldset(
                _("Mailing Address"),
                'first_line',
                'second_line',
                'city',
                'state_province_region',
                'postal_code',
                crispy.Field(
                    'country',
                    css_class="input-large accounting-country-select2",
                    data_country_code=self.current_country or '',
                    data_country_name=COUNTRIES.get(self.current_country, '')),
            ),
            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',
                ),
            ),
        )