Example #1
0
 def __init__(self, *args, **kwargs):
     super(RecordForm3, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.fields['purch_date'].widget = DateInput()
     self.helper.layout = layout.Layout(
         bootstrap.InlineRadios('flow_type'), layout.Field('item'),
         layout.Field('amount'), layout.Field('purch_date'),
         layout.ButtonHolder(
             Submit('submit', '送出', css_class='button white'),
             layout.HTML(
                 "<a href='{% url 'list_record' %}' class='btn btn-warning'>取消</a>"
             )))
Example #2
0
 def __init__(self, *args, **kwargs):
     self.user = kwargs.pop("user")
     is_ajax = kwargs.pop("is_ajax", None)
     action = kwargs.pop("action", None)
     submit_value = kwargs.pop("submit_value", "OK")
     super().__init__(*args, **kwargs)
     self.instance.owner = self.user
     self.helper = FormHelper()
     self.helper.form_id = "bikeForm"
     if action is not None:
         self.helper.form_action = action
     self.helper.layout = layout.Layout(
         layout.Field("nickname"),
         layout.Div(layout.Div(
             layout.Field("bike_type"),
             css_class="col-lg-4",
         ),
                    layout.Div(
                        layout.Field("gear"),
                        css_class="col-lg-4",
                    ),
                    layout.Div(
                        layout.Field("brake"),
                        css_class="col-lg-4",
                    ),
                    layout.Div(
                        layout.Field("brand"),
                        layout.Field("model"),
                        css_class="col-lg-6",
                    ),
                    layout.Div(
                        layout.Field("color"),
                        layout.Field("saddle"),
                        css_class="col-lg-6",
                    ),
                    layout.Div(
                        layout.Fieldset(
                            None,
                            "has_basket",
                            "has_cargo_rack",
                        ),
                        css_class="col-lg-6",
                    ),
                    layout.Div(
                        layout.Fieldset(
                            None,
                            "has_lights",
                            "has_bags",
                        ),
                        css_class="col-lg-6",
                    ),
                    css_class="row"),
         layout.Field("other_details"),
     )
     if not is_ajax:
         self.helper.layout.append(
             bootstrap.FormActions(layout.Submit("submit", submit_value)), )
Example #3
0
 def __init__(self, *args, **kwargs):
     user = kwargs.pop("user")
     bike = kwargs.pop("bike", None)
     is_ajax = kwargs.pop("is_ajax", None)
     action = kwargs.pop("action", None)
     submit_value = _(
         "Report lost bike") if not bike else _("Update bike status")
     super().__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_id = "statusForm"
     if action is not None:
         self.helper.form_action = action
     if is_ajax:
         form_layout = layout.Layout(
             layout.Fieldset(
                 None,
                 "bike",
                 "lost",
                 "details",
                 "position",
             )
         )
     else:
         form_layout = layout.Layout(
             layout.Div(
                 layout.Div(
                     layout.Field("bike"),
                     layout.Field("lost"),
                     layout.Field("details"),
                     css_class="col-lg-3"
                 ),
                 layout.Div(
                     layout.Field("position"),
                     css_class="col-lg-9",
                 ),
                 css_class="row"
             ),
             bootstrap.FormActions(
                 layout.Submit("submit", submit_value)
             ),
         )
     self.helper.layout = form_layout
     if bike is None:  # TODO: show only bikes that are not currently lost
         self.fields["bike"].queryset = models.Bike.objects.filter(
             owner=user)
         self.instance.lost = True
         del self.fields["lost"]
     else:
         current_status = bike.get_current_status()
         self.fields["lost"].initial = current_status.lost
         self.instance.bike = bike
         del self.fields["bike"]
Example #4
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",
                ),
            ),
        )
    def __init__(self, *args, event, submission, is_guest, **kwargs):
        super().__init__(*args, **kwargs)

        self.fields["submission"].initial = submission
        self.fields["event"].initial = event
        self.fields["is_guest"].initial = is_guest

        # si l'événement est dans moins d'une semaine, on refuse le paiement par chèque
        if event.start_time - timezone.now() < timezone.timedelta(days=7):
            self.fields["payment_mode"].payment_modes = ["system_pay"]
            self.fields[
                "payment_mode"].help_text = "Il n'est plus possible de payer en ligne par chèque à moins d'une semaine de l'événement."

        for f in [
                "first_name",
                "last_name",
                "location_address1",
                "location_zip",
                "location_city",
                "location_country",
                "contact_phone",
        ]:
            self.fields[f].required = True
        self.fields["location_address1"].label = "Adresse"
        self.fields["location_address2"].label = False

        fields = ["submission", "event", "is_guest"]

        fields.extend(["first_name", "last_name"])
        fields.extend([
            layout.Field("location_address1", placeholder="Ligne 1"),
            layout.Field("location_address2", placeholder="Ligne 2"),
        ])

        fields.append(
            Row(
                layout.Div("location_zip", css_class="col-md-4"),
                layout.Div("location_city", css_class="col-md-8"),
            ))

        fields.append("location_country")
        fields.append("contact_phone")

        fields.append("payment_mode")

        self.helper = FormHelper()
        self.helper.add_input(
            layout.Submit(
                "valider",
                f"Je paie {floatformat(event.get_price(submission and submission.data)/100, 2)} €",
            ))
        self.helper.layout = layout.Layout(*fields)
Example #6
0
 def __init__(self, *args, **kwargs):
     super(ArticleCreateForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_action = reverse("inventex:article-create")
     self.helper.form_method = "POST"
     self.helper.add_input(Submit('Submit', 'submit'))
     prod_client_layout = layout.Layout(
         layout.Fieldset(
             "Produit et type de client",
             layout.Field('type_client'),
             layout.Field('type_de_produit'),
         ))
     self.helper.layout = prod_client_layout
Example #7
0
    def __init__(self, *args, **kwargs):
        super(BlogInlineEditForm, self).__init__(*args, **kwargs)

        # Todo: Remove when this issue is resolved (and add "type='hidden'" to layout.Field below): https://github.com/maraujop/django-crispy-forms/issues/344
        self.fields['title'].widget = forms.HiddenInput()
        self.fields['text'].widget = forms.HiddenInput()

        self.helper = helper.FormHelper()
        self.helper.form_tag = False
        self.helper.layout = helper.Layout(
            layout.Field('title'),
            layout.Field('text'),
        )
Example #8
0
 def __init__(self, *args, **kwargs):
     super(DataDumpTaskForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_tag = False
     self.helper.label_class = 'col-sm-3'
     self.helper.field_class = 'col-sm-5'
     self.helper.layout = Layout(
         Fieldset("Details", crispy.Field('email'), crispy.Field('task')),
         ButtonHolder(Submit(
             "run",
             "Run",
             css_class='btn-primary',
         )))
Example #9
0
    def __init__(self, *args, **kwargs):
        from corehq.apps.locations.forms import LocationSelectWidget
        from corehq.apps.users.views import get_editable_role_choices
        self.domain = kwargs.pop('domain')
        self.couch_user = kwargs.pop('couch_user')
        super(CommCareUserFilterForm, self).__init__(*args, **kwargs)
        self.fields['location_id'].widget = LocationSelectWidget(self.domain)
        self.fields['location_id'].help_text = ExpandedMobileWorkerFilter.location_search_help

        if is_icds_cas_project(self.domain) and not self.couch_user.is_domain_admin(self.domain):
            roles = get_editable_role_choices(self.domain, self.couch_user, allow_admin_role=True,
                                              use_qualified_id=False)
            self.fields['role_id'].choices = roles
        else:
            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.fields['domains'].choices = [(self.domain, self.domain)]
        if len(DomainPermissionsMirror.mirror_domains(self.domain)) > 0:
            self.fields['domains'].choices = [('all_project_spaces', _('All Project Spaces'))] + \
                                             [(self.domain, self.domain)] + \
                                             [(domain, domain) for domain in
                                              DomainPermissionsMirror.mirror_domains(self.domain)]
        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', css_class="hqwebapp-select2"),
                crispy.Field('search_string'),
                crispy.Field('location_id'),
                crispy.Field('columns'),
                crispy.Field('domains'),
            ),
            hqcrispy.FormActions(
                twbscrispy.StrictButton(
                    _("Download All Users"),
                    type="submit",
                    css_class="btn btn-primary submit_button",
                )
            ),
        )
Example #10
0
    def __init__(self, *args, **kwargs):
        if 'domain' not in kwargs:
            raise Exception('Expected kwargs: domain')
        self.domain = kwargs.pop('domain')

        super(SendRegistrationInvitationsForm, self).__init__(*args, **kwargs)
        self.set_app_id_choices()

        self.helper = HQFormHelper()
        self.helper.layout = crispy.Layout(
            crispy.Div(
                'app_id',
                crispy.Field(
                    'phone_numbers',
                    placeholder=_("Enter phone number(s) in international "
                        "format. Example: +27..., +91...,"),
                ),
                'phone_type',
                InlineField('action'),
                css_class='modal-body',
            ),
            hqcrispy.FieldsetAccordionGroup(
                _("Advanced"),
                crispy.Field(
                    'registration_message_type',
                    data_bind='value: registration_message_type',
                ),
                crispy.Div(
                    crispy.Field(
                        'custom_registration_message',
                        placeholder=_("Enter registration SMS"),
                    ),
                    data_bind='visible: showCustomRegistrationMessage',
                ),
                'make_email_required',
                active=False
            ),
            crispy.Div(
                twbscrispy.StrictButton(
                    _("Cancel"),
                    data_dismiss='modal',
                    css_class="btn btn-default",
                ),
                twbscrispy.StrictButton(
                    _("Send Invitation"),
                    type="submit",
                    css_class="btn btn-primary",
                ),
                css_class='modal-footer',
            ),
        )
Example #11
0
 def __init__(self, *args, **kwargs):
     super(TobuyForm2, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.fields['tobuy_date'].widget = DateInput()
     self.helper.layout = layout.Layout(
         _('待買表單'),
         layout.Field('itemname'),
         layout.Field('budget'),
         layout.Field('tobuy_date'),
         bootstrap.InlineRadios('tobuy_type'),
         # layout.Fieldset(
         # ),
         layout.ButtonHolder(
             Submit('submit', '送出', css_class='button white')))
Example #12
0
    def __init__(self, data, *args, **kwargs):
        self.domain = kwargs.pop('domain')
        kwargs['initial'] = self.initial_data
        super(TableauServerForm, self).__init__(data, *args, **kwargs)

        self.helper = HQFormHelper()
        self.helper.form_method = 'POST'
        self.helper.layout = crispy.Layout(
            crispy.Div(crispy.Field('server_type'), ),
            crispy.Div(crispy.Field('server_name'), ),
            crispy.Div(crispy.Field('validate_hostname'), ),
            crispy.Div(crispy.Field('target_site'), ),
            crispy.Div(crispy.Field('domain_username'), ),
            FormActions(crispy.Submit('submit_btn', 'Submit')))
Example #13
0
    def general_fields(self):
        fields = [
            crispy.Field('name', css_class='input-xxlarge'),
            crispy.Field('display_name', css_class='input-xxlarge'),
            crispy.Field('description', css_class='input-xxlarge', rows="3"),
            crispy.Field('reply_to_phone_number', css_class='input-xxlarge'),
            crispy.Field('opt_out_keywords'),
            crispy.Field('opt_in_keywords')
        ]

        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
Example #14
0
    def __init__(self, domain_object, *args, **kwargs):
        self.domain_object = domain_object
        super(BaseFilterExportDownloadForm, self).__init__(*args, **kwargs)

        if not self.domain_object.uses_locations:
            # don't use CommCare Supply as a user_types choice if the domain
            # is not a CommCare Supply domain.
            self.fields['user_types'].choices = self._USER_TYPES_CHOICES[:-1]

        self.helper = FormHelper()
        self.helper.form_tag = False
        self.helper.label_class = 'col-sm-3'
        self.helper.field_class = 'col-sm-5'
        if not self.skip_layout:
            self.helper.layout = Layout(
                crispy.Field(
                    'type_or_group',
                    ng_model="formData.type_or_group",
                    ng_required='false',
                ),
                crispy.Div(
                    crispy.Field(
                        'user_types',
                        ng_model='formData.user_types',
                        ng_required='false',
                    ),
                    ng_show="formData.type_or_group === 'type'",
                ),
                crispy.Div(
                    B3MultiField(
                        _("Group"),
                        crispy.Div(
                            crispy.Div(
                                InlineField(
                                    'group',
                                    ng_model='formData.group',
                                    ng_required='false',
                                    style="width: 98%",
                                ),
                                ng_show="hasGroups",
                            ),
                        ),
                        CrispyTemplate('export/crispy_html/groups_help.html', {
                            'domain': self.domain_object.name,
                        }),
                    ),
                    ng_show="formData.type_or_group === 'group'",
                ),
                *self.extra_fields
            )
Example #15
0
 def get_field_layout(self):
     return [
         layout.Div(layout.Field('long_name',
                                 placeholder=_('Example: Spring 2025'),
                                 focusonme='focusonme'),
                    layout.Field('short_name',
                                 placeholder=_('Example: spring2025')),
                    layout.Div(layout.Div(layout.Field('start_time'),
                                          css_class='col-sm-6'),
                               layout.Div(layout.Field('end_time'),
                                          css_class='col-sm-6'),
                               css_class='row'),
                    css_class='cradmin-globalfields')
     ]
Example #16
0
    def __init__(self, domain, *args, **kwargs):
        super(SMSRateCalculatorForm, self).__init__(*args, **kwargs)

        backends = SMSBackend.view(
            "sms/backend_by_domain",
            startkey=[domain],
            endkey=[domain, {}],
            reduce=False,
            include_docs=True,
        ).all()
        backends.extend(
            SMSBackend.view(
                'sms/global_backends',
                reduce=False,
                include_docs=True,
            ).all())

        def _get_backend_info(backend):
            try:
                api_id = " (%s)" % get_backend_by_class_name(
                    backend.doc_type).get_api_id()
            except AttributeError:
                api_id = ""
            return backend._id, "%s%s" % (backend.name, api_id)

        backends = [_get_backend_info(g) for g in backends]
        self.fields['gateway'].choices = backends

        self.helper = FormHelper()
        self.helper.form_class = "form-horizontal"
        self.helper.layout = crispy.Layout(
            crispy.Field(
                'gateway',
                data_bind="value: gateway, events: {change: clearSelect2}",
                css_class="input-xxlarge",
            ),
            crispy.Field(
                'direction',
                data_bind="value: direction, "
                "event: {change: clearSelect2}",
            ),
            crispy.Field(
                'country_code',
                css_class="input-xxlarge",
                data_bind="value: select2CountryCode.value, "
                "event: {change: updateRate}",
                placeholder=_("Please Select a Country Code"),
            ),
        )
Example #17
0
 def __init__(self, *args, **kwargs):
     domain = kwargs.pop('domain')
     super(ComposeMessageForm, self).__init__(*args, **kwargs)
     self.helper = HQFormHelper()
     self.helper.form_action = reverse('send_to_recipients', args=[domain])
     self.helper.layout = crispy.Layout(
         crispy.Field('recipients', rows=2, css_class='sms-typeahead'),
         crispy.Field('message', rows=2),
         hqcrispy.FormActions(
             twbscrispy.StrictButton(
                 _("Send Message"),
                 type="submit",
                 css_class="btn-primary",
             ), ),
     )
Example #18
0
    def __init__(self, *args, **kwargs):
        super(BulletinFilterForm, self).__init__(*args, **kwargs)

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

        self.helper.layout = layout.Layout(
            layout.Fieldset(
                _("Filter bulletins"),
                layout.Field("bulletin_type"),
                layout.Field("category"),
            ),
            bootstrap.FormActions(layout.Submit("submit", _("Filter")), ),
        )
Example #19
0
 def __init__(self, request, domain, *args, **kwargs):
     self.domain = domain
     super(DataManagementForm, self).__init__(*args, **kwargs)
     self.helper = HQFormHelper()
     self.helper.layout = crispy.Layout(
         crispy.Field('slug'),
         crispy.Field('db_alias'),
         crispy.Field('start_date', css_class="date-picker"),
         crispy.Field('end_date', css_class="date-picker"),
         hqcrispy.FormActions(
             crispy.ButtonHolder(
                 Submit('submit', ugettext_lazy("Submit"))
             )
         )
     )
Example #20
0
    def crispy_init(self):  # pragma: no cover
        """Initialize crispy-forms helper."""
        self.helper = FormHelper()
        self.helper.form_id = 'id-RegistrationForm'
        self.helper.form_class = 'form-group'
        self.helper.form_method = 'post'
        self.helper.form_action = reverse('blog_admin:register')

        self.helper.layout = layout.Layout(
            layout.Field('username'), layout.Field('email'),
            layout.Field('password1'), layout.Field('password2'),
            layout.Div(layout.Submit('submit',
                                     'Register',
                                     css_class='btn-success my-2 px-4'),
                       css_class='text-center'))
Example #21
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = HQFormHelper()
        self.helper.layout = Layout(
            crispy.Fieldset(
                ugettext_lazy("Add New API Key"),
                crispy.Field('name'),
                crispy.Field('ip_allowlist'),
            ),
            hqcrispy.FormActions(
                StrictButton(mark_safe('<i class="fa fa-plus"></i> {}'.format(
                    ugettext_lazy("Generate New API Key"))),
                             css_class='btn btn-primary',
                             type='submit')))
Example #22
0
 def __int__(self, *args, **kwargs):
     super(ProductForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_action = ""
     self.helper.form_method = "POST"
     self.helper.layout = layout.Layout(
         layout.Field('category_name'),
         layout.Field(
             "categories",
             template='utils/checkbox_select_multiple_tree.html'
         ),
         bootstrap.FormActions(
             layout.Submit('submit', _('Save'))
         )
     )
Example #23
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")))))
Example #24
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"))
            )
        )
Example #25
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")))))
Example #26
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")))))
Example #27
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"))
                )
            )
        )
Example #28
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'),
            ),
        )
Example #29
0
 def extra_fields(self):
     return [
         crispy.Field(
             'date_range',
             data_bind='value: dateRange',
         ),
     ]
Example #30
0
    def __init__(self, *args, **kwargs):
        self.emw_settings = kwargs.pop('emw_settings', None)
        self.domain = kwargs.pop('domain', None)
        kwargs['initial'] = {
            "enable_auto_deactivation":
            self.emw_settings.enable_auto_deactivation,
            "inactivity_period":
            self.emw_settings.inactivity_period,
            "allow_custom_deactivation":
            self.emw_settings.allow_custom_deactivation,
        }

        super().__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.form_id = 'emw-settings-form'
        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(
                _("Manage Mobile Workers"),
                PrependedText('enable_auto_deactivation', ''),
                crispy.Div(crispy.Field('inactivity_period'), ),
                PrependedText('allow_custom_deactivation', ''),
            ),
            hqcrispy.FormActions(
                StrictButton(
                    _("Update Settings"),
                    type="submit",
                    css_class='btn-primary',
                )))