Exemplo n.º 1
0
 def special_crispy_fields(self):
     """
     DRY mapping that can be used in generating self.get_ordered_crispy_form_fields
     """
     return {
         "test_link":
         crispy.Div(crispy.Div(
             twbscrispy.StrictButton(
                 _('Test Link'),
                 type='button',
                 css_id='test-forward-link',
                 css_class='btn btn-default disabled',
             ),
             crispy.Div(
                 css_id='test-forward-result',
                 css_class='text-success hide',
             ),
             css_class='{} {}'.format(self.helper.field_class,
                                      self.helper.offset_class),
         ),
                    css_class='form-group'),
         "auth_type":
         twbscrispy.PrependedText('auth_type', ''),
         "skip_cert_verify":
         twbscrispy.PrependedText('skip_cert_verify', ''),
     }
Exemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        photographer = kwargs.pop('photographer')
        assert isinstance(photographer, models.LuminaUser)
        assert photographer.is_photographer()

        super().__init__(*args, **kwargs)
        self.helper = helper.FormHelper()
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-lg-2'
        self.helper.field_class = 'col-lg-8'

        self.helper.layout = helper.Layout(
            layout.Fieldset(
                'Actualizar presupuesto', 'name', 'customer', 'image_quantity',
                forms_utils.DatePickerField('stipulated_date'),
                bootstrap.PrependedText('cost', '$'),
                bootstrap.PrependedText('stipulated_down_payment', '$'),
                'terms'),
            bootstrap.FormActions(
                layout.Submit('submit_update_quote',
                              'Actualizar',
                              css_id='form-submit-button'),
                layout.HTML(
                    '<a href="{% url "quote_detail" object.id %}" class="btn btn-primary">Volver</a>'
                )),
        )

        self.fields[
            'customer'].queryset = models.Customer.objects.customers_of(
                photographer)
Exemplo n.º 3
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     email_field = bootstrap.PrependedText(
         "email",
         '<i class="fas fa-envelope"></i>',
         css_class="form-control",
         placeholder="*****@*****.**")
     birth_date_field = bootstrap.PrependedText(
         "birth_date",
         '<i class="fa fa-calendar"></i>',
         css_class="datetimepicker")
     self.helper = FormHelper()
     self.helper.form_method = "POST"
     self.helper.form_action = "profile"
     self.helper.layout = Layout(
         'username',
         Row(
             Column('first_name', css_class='form-group col-md-6 mb-3'),
             Column('last_name', css_class='form-group col-md-6 mb-3'),
         ),
         Row(
             Column(email_field),
             Column(CustomCheckbox('birth_date')),
         ),
         Submit('submit', _('Update')),
     )
Exemplo n.º 4
0
 def get_ordered_crispy_form_fields(self):
     fields = super().get_ordered_crispy_form_fields()
     return fields + [
         'fhir_version',
         twbscrispy.PrependedText('patient_registration_enabled', ''),
         twbscrispy.PrependedText('patient_search_enabled', ''),
     ]
Exemplo n.º 5
0
    def __init__(self, *args, **kwargs):
        self.user = kwargs['existing_user']
        api_key = kwargs.pop('api_key') if 'api_key' in kwargs else None
        super(UpdateMyAccountInfoForm, self).__init__(*args, **kwargs)
        self.username = self.user.username

        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_analytics_enabled:
            basic_fields.append(
                twbscrispy.PrependedText('analytics_enabled', ''), )
        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',
                )))
Exemplo n.º 6
0
    def __init__(self, *args, **kwargs):
        super(BulletinForm, self).__init__(*args, **kwargs)

        self.helper = FormHelper()
        self.helper.form_action = "."
        self.helper.form_methon = "POST"

        #delete empty choice for the tpe
        del self.fields['bulletin_type'].choices[0]

        # self.helper.add_input(Submit('submit', 'Submit'))
        # self.helper.add_input(Submit('cancel', 'Cancel', css_class='btn-danger',formnovalidate='formnovalidate'))

        self.helper.layout = layout.Layout(
            layout.Fieldset(
                _("Main data"),
                # layout.Field("bulletin_type"),
                bootstrap.InlineRadios("bulletin_type"),
                layout.Field("title", css_class="input-block-level"),
                layout.Field("description",
                             css_class="input-block-level",
                             rows="3"),
            ),
            layout.Fieldset(
                _("Image"),
                layout.Field("image", css_class="input-block-level"),
                layout.HTML(u""" {% load i18n %}
                        <p class='help-block'>{% trans "Available formats are ..." %}</p>
                    """),
                title=_("Image upload"),
                css_id="image_fieldset",
            ),
            layout.Fieldset(
                _('Contact'),
                layout.Field("contact_person", css_cass="input-block-level"),
                layout.Div(
                    bootstrap.PrependedText(
                        "phone",
                        """<span class='glyphicon glyphicon-earphone'></span>""",
                        css_class="input-block-level"),
                    bootstrap.PrependedText("email",
                                            "@",
                                            placeholder="*****@*****.**"),
                    css_id="contact_info",
                ),
            ),
            layout.ButtonHolder(
                layout.Submit('submit', _('Save')),
                layout.Submit(
                    'cancel',
                    _('Cancel'),
                    css_class='btn-warning',
                    formnovalidate='formnovalidate',
                )))
Exemplo n.º 7
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.fields["bulletin_type"].widget = forms.RadioSelect()
        # delete empty choice for the type
        del self.fields["bulletin_type"].choices[0]

        title = layout.Field("title", css_class="input-block-level")
        desciption = layout.Field("description",
                                  css_class="input-block-level",
                                  rows="3")
        main_fieldset = layout.Fieldset(_("Main data"), "bulletin_type", title,
                                        desciption)

        image = layout.Field("image", css_class="input-block-level")
        format_html_template = """
            {% load i18n %}
            <p class="help-block">
            {% trans "Available formats are JPG, GIF, and PNG." %}
            {% trans "Minimal size is 800 × 800 px." %}
            </p>
            """
        format_html = layout.HTML(format_html_template)
        image_fieldset = layout.Fieldset(_("Image"),
                                         image,
                                         format_html,
                                         title=_("Image upload"),
                                         css_id="image_fieldset")

        contact_person = layout.Field("contact_person",
                                      css_class="input-block-level")
        phone_field = bootstrap.PrependedText(
            "phone",
            '<i class="ion-ios-telephone"></i>',
            css_class="input-block-level")
        email_field = bootstrap.PrependedText(
            "email",
            "@",
            css_class="input-block-level",
            placeholder="*****@*****.**")
        contact_info = layout.Div(phone_field,
                                  email_field,
                                  css_id="contact_info")
        contact_fieldset = layout.Fieldset(_("Contact"), contact_person,
                                           contact_info)

        submit_button = layout.Submit("submit", _("Save"))
        actions = bootstrap.FormActions(submit_button)

        self.helper = helper.FormHelper()
        self.helper.form_action = "bulletin-change"
        self.helper.form_method = "POST"
        self.helper.layout = layout.Layout(main_fieldset, image_fieldset,
                                           contact_fieldset, actions)
Exemplo n.º 8
0
    def __init__(self, identity_provider, *args, **kwargs):
        self.idp = identity_provider
        kwargs['initial'] = {
            'name': identity_provider.name,
            'is_editable': identity_provider.is_editable,
            'is_active': identity_provider.is_active,
            'slug': identity_provider.slug,
        }
        super().__init__(*args, **kwargs)

        sp_details_form = ServiceProviderDetailsForm(identity_provider,
                                                     show_help_block=False)
        self.fields.update(sp_details_form.fields)

        from corehq.apps.accounting.views import ManageBillingAccountView
        account_link = reverse(ManageBillingAccountView.urlname,
                               args=(identity_provider.owner.id, ))

        if self.idp.is_editable:
            self.fields['is_editable'].help_text = format_html(
                '<a href="{}">{}</a>',
                url_helpers.get_dashboard_link(self.idp),
                _("Edit Enterprise Settings"))

        self.helper = FormHelper()
        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.layout = crispy.Layout(
            crispy.Div(crispy.Div(crispy.Fieldset(
                _('Primary Configuration'),
                hqcrispy.B3TextField(
                    'owner',
                    format_html('<a href="{}">{}</a>', account_link,
                                identity_provider.owner.name)),
                'name',
                twbscrispy.PrependedText('is_editable', ''),
                twbscrispy.PrependedText('is_active', ''),
            ),
                                  css_class="panel-body"),
                       css_class="panel panel-modern-gray panel-form-only"),
            crispy.Div(crispy.Div(crispy.Fieldset(
                _('Service Provider Settings'), 'slug',
                *sp_details_form.service_provider_fields),
                                  css_class="panel-body"),
                       css_class="panel panel-modern-gray panel-form-only"),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    ugettext_lazy("Update Configuration"),
                    type="submit",
                    css_class="btn btn-primary",
                )))
Exemplo n.º 9
0
    def __init__(self, *args, **kwargs):
        super(BulletinForm, self).__init__(*args, **kwargs)

        self.helper = FormHelper()
        self.helper.form_action = ""
        self.helper.form_method = "POST"

        self.fields["bulletin_type"].widget = forms.RadioSelect()

        # delete empty choice for the type
        del self.fields["bulletin_type"].choices[0]

        self.helper.layout = layout.Layout(
            layout.Fieldset(
                _("Main data"),
                layout.Field("bulletin_type"),
                layout.Field("title", css_class="input-block-level"),
                layout.Field("description", css_class="input-blocklevel", rows=3),
            ),
            layout.Fieldset(
                _("Image"),
                layout.Field("image", css_class="input-block-level"),
                layout.HTML(
                    u"""
                    {% load i18n%}
                    <p class="help-block">
                        {% trans "Available formats are JPG, GIF, PNG. Minimal size is 800 x 800 px." %}
                    </p>
                    """
                ),
                title=_("Image upload"),
                css_id="image_fieldset",
            ),
            layout.Fieldset(
                _("Contact"),
                layout.Field("contact_person", css_class="input-blocklevel"),
                layout.Div(
                    bootstrap.PrependedText("phone", """<span class="glyphicon glyphicon-earphone"></span>""",
                                            css_class="input-blocklevel"),
                    bootstrap.PrependedText("email", "@", css_class="input-block-level",
                                            placeholder="*****@*****.**"),
                    css_id="contact_info",
                ),
            ),
            bootstrap.FormActions(
                layout.Submit("submit", _("Save"))
            )
        )
Exemplo n.º 10
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
Exemplo n.º 11
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'),
            ),
        )
Exemplo n.º 12
0
 def get_ordered_crispy_form_fields(self):
     fields = super(OpenmrsRepeaterForm,
                    self).get_ordered_crispy_form_fields()
     return [
         'location_id',
         twbscrispy.PrependedText('atom_feed_enabled', ''),
     ] + fields
Exemplo n.º 13
0
    def general_fields(self):
        fields = [
            crispy.Field('name', css_class='input-xxlarge'),
            crispy.Field('description', css_class='input-xxlarge', rows="3"),
            crispy.Field('reply_to_phone_number', css_class='input-xxlarge'),
        ]

        if not self.is_global_backend:
            fields.extend([
                crispy.Field(
                    twbscrispy.PrependedText(
                        'give_other_domains_access',
                        '',
                        data_bind="checked: share_backend")),
                crispy.Div(
                    'authorized_domains',
                    data_bind="visible: showAuthorizedDomains",
                ),
            ])

        if self.backend_id:
            backend = SQLMobileBackend.load(self.backend_id)
            if backend.show_inbound_api_key_during_edit:
                self.fields[
                    'inbound_api_key'].initial = backend.inbound_api_key
                fields.append(crispy.Field('inbound_api_key'))

        return fields
Exemplo n.º 14
0
 def __init__(self, *args, **kwargs):
     super(SubscribeSMSForm, self).__init__(*args, **kwargs)
     self.helper = HQFormHelper()
     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",
             ), ))
Exemplo n.º 15
0
def DatePickerField(field_name, *args, **kwargs):
    assert 'css_class' not in kwargs
    return bootstrap.PrependedText(field_name,
                                   '<i class="fa fa-calendar"></i>',
                                   css_class='force-datepicker',
                                   *args,
                                   **kwargs)
Exemplo n.º 16
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',
                )
            ),
        )
Exemplo n.º 17
0
class SessionQuoteCreateForm(_SessionQuoteValidateMixin,
                             forms_utils.GenericCreateUpdateModelForm):

    FORM_TITLE = 'Crear nuevo presupuesto'
    SUBMIT_LABEL = 'Crear'
    CANCEL_URL = reverse_lazy('quote_list')
    FIELDS = [
        'name', 'customer', 'image_quantity',
        forms_utils.DatePickerField('stipulated_date'),
        bootstrap.PrependedText('cost', '$'),
        bootstrap.PrependedText('stipulated_down_payment', '$'), 'terms'
    ]

    class Meta:
        model = models.SessionQuote
        fields = ('name', 'customer', 'image_quantity', 'stipulated_date',
                  'cost', 'stipulated_down_payment', 'terms')
Exemplo n.º 18
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",
                ),
            ),
        )
Exemplo n.º 19
0
    def __init__(self, *args, **kwargs):
        from corehq.apps.settings.views import ApiKeyView
        self.user = kwargs['existing_user']
        super(UpdateMyAccountInfoForm, self).__init__(*args, **kwargs)
        self.username = self.user.username

        username_controls = []
        if self.username:
            username_controls.append(hqcrispy.StaticField(
                ugettext_lazy('Username'), self.username)
            )

        self.fields['language'].label = ugettext_lazy("My Language")

        self.new_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 = [
            crispy.Div(*username_controls),
            hqcrispy.Field('first_name'),
            hqcrispy.Field('last_name'),
            hqcrispy.Field('email'),
        ]
        if self.set_analytics_enabled:
            basic_fields.append(twbscrispy.PrependedText('analytics_enabled', ''),)

        self.new_helper.layout = crispy.Layout(
            crispy.Fieldset(
                ugettext_lazy("Basic"),
                *basic_fields
            ),
            (hqcrispy.FieldsetAccordionGroup if self.collapse_other_options else crispy.Fieldset)(
                ugettext_lazy("Other Options"),
                hqcrispy.Field('language'),
                crispy.Div(hqcrispy.StaticField(
                    ugettext_lazy('API Key'),
                    mark_safe(
                        ugettext_lazy('API key management has moved <a href="{}">here</a>.')
                        .format(reverse(ApiKeyView.urlname))
                    ),
                )),
            ),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    ugettext_lazy("Update My Information"),
                    type='submit',
                    css_class='btn-primary',
                )
            )
        )
Exemplo n.º 20
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.form_class = 'form-horizontal'
     self.label_class = 'col-sm-3 col-md-2'
     self.field_class = 'col-sm-9 col-md-8 col-lg-6'
     self.layout = crispy.Layout(
         crispy.Fieldset(
             _('Remote Connection'),
             crispy.Field('name'),
             crispy.Field('url'),
             crispy.Field('auth_type'),
             crispy.Field('username'),
             crispy.Field('plaintext_password'),
             twbscrispy.PrependedText('skip_cert_verify', ''),
             crispy.Field('notify_addresses_str'),
             twbscrispy.PrependedText('DELETE',
                                      '',
                                      wrapper_class='alert alert-warning'),
         ), )
     self.add_input(crispy.Submit('submit', _('Save Connections')))
     self.render_required_fields = True
Exemplo n.º 21
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.form_class = 'form-horizontal'
        self.label_class = 'col-sm-3 col-md-2'
        self.field_class = 'col-sm-9 col-md-8 col-lg-6'
        self.layout = crispy.Layout(
            crispy.Fieldset(
                _('Incremental Export'),
                crispy.Field('name'),
                crispy.Field('export_instance_id'),
                crispy.Field('connection_settings'),
                twbscrispy.PrependedText('active', ''),

                twbscrispy.PrependedText(
                    'DELETE', '',
                    wrapper_class='alert alert-warning'
                ),
            ),
        )
        self.add_input(
            crispy.Submit('submit', _('Save'))
        )
        self.render_required_fields = True
Exemplo n.º 22
0
 def __init__(self, *args, **kwargs):
     super(CrispyEvidenceForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_action = ""
     self.helper.form_method = "POST"
     self.helper.form_class = 'form-horizontal'
     self.helper.label_class = 'col-lg-2'
     self.helper.field_class = 'col-lg-8'
     self.helper.layout = layout.Layout(
         layout.Div(
             layout.Fieldset(
                 _("Main data"),
                 layout.Field('title', wrapper_class='col-md-6'),
                 layout.Field('type', wrapper_class='col-md-6'),
                 layout.Field('status', wrapper_class='col-md-9'),
                 layout.Field('comment', wrapper_class='col-md-3'),
                 #css_class='form-row'
             )),
         layout.Fieldset(
             _("Main data"),
             layout.Field("classification"),
         ),
         layout.Fieldset(
             _("Authorisation"),
             layout.Field("authorisation"),
             layout.Field("assigned_to"),
             layout.Field("assigned_by"),
             layout.Div(
                 bootstrap.PrependedText("reference",
                                         "",
                                         css_class="input-block-level",
                                         placeholder="*****@*****.**"),
                 css_id="contact_info",
             ),
         ),
         layout.Fieldset(
             _("Main data"),
             bootstrap.TabHolder(
                 bootstrap.Tab(
                     'First Tab',
                     layout.Field('location', wrapper_class='col-md-6')),
                 bootstrap.Tab(
                     'Second Tab',
                     layout.Field('description', wrapper_class='col-md-6')),
             ),
         ),
         bootstrap.FormActions(layout.Submit("submit", _("Save")), ))
Exemplo n.º 23
0
    def __init__(self, *args, **kwargs):
        super(ExampleUserLoginForm, self).__init__(*args, **kwargs)

        # Here's what makes the form a Crispy Form:
        self.helper = FormHelper()

        # This is necessary to make the form a horizontal form
        self.helper.form_class = 'form-horizontal'

        # What do all these col-sm-3, col-md-2, col-lg-6 things mean? They
        # specify the column sizes for the label and field columns depending
        # on what the screen size is. This is called Responsive Design, and
        # you should visit
        # [Bootstrap 3's Responsive Docs](http://getbootstrap.com/css/#responsive-utilities)
        # for more information.
        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'

        # 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'),
            ),
        )
Exemplo n.º 24
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # TODO: Don't repeat from the PostForm
        self.helper = FormHelper(self)
        self.helper.layout = layout.Layout(
            layout.Fieldset(
                '', layout.Field('title',
                                 placeholder='A snappy title'), 'body', 'tags',
                bootstrap.PrependedText('price', '$'), 'unit', 'location'),
            bootstrap.FormActions(
                layout.Submit('submit',
                              'Update post',
                              css_class='btn btn-success'),
                layout.HTML(
                    '<a class="btn btn-outline-secondary" href="{% url "board:detail" slug=object.slug %}">Cancel</a>'
                ),
            ))
        self.helper.form_tag = False
Exemplo n.º 25
0
 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',
             )))
Exemplo n.º 26
0
 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'),
             twbscrispy.PrependedText('skip_cert_verify', ''),
         ),
         hqcrispy.FormActions(
             twbscrispy.StrictButton(
                 _("Update DHIS2 connection"),
                 type="submit",
                 css_class='btn-primary',
             )),
     )
Exemplo n.º 27
0
    def general_fields(self):
        fields = [
            crispy.Field('name', css_class='input-xxlarge'),
            crispy.Field('description', css_class='input-xxlarge', rows="3"),
            crispy.Field('reply_to_phone_number', css_class='input-xxlarge'),
        ]

        if not self.is_global_backend:
            fields.extend([
                crispy.Field(
                    twbscrispy.PrependedText(
                        'give_other_domains_access', '', data_bind="checked: share_backend"
                    )
                ),
                crispy.Div(
                    'authorized_domains',
                    data_bind="visible: showAuthorizedDomains",
                ),
            ])

        return fields
Exemplo n.º 28
0
 def get_primary_fields(self):
     return [
         crispy.Div(crispy.Div(crispy.Fieldset(
             _('Single Sign-On Settings'),
             hqcrispy.B3TextField(
                 'name',
                 self.idp.name,
             ),
             hqcrispy.B3TextField(
                 'linked_email_domains',
                 ", ".join(self.idp.get_email_domains()),
             ),
             twbscrispy.PrependedText('is_active', ''),
         ),
                               css_class="panel-body"),
                    css_class="panel panel-modern-gray panel-form-only"),
         hqcrispy.FormActions(
             twbscrispy.StrictButton(
                 gettext_lazy("Update Configuration"),
                 type="submit",
                 css_class="btn btn-primary",
             )),
     ]
Exemplo n.º 29
0
    def __init__(self, *args, **kwargs):
        super(UserCreationForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_action = ""
        self.helper.form_method = "POST"
        self.helper.form_tag = False
        self.helper.csrf = False

        self.fields['email'].required = True
        self.fields['first_name'].required = True
        self.fields['last_name'].required = True

        self.helper.layout = layout.Layout(
            layout.Div(layout.HTML(
                u"""<div class="panel-heading"><h3 class="panel-title">Researcher data</h3></div>"""
            ),
                       layout.Div(
                           layout.Div(
                               layout.Field("username"),
                               layout.Field("first_name"),
                               layout.Field("password1"),
                               css_class="col-md-6",
                           ),
                           layout.Div(
                               bootstrap.PrependedText(
                                   "email",
                                   "@",
                                   css_class="input-block-level",
                                   placeholder="*****@*****.**"),
                               layout.Field("last_name"),
                               layout.Field("password2"),
                               css_class="col-md-6",
                           ),
                           css_class='row panel-body',
                       ),
                       css_class='panel panel-default'), )
Exemplo n.º 30
0
 def get_ordered_crispy_form_fields(self):
     fields = super(FormRepeaterForm, self).get_ordered_crispy_form_fields()
     fields.append(twbscrispy.PrependedText('include_app_id_param', ''))
     return fields