示例#1
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'),
            ),
        )
示例#2
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
示例#3
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",
                ),
            ),
        )
示例#4
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",
                ),
            ),
        )
示例#5
0
    def helper(self):
        from corehq.motech.views import ConnectionSettingsListView

        helper = hqcrispy.HQFormHelper()
        helper.layout = crispy.Layout(
            crispy.Field('name'),
            crispy.Field('notify_addresses_str'),
            crispy.Field('url'),
            crispy.Field('auth_type'),
            crispy.Field('api_auth_settings'),
            crispy.Field('username'),
            crispy.Field('plaintext_password'),
            crispy.Field('client_id'),
            crispy.Field('plaintext_client_secret'),
            twbscrispy.PrependedText('skip_cert_verify', ''),
            self.test_connection_button,
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    _("Save"),
                    type="submit",
                    css_class="btn btn-primary",
                ),
                hqcrispy.LinkButton(
                    _("Cancel"),
                    reverse(
                        ConnectionSettingsListView.urlname,
                        kwargs={'domain': self.domain},
                    ),
                    css_class="btn btn-default",
                ),
            ),
        )

        return helper
示例#6
0
    def __init__(self, domain, *args, **kwargs):
        from corehq.motech.views import ConnectionSettingsListView

        if kwargs.get('instance'):
            # `plaintext_password` is not a database field, and so
            # super().__init__() will not update `initial` with it. We
            # need to do that here.
            #
            # We use PASSWORD_PLACEHOLDER to avoid telling the user what
            # the password is, but still indicating that it has been
            # set. (The password is only changed if its value is not
            # PASSWORD_PLACEHOLDER.)
            password = kwargs['instance'].plaintext_password
            secret = kwargs['instance'].plaintext_client_secret
            if 'initial' in kwargs:
                kwargs['initial'].update({
                    'plaintext_password': PASSWORD_PLACEHOLDER if password else '',
                    'plaintext_client_secret': PASSWORD_PLACEHOLDER if secret else '',
                })
            else:
                kwargs['initial'] = {
                    'plaintext_password': PASSWORD_PLACEHOLDER if password else '',
                    'plaintext_client_secret': PASSWORD_PLACEHOLDER if secret else '',
                }
        super().__init__(*args, **kwargs)

        self.domain = domain
        self.helper = hqcrispy.HQFormHelper()
        self.helper.layout = crispy.Layout(
            crispy.Field('name'),
            crispy.Field('notify_addresses_str'),
            crispy.Field('url'),
            crispy.Field('auth_type'),
            crispy.Field('api_auth_settings'),
            crispy.Field('username'),
            crispy.Field('plaintext_password'),
            crispy.Field('client_id'),
            crispy.Field('plaintext_client_secret'),
            twbscrispy.PrependedText('skip_cert_verify', ''),
            self.test_connection_button,

            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    _("Save"),
                    type="submit",
                    css_class="btn btn-primary",
                ),
                hqcrispy.LinkButton(
                    _("Cancel"),
                    reverse(
                        ConnectionSettingsListView.urlname,
                        kwargs={'domain': self.domain},
                    ),
                    css_class="btn btn-default",
                ),
            ),
        )
示例#7
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")))))
示例#8
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")))))
示例#9
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")))))
示例#10
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")))))
示例#11
0
    def __init__(self, domain, *args, **kwargs):
        from corehq.motech.dhis2.views import DataSetMapListView
        kwargs['initial'] = add_initial_properties(kwargs.get('instance'), kwargs.get('initial'))

        super().__init__(*args, **kwargs)
        self.domain = domain
        self.fields['connection_settings'] = get_connection_settings_field(domain)
        self.fields['ucr_id'] = get_ucr_field(domain)

        self.helper = hqcrispy.HQFormHelper()

        self.helper.layout = crispy.Layout(
            crispy.Fieldset(
                _('DataSet Details'),
                crispy.Field('description'),
                crispy.Field('connection_settings'),
                crispy.Field('ucr_id'),
                crispy.Field('frequency'),
                crispy.Field('day_to_send'),
                crispy.Field('data_set_id'),
                crispy.Field('org_unit_id'),
                crispy.Field('period'),
                crispy.Field('attribute_option_combo_id'),
                crispy.Field('complete_date_option'),
                crispy.Field('complete_date_column'),
            ),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    _("Save"),
                    type="submit",
                    css_class="btn btn-primary",
                ),
                hqcrispy.LinkButton(
                    _("Cancel"),
                    reverse(
                        DataSetMapListView.urlname,
                        kwargs={'domain': self.domain},
                    ),
                    css_class="btn btn-default",
                ),
            ),
        )
示例#12
0
    def __init__(self, *args, **kwargs):
        self.domain = kwargs.pop('domain')
        super().__init__(*args, **kwargs)
        self.fields['root_location_id'].widget = LocationSelectWidget(self.domain, placeholder=_("All Locations"))

        self.helper = hqcrispy.HQFormHelper()
        self.helper.form_method = 'GET'
        self.helper.form_action = reverse('location_export', args=[self.domain])

        self.helper.layout = crispy.Layout(
            crispy.Fieldset(
                _("Filter and Download Locations"),
                crispy.Field('root_location_id'),
            ),
            hqcrispy.FormActions(
                StrictButton(
                    _("Download Locations"),
                    type="submit",
                    css_class="btn btn-primary",
                )
            ),
        )
示例#13
0
    def __init__(self, *args, **kwargs):
        self.domain = kwargs.pop('domain')
        self.user = kwargs.pop('user')
        super().__init__(*args, **kwargs)
        self.fields['location_id'].widget = LocationSelectWidget(
            self.domain,
            id='id_location_id',
            placeholder=_("All Locations"),
            attrs={'data-bind': 'value: location_id'},
        )
        self.fields[
            'location_id'].widget.query_url = "{url}?show_all=true".format(
                url=self.fields['location_id'].widget.query_url)

        self.helper = hqcrispy.HQFormHelper()
        self.helper.form_method = 'GET'
        self.helper.form_id = 'locations-filters'
        self.helper.form_action = reverse('location_export',
                                          args=[self.domain])

        self.helper.layout = crispy.Layout(
            crispy.Fieldset(
                _("Filter and Download Locations"),
                crispy.Field('location_id', ),
                crispy.Div(
                    crispy.Field('selected_location_only',
                                 data_bind='checked: selected_location_only'),
                    data_bind="slideVisible: location_id",
                ),
                crispy.Field('location_status_active', ),
            ),
            hqcrispy.FormActions(
                StrictButton(
                    _("Download Locations"),
                    type="submit",
                    css_class="btn btn-primary",
                    data_bind="html: buttonHTML",
                ), ),
        )