Example #1
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # # valores iniciales para campos especiales
        # self.fields['comunicaciones'].widget.attrs['size'] = 13
        # self.fields['comunicaciones'].help_text = "Pulse Ctrl para seleccionar varios"

        # self.fields['domicilios'].widget.attrs['size'] = 13
        # self.fields['domicilios'].help_text = "Pulse Ctrl para seleccionar varios"

        # creamos helper
        self.helper = helper.FormHelper()
        self.helper.form_id = "myform"

        # creamos layouts
        self.helper.layout = layout.Layout()

        # agregamos todos los campos
        for fld in self.Meta.fields:
            self.helper.layout.append(fld)

        # agregamos los botones de acción
        bSave = '<button type="submit" class="btn btn-sm btn-primary btn-icon-split mr-1"><span class="icon text-white-50"><i class="fas fa-save"></i></span><span class="text">Grabar</span></button>'
        bCancel = '<a class="btn btn-sm btn-warning btn-icon-split" href="{{request.META.HTTP_REFERER}}"><span class="icon text-white-50"><i class="fas fa-undo"></i></span><span class="text text-dark">Cancela</span></a>'
        self.helper.layout.append(layout.HTML("<hr>"))
        self.helper.layout.append(layout.HTML(bSave))
        self.helper.layout.append(layout.HTML(bCancel))
Example #2
0
    def setHelper(self):

        # by default take-up the whole row-fluid
        for fld in list(self.fields.keys()):
            widget = self.fields[fld].widget
            if type(widget) != forms.CheckboxInput:
                widget.attrs['class'] = 'span12'

        inputs = {"legend_text": "HAWC login"}

        helper = BaseFormHelper(self, **inputs)
        helper.form_class = "loginForm"

        helper.layout.append(
            cfb.FormActions(
                cfl.Submit('login', 'Login'),
                cfl.HTML(
                    """<a role="button" class="btn btn-default" href="{}">Cancel</a>"""
                    .format(reverse('home'))), cfl.HTML("""<br><br>"""),
                cfl.HTML(
                    """<a href="{0}">Forgot your password?</a><br>""".format(
                        reverse('user:reset_password'))),
                cfl.HTML("""<a href="{0}">Create an account</a><br>""".format(
                    reverse('user:new')))))

        return helper
Example #3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # valores iniciales para campos especiales
        self.fields['comercial'].queryset = Comercial.objects.all().order_by(
            'persona__nombre')
        self.fields['actividad'].queryset = Actividad.objects.filter(
            parent__isnull=True).order_by('nombre')
        self.fields['actividades'].queryset = Actividad.objects.filter(
            parent__isnull=False).order_by('nombre')

        # self.fields['comercial'].queryset = None
        # self.fields['actividad'].queryset = None
        # self.fields['actividades'].queryset = None

        self.fields['actividades'].widget.attrs['size'] = 13
        self.fields[
            'actividades'].help_text = "Pulse Ctrl para seleccionar varios"

        # creamos helper
        self.helper = helper.FormHelper()
        self.helper.form_id = "myform"

        # creamos layouts personalizado
        self.helper.layout = layout.Layout(
            layout.Row(
                layout.Column('nombre', css_class='col-lg-5 col-md-4 mb-0'),
                layout.Column('razon_social',
                              css_class='col-lg-5 col-md-4 mb-0'),
                layout.Column('cuit',
                              css_class='col-lg-2 col-md-4 mb-0',
                              onkeypress="buscar_cliente(event)"),
            ),
            layout.Row(
                layout.Column('actividad', css_class='col-lg-4 col-md-4 mb-0'),
                layout.Column('comercial', css_class='col-lg-3 col-md-4 mb-0'),
                layout.Column('calificacion',
                              css_class='col-lg-3 col-md-4 mb-0'),
                layout.Column('referencia_id',
                              css_class='col-lg-2 col-md-12 mb-0'),
            ),
            layout.Row(
                layout.Column('actividades',
                              css_class='col-lg-5 col-md-6 mb-0'),
                layout.Column('observacion',
                              css_class='col-lg-7 col-md-6 mb-0'),
            ),
            'active',
        )

        # self.helper.layout = layout.Layout(
        #     layout.Field('cuit', onkeypress="buscar_cliente(event)")
        # )

        # agregamos los botones de acción
        bSave = '<button type="submit" class="btn btn-sm btn-primary btn-icon-split mr-1"><span class="icon text-white-50"><i class="fas fa-save"></i></span><span class="text">Grabar</span></button>'
        bCancel = '<a class="btn btn-sm btn-warning btn-icon-split" href="{{request.META.HTTP_REFERER}}"><span class="icon text-white-50"><i class="fas fa-undo"></i></span><span class="text text-dark">Cancela</span></a>'
        self.helper.layout.append(layout.HTML("<hr>"))
        self.helper.layout.append(layout.HTML(bSave))
        self.helper.layout.append(layout.HTML(bCancel))
Example #4
0
 def __init__(self, *args, **kwargs):
     super(UpdateNameForm, self).__init__(*args, **kwargs)
     self.helper = helper.FormHelper(self)
     self.helper.form_show_labels = False
     self.helper.form_tag = False
     self.helper.layout = layout.Layout(
         layout.Div(
             layout.Div(
                 layout.Div(
                     layout.HTML(
                         fieldtostring(True,
                                       "required",
                                       "autofocus",
                                       type="text",
                                       name="first_name",
                                       value="",
                                       css_class="form-control")),
                     layout.HTML(valuetolabel("first_name", "First Name")),
                     css_class="md-form",
                 ), ),
             layout.Div(
                 layout.Div(
                     layout.HTML(
                         fieldtostring(True,
                                       "required",
                                       type="text",
                                       name="last_name",
                                       value="",
                                       css_class="form-control")),
                     layout.HTML(valuetolabel("last_name", "Last Name")),
                     css_class="md-form",
                 ), ),
         ))
Example #5
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # valores iniciales para campos especiales
        self.fields['comercial'].queryset = Comercial.objects.all().order_by('persona__nombre')
        self.fields['actividad'].queryset = Actividad.objects.filter(parent__isnull=True).order_by('nombre')

        # creamos helper
        self.helper = helper.FormHelper()
        self.helper.form_id = "myform"

        # creamos layouts personalizado
        self.helper.layout = layout.Layout(
            layout.Row(
                layout.Column('nombre', css_class='col-lg-6 col-md-12 mb-0'),
                layout.Column('razon_social'),
            ),
            layout.Row(
                layout.Column('cuit', css_class='col-lg-3 col-md-3 col-sm-6 mb-0'),
                layout.Column('comercial'),
                layout.Column('referencia_id', css_class='col-lg-3 col-md-3 col-sm-3 mb-0'),
            ),
            layout.Row(
                layout.Column('actividad', css_class='col-lg-6 col-md-12 mb-0'),
                layout.Column('actividades'),
            ),
            'observacion',
        )

        # agregamos los botones de acción
        bSave = '<button type="submit" class="btn btn-primary btn-icon-split"><span class="icon text-white-50"><i class="fas fa-save"></i></span><span class="text">Grabar</span></button>'
        bCancel = '<a class="btn btn-warning btn-icon-split" style="margin-left: 5px" href="{{request.META.HTTP_REFERER}}"><span class="icon text-white-50"><i class="fas fa-undo"></i></span><span class="text">Cancela</span></a>'
        self.helper.layout.append(layout.HTML("<hr>"))
        self.helper.layout.append(layout.HTML(bSave))
        self.helper.layout.append(layout.HTML(bCancel))
Example #6
0
    def __init__(self, *args, **kwargs):
        assert self.FORM_TITLE is not None
        assert self.SUBMIT_LABEL is not None
        assert self.FIELDS

        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'

        fields = [
            self._get_crispy_form_field(field_name)
            for field_name in self.FIELDS
        ]

        form_actions = (
            layout.Submit('submit_button',
                          self.SUBMIT_LABEL,
                          css_id='form-submit-button'),
            layout.HTML(
                "<a class='btn btn-primary' href='{}'>Cancelar</a>".format(
                    self.get_cancel_url())),
        )

        if self.HELP_LINK:
            form_actions += (layout.HTML("""
                    <span style="padding-left: 1em;"><a href="{0}" target="_blank"><i
                        class="fa fa-life-ring"></i> Ayuda</a></span>
                """.format(self.HELP_LINK)), )

        self.helper.layout = helper.Layout(
            layout.Fieldset(self.FORM_TITLE, *fields),
            bootstrap.FormActions(*form_actions),
        )
Example #7
0
    def setHelper(self):

        # by default take-up the whole row-fluid
        for fld in list(self.fields.keys()):
            widget = self.fields[fld].widget
            if type(widget) != forms.CheckboxInput:
                widget.attrs['class'] = 'span12'

        inputs = {"legend_text": "Create an account"}

        helper = BaseFormHelper(self, **inputs)
        helper.form_class = "loginForm"

        helper.layout.extend([
            cfl.HTML(
                '''<a class="btn btn-small" href="#license_modal" data-toggle="modal">View License</a>'''
            ),
            cfb.FormActions(
                cfl.Submit('login', 'Create account'),
                cfl.HTML(
                    """<a role="button" class="btn btn-default" href="{}">Cancel</a>"""
                    .format(reverse('user:login'))),
            )
        ])

        return helper
Example #8
0
    def __init__(self, *args, **kwargs):
        super(CrispyFormMixin, self).__init__(*args, **kwargs)

        self.helper = FormHelper(self)

        # Allow forms to easily override the form_tag
        self.helper.form_tag = self.form_tag

        # Wrap the whole form in a fieldset, if wrap_fieldset is specified
        if self.wrap_fieldset_title:
            fieldset_kwargs = [self.wrap_fieldset_title]
            fieldset_kwargs.extend(self.fields.keys())
            self.helper.layout = layout.Layout(
                layout.Fieldset(*fieldset_kwargs)
            )

        if self.submit_name:
            self.helper.layout.append(self.get_submit_button())

        if self.top_html:
            self.helper.layout.insert(0, layout.HTML(
                                        self.top_html % self.top_html_dict))

        if self.bottom_html:
            self.helper.layout.append(layout.HTML(
                                    self.bottom_html % self.bottom_html_dict))

        if self.labels_as_placeholders:
            self.labels_to_placeholders()
Example #9
0
    def __init__(self,
                 user_name: str = None,
                 post: artisan_models.Post = None,
                 *args,
                 **kwargs) -> None:
        super().__init__(user_name=user_name, post=post, *args, **kwargs)
        checked_string = ''
        if post and user_name and post.subscribed_users.filter(
                username=user_name).count():
            checked_string = 'checked'
        checkbox_string = '<input type="checkbox" id="subscribe_cb" name="subscribe" value="Subscribe" ' + \
            checked_string + '> \
                              <label for="subscribe_cb" class="tinfo">Subscribe to this post...</label><br>'

        self.helper.layout = layout.Layout(
            layout.Fieldset(
                'Create your post...',
                bootstrap5.FloatingField('title'),
                layout.Field('text', css_class="mb-3 post-create-form-text"),
                layout.HTML(
                    "<div class='font-italic mb-3 tinfo'>Maximum of 2000 characters.  Click on word count to see how many characters you have used...</div>"
                ),
                layout.Div(layout.Field('category', css_class="col-auto")
                           if conf.settings.SHOW_CATEGORY else layout.Div(),
                           layout.Field('location', css_class="col-auto")
                           if conf.settings.SHOW_LOCATION else layout.Div(),
                           css_class="col-8 col-sm-4 col-md-4 col-lg-3 tinfo"),
                layout.HTML(checkbox_string),
                layout.Submit('save',
                              'Publish Post',
                              css_class="col-auto mt-3 mb-3"),
            ))
        self.helper.form_action = 'django_artisan:post_create_view'
Example #10
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.form_method = 'get'

        bFilter = '<button type="submit" class="btn btn-sm btn-primary btn-icon-split mr-1"><span class="icon text-white-50"><i class="fas fa-filter"></i></span><span class="text">Filtrar</span></button>'
        bLimpiar = '<a class="btn btn-sm btn-secondary btn-icon-split" href="' + reverse('domicilio:list') + '"><span class="icon text-white-50"><i class="fas fa-undo"></i></span><span class="text">Limpiar</span></a>'

        self.layout = layout.Layout(
            layout.Div(
                layout.Row(
                    layout.Div(
                        layout.Row(
                            layout.Column('nombre', css_class='col-lg-10 col-md-10 col-sm-9 mb-0'),
                            layout.Column('active', css_class='col-lg-2  col-md-2  col-sm-3 mb-0'),
                        ),
                        css_class="col-lg-12 col-md-12 col-sm-12",
                    ),
                    layout.Div(
                        layout.HTML(bFilter),
                        layout.HTML(bLimpiar),
                        css_class="col-12 text-right",
                    ),
                )
            )
        )
Example #11
0
    def setHelper(self):

        # by default take-up the whole row-fluid
        for fld in list(self.fields.keys()):
            widget = self.fields[fld].widget
            if type(widget) != forms.CheckboxInput:
                widget.attrs["class"] = "span12"

        inputs = {"legend_text": "Create an account"}

        helper = BaseFormHelper(self, **inputs)
        helper.form_class = "loginForm"

        login_url = reverse("user:login")
        helper.layout.extend(
            [
                cfl.HTML(
                    '<a class="btn btn-small" href="#license_modal" data-toggle="modal">View License</a>'
                ),
                cfb.FormActions(
                    cfl.Submit("login", "Create account"),
                    cfl.HTML(
                        f'<a role="button" class="btn btn-default" href="{login_url}">Cancel</a>'
                    ),
                ),
            ]
        )

        return helper
Example #12
0
    def build_default_layout(self, form):
        layout = cfl.Layout(*list(form.fields.keys()))

        if self.kwargs.get("legend_text"):
            layout.insert(
                0, cfl.HTML(f"<legend>{self.kwargs.get('legend_text')}</legend>"),
            )

        if "help_text" in self.kwargs:
            layout.insert(
                1, cfl.HTML(f'<p class="help-block">{self.kwargs["help_text"]}</p><br>'),
            )

        if "cancel_url" in self.kwargs:
            self.addCustomFormActions(
                layout,
                [
                    cfl.Submit("save", "Save"),
                    cfl.HTML(
                        f'<a role="button" class="btn btn-default" href="{self.kwargs["cancel_url"]}">Cancel</a>'
                    ),
                ],
            )

        if self.kwargs.get("form_actions"):
            self.addCustomFormActions(layout, self.kwargs.get("form_actions"))

        return layout
Example #13
0
    def build_default_layout(self, form):
        layout = cfl.Layout(*form.fields.keys())

        if self.kwargs.get('legend_text'):
            layout.insert(
                0,
                cfl.HTML(u"<legend>{}</legend>".format(
                    self.kwargs.get('legend_text'))))

        if self.kwargs.get('help_text'):
            layout.insert(
                1,
                cfl.HTML("""<p class="help-block">{}</p><br>""".format(
                    self.kwargs.get('help_text'))))

        if self.kwargs.get('cancel_url'):
            self.addCustomFormActions(layout, [
                cfl.Submit('save', 'Save'),
                cfl.HTML(
                    """<a role="button" class="btn btn-default" href="{}">Cancel</a>"""
                    .format(self.kwargs.get('cancel_url')))
            ])

        if self.kwargs.get('form_actions'):
            self.addCustomFormActions(layout, self.kwargs.get('form_actions'))

        return layout
Example #14
0
    def __init__(self, *args, **kwargs):
        super(DomicilioForm, self).__init__(*args, **kwargs)

        # # dropdown
        # if self.instance.provincia_id:
        #     self.fields['departamento'].queryset = (Departamento.objects.filter(provincia_id=self.instance.provincia_id))
        # if self.instance.departamento_id:
        #     self.fields['localidad'].queryset = (Localidad.objects.filter(departamento_id=self.instance.departamento_id))

        # creamos helper
        self.helper = helper.FormHelper()
        self.helper.form_id = "myform"

        # # creamos layouts
        # self.helper.layout = layout.Layout()

        # # agregamos todos los campos
        # for fld in self.Meta.fields:
        #     self.helper.layout.append(fld)

        campo = '<div class="formColumn col-lg-1 col-md-2 col-sm-6 mb-0"><div id="div_id_hectarea" class="form-group" style="display: none"><label for="id_hectarea" class="col-form-label">Hectareas</label><div class=""><input type="text" name="hectarea" maxlength="2" class="textinput textInput form-control" id="id_hectarea"></div></div></div>'

        # creamos layouts personalizado
        self.helper.layout = layout.Layout(
            layout.Row(
                layout.Column('tipo', css_class='col-lg-4 col-md-6 mb-0'),
                layout.HTML(campo),
            ),
            layout.Row(
                layout.Column('tipo_calle', css_class='col-lg-3 col-md-6 mb-0'),
                layout.Column('nombre',     css_class='col-lg-6 col-md-9 mb-0'),
                layout.Column('numero',     css_class='col-lg-3 col-md-3 mb-0'),
            ),
            layout.Row(
                layout.Column('piso',   css_class='col-lg-4 col-md-4 col-sm-6 mb-0'),
                layout.Column('puerta', css_class='col-lg-4 col-md-4 col-sm-6 mb-0'),
                layout.Column('barrio', css_class='col-lg-4 col-md-4 col-sm-12 mb-0'),
            ),
            layout.Row(                
                layout.Column('provincia',    css_class='col-lg-4 col-md-6  col-sm-12 mb-0'),
                layout.Column('departamento', css_class='col-lg-4 col-md-6  col-sm-12 mb-0'),
                layout.Column('localidad',    css_class='col-lg-4 col-md-12 col-sm-12 mb-0'),
            ),
            layout.Row(                
                layout.Column(layout.Field('provincia_texto',    readonly=True), css_class='col-lg-4 col-md-12 col-sm-12 mb-0'),
                layout.Column(layout.Field('departamento_texto', readonly=True), css_class='col-lg-4 col-md-12 col-sm-12 mb-0'),
                layout.Column(layout.Field('localidad_texto',    readonly=True), css_class='col-lg-4 col-md-12 col-sm-12 mb-0'),
            ),
            'observacion_texto',
            'active',
        )

        # agregamos los botones de acción
        bSave = '<button type="submit" class="btn btn-sm btn-primary btn-icon-split mr-1"><span class="icon text-white-50"><i class="fas fa-save"></i></span><span class="text">Grabar</span></button>'
        bCancel = '<a class="btn btn-sm btn-warning btn-icon-split" href="{{request.META.HTTP_REFERER}}"><span class="icon text-white-50"><i class="fas fa-undo"></i></span><span class="text text-dark">Cancela</span></a>'
        self.helper.layout.append(layout.HTML("<hr>"))
        self.helper.layout.append(layout.HTML(bSave))
        self.helper.layout.append(layout.HTML(bCancel))
Example #15
0
File: forms.py Project: cpy24/pymun
 def __init__(self, *args, **kwargs):
     super(UpdateBirthdayForm, self).__init__(*args, **kwargs)
     self.helper = helper.FormHelper(self)
     self.helper.form_show_labels = False
     self.helper.form_tag = False
     self.helper.layout = layout.Layout(
         layout.Div(
             layout.Div(
                 layout.Div(layout.Div(
                     layout.HTML(
                         selecttostring("required",
                                        name="birthday_month",
                                        id="id_birthday_month",
                                        css_class="form-control md-form")),
                     layout.HTML("""
                             <option value="" disabled selected>Choose your option</option>
                             <option value="1">January</option>
                             <option value="2">February</option>
                             <option value="3" selected>March</option>
                             <option value="4">April</option>
                             <option value="5">May</option>
                             <option value="6">June</option>
                             <option value="7">July</option>
                             <option value="8">August</option>
                             <option value="9">September</option>
                             <option value="10">October</option>
                             <option value="11">November</option>
                             <option value="12">December</option>
                             """ + closeselect()),
                 ),
                            css_class="col"),
                 layout.Div(layout.Div(layout.Div(
                     layout.Div(layout.HTML(
                         fieldtostring(False,
                                       "required",
                                       name="birthday_day",
                                       id="id_birthday_day",
                                       css_class="form-control",
                                       type="number",
                                       placeholder="Day")),
                                css_class="col-5 birthday-change-col-0"),
                     layout.Div(layout.HTML(
                         fieldtostring(False,
                                       "required",
                                       name="birthday_year",
                                       id="id_birthday_year",
                                       css_class="form-control",
                                       type="number",
                                       placeholder="Year")),
                                css_class="col-7 birthday-change-col-0"),
                     css_class="row"),
                                       css_class="md-form"),
                            css_class="col"),
                 css_class="row")))
Example #16
0
    def __init__(self, account, domain, creating_user, data=None, *args, **kwargs):
        super(ConfirmExtraUserChargesForm, self).__init__(account, domain, creating_user, data=data, *args, **kwargs)
        self.fields['confirm_product_agreement'].label = _(
            'I have read and agree to the <a href="%(pa_url)s" target="_blank">'
            'Software Product Subscription Agreement</a>.'
        ) % {'pa_url': reverse('product_agreement')}

        from corehq.apps.users.views.mobile import MobileWorkerListView
        self.helper.label_class = 'col-sm-3 col-md-2'
        self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6'
        self.helper.layout = crispy.Layout(
            crispy.Fieldset(
                _("Basic Information"),
                'company_name',
                'first_name',
                'last_name',
                crispy.Field('email_list', css_class='input-xxlarge ko-email-select2'),
                'phone_number',
            ),
            crispy.Fieldset(
                 _("Mailing Address"),
                'first_line',
                'second_line',
                'city',
                'state_province_region',
                'postal_code',
                crispy.Field('country', css_class="input-large ko-country-select2",
                             data_countryname=COUNTRIES.get(self.current_country, '')),
            ),
            hqcrispy.B3MultiField(
                '',
                crispy.Field('confirm_product_agreement'),
            ),
            hqcrispy.FormActions(
                crispy.HTML(
                    '<a href="%(user_list_url)s" class="btn btn-default">%(text)s</a>' % {
                        'user_list_url': reverse(MobileWorkerListView.urlname, args=[self.domain]),
                        'text': _("Back to Mobile Workers List")
                    }
                ),
                StrictButton(
                    _("Confirm Billing Information"),
                    type="submit",
                    css_class='btn btn-primary disabled',
                    disabled="disabled",
                    css_id="submit-button-pa",
                ),
                crispy.HTML(
                    '<p class="help-inline" id="submit-button-help-qa" style="vertical-align: '
                    'top; margin-top: 5px; margin-bottom: 0px;">%s</p>' % _("Please agree to the Product Subscription "
                                                                            "Agreement above before continuing.")
                ),
            ),
        )
Example #17
0
 def helper(self):
     helper = FormHelper()
     helper.layout = layout.Layout(
         layout.HTML(f'<h2>{self.header}</h2>'),
         layout.HTML(f'<div>{self.message}</div>'),
     )
     for field in self.Meta().fields:
         helper.layout.append(layout.Field(field, wrapper_class='row'))
     helper.layout.append(
         layout.Submit('submit',
                       'Submit your session',
                       css_class='btn-success col-12'))
     helper.label_class = 'col-3'
     helper.field_class = 'col-9'
     return helper
Example #18
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(
                 gettext_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",
         ))
Example #19
0
 def get_form_helper(self):
     helper = FormHelper()
     helper.form_style = 'default'
     helper.form_show_labels = True
     helper.layout = crispy.Layout(
         crispy.Div(
             crispy.Field('id'),
             crispy.Field('column'),
             crispy.Field('data_element_id'),
             crispy.Field('category_option_combo_id'),
             crispy.Field('comment'),
             css_class='modal-body',
         ),
         twbscrispy.FormActions(
             twbscrispy.StrictButton(
                 "Update DataValue Map",
                 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',
         )
     )
     return helper
Example #20
0
    def setHelper(self):

        # by default take-up the whole row-fluid
        for fld in list(self.fields.keys()):
            widget = self.fields[fld].widget
            if type(widget) != forms.CheckboxInput:
                widget.attrs["class"] = "span12"

        inputs = {
            "legend_text": "Password reset",
            "help_text": """
                Enter your email address below, and we'll email instructions
                for setting a new password.
            """,
        }

        helper = BaseFormHelper(self, **inputs)
        helper.form_class = "loginForm"

        helper.layout.append(
            cfb.FormActions(
                cfl.Submit("submit", "Send email confirmation"),
                cfl.HTML(
                    f'<a role="button" class="btn btn-default" href="{reverse("user:login")}">Cancel</a>'
                ),
            )
        )

        return helper
Example #21
0
    def setHelper(self):

        # by default take-up the whole row-fluid
        for fld in list(self.fields.keys()):
            widget = self.fields[fld].widget
            if type(widget) != forms.CheckboxInput:
                widget.attrs["class"] = "span12"

        inputs = {
            "legend_text": "Password reset",
            "help_text": "Enter a new password for your account.",
        }

        helper = BaseFormHelper(self, **inputs)
        helper.form_class = "loginForm"

        cancel_url = reverse("user:login")
        helper.layout.append(
            cfb.FormActions(
                cfl.Submit("submit", "Change password"),
                cfl.HTML(
                    f'<a role="button" class="btn btn-default" href="{cancel_url}">Cancel</a>'
                ),
            )
        )

        return helper
Example #22
0
    def __init__(self, *args, **kwargs):
        super(AddDeliveryService, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-lg-4'
        self.helper.field_class = 'col-lg-7'
        self.helper.form_action = ""
        self.helper.form_method = "POST"

        self.helper.layout = layout.Layout(
            layout.Div(
                layout.HTML(
                    u"""<div class="panel-heading"><h3 class="panel-title">Delivery Form for Service </h3></div>"""
                ),
                layout.Div(
                    layout.Div(
                        layout.Field('deliveryNotes'),
                        css_class="col-md-10",
                    ),
                    layout.Div(
                        bootstrap.FormActions(
                            layout.Reset(('Reset'), _('Reset')),
                            layout.Submit(('submit'),
                                          _('Save'),
                                          style='margin-left: 80px')),
                        #layout.Submit(('submit'),_('Save'), css_class= "col-md-2 offset-md-3")),
                        css_class="col-md-10"),
                    css_class="row panel-body",
                ),
                css_class="panel panel-default"), )
Example #23
0
 def get_layout(self, **kwargs):
     lay = []
     if kwargs['description']:
         lay += [layout.HTML('<p>{}</p>'.format(kwargs['description']))]
     lay += filter(None, [f.get_layout() for f in self.data_fields])
     lay += [Submit(kwargs['action'])]
     return layout.Layout(*lay)
Example #24
0
    def __init__(self, *args, **kwargs):
        super(TimeDelivery, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-lg-4'
        self.helper.field_class = 'col-lg-7'
        self.helper.form_action = ""
        self.helper.form_method = "POST"

        self.helper.layout = layout.Layout(
            layout.Div(layout.HTML(
                u"""<div class="panel-heading"><h3 class="panel-title">Form for getting the delivery time for the requested services</h3></div>"""
            ),
                       layout.Div(
                           layout.Div(
                               layout.Field('start_date'),
                               css_class="col-md-10",
                           ),
                           layout.Div(
                               layout.Field('end_date'),
                               css_class="col-md-10",
                           ),
                           layout.Div(bootstrap.FormActions(
                               layout.Reset(('Reset'), _('Reset')),
                               layout.Submit(('submit'),
                                             _('Submit'),
                                             style='margin-left: 80px')),
                                      css_class="col-md-10"),
                           css_class="row panel-body",
                       ),
                       css_class="panel panel-default"), )
Example #25
0
    def __init__(self, *args, **kwargs):
        super(ProfileCreationForm, 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['profilePosition'].required = True
        self.fields['profileCenter'].required = True
        self.fields['profileArea'].required = True

        self.helper.layout = layout.Layout(
            layout.Div(
                layout.HTML(
                    u"""<div class="panel-heading"><h3 class="panel-title">User data</h3></div>"""
                ),
                layout.Div(
                    layout.Div(
                        layout.Field("profilePosition"),
                        layout.Field("profileCenter"),
                        css_class="col-md-6",
                    ),
                    layout.Div(
                        layout.Field("profileArea"),
                        layout.Field("profileExtension"),
                        css_class="col-md-6",
                    ),
                    css_class='row panel-body',
                ),
                css_class='panel panel-default',
            ), )
Example #26
0
    def setHelper(self):

        # by default take-up the whole row-fluid
        for fld in list(self.fields.keys()):
            widget = self.fields[fld].widget
            if type(widget) != forms.CheckboxInput:
                widget.attrs['class'] = 'span12'

        inputs = {
            "legend_text": "Password reset",
            "help_text": "Enter a new password for your account."
        }

        helper = BaseFormHelper(self, **inputs)
        helper.form_class = "loginForm"

        helper.layout.append(
            cfb.FormActions(
                cfl.Submit('submit', 'Change password'),
                cfl.HTML(
                    """<a role="button" class="btn btn-default" href="{}">Cancel</a>"""
                    .format(reverse('user:login'))),
            ))

        return helper
Example #27
0
    def __init__(self, *args, **kwargs):
        super(ImageForm, self).__init__(*args, **kwargs)

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

        self.helper.layout = layout.Layout(
            layout.Fieldset(
                _("Image form"),
                "title",
                layout.HTML(u"""{% load i18n %}
                    <div id="image_upload_widget">
                        <div class="preview">
                            {% if instance.image %}
                                <img src="{{ MEDIA_URL }}{{ instance.image }}" alt="" />
                            {% endif %}
                        </div>
                        <div class="uploader">
                            <noscript>
                                <p>{% trans "Please enable JavaScript to use file uploader." %}</p>
                            </noscript>
                        </div>
                        <p class="help_text" class="help-block">{% trans "Available formats are JPG, GIF, and PNG." %}</p>
                        <div class="messages"></div>
                    </div>
                """),
                "image_path",
                "delete_image",
            ),
            bootstrap.FormActions(
                layout.Submit('submit', _('Save'),
                              css_class="btn btn-primary"), ))
Example #28
0
    def __init__(self, *args, **kwargs):
        super(ContactForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-lg-5'
        self.helper.field_class = 'col-lg-7'
        self.helper.form_action = ""
        self.helper.form_method = "POST"

        self.helper.layout = layout.Layout(
            layout.Div(layout.HTML(
                u"""<div class="panel-heading"><h3 class="panel-title">Write your email and your request </h3></div>"""
            ),
                       layout.Div(
                           layout.Div(
                               layout.Field('email_contact'),
                               css_class="col-md-10",
                           ),
                           layout.Div(
                               layout.Field('subject'),
                               css_class="col-md-10",
                           ),
                           layout.Div(
                               layout.Field('message'),
                               css_class="col-md-10",
                           ),
                           layout.Div(bootstrap.FormActions(
                               layout.Reset(('Reset'), _('Reset')),
                               layout.Submit(('submit'),
                                             _('Submit'),
                                             style='margin-left: 80px')),
                                      css_class="col-md-10"),
                           css_class="row panel-body",
                       ),
                       css_class="panel panel-default"), )
Example #29
0
    def build_default_layout(self, form):
        layout = cfl.Layout(*form.fields.keys())

        if self.kwargs.get('legend_text'):
            layout.insert(
                0,
                cfl.HTML(u"<legend>{}</legend>".format(
                    self.kwargs.get('legend_text'))))

        if self.kwargs.get('help_text'):
            layout.insert(
                1,
                cfl.HTML("""<p class="help-block">{}</p><br>""".format(
                    self.kwargs.get('help_text'))))

        return layout
Example #30
0
    def __init__(self, *args, **kwargs):
        super(ScheduledReportForm, self).__init__(*args, **kwargs)

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

        domain = kwargs.get('initial', {}).get('domain', None)
        if domain is not None and HOURLY_SCHEDULED_REPORT.enabled(
                domain, NAMESPACE_DOMAIN):
            self.fields['interval'].choices.insert(
                0, ("hourly", gettext("Hourly")))
            self.fields['interval'].widget.choices.insert(
                0, ("hourly", gettext("Hourly")))

        self.helper.add_layout(
            crispy.Layout(
                crispy.Fieldset(
                    gettext("Configure Scheduled Report"), 'config_ids',
                    'interval', 'day', 'hour', 'start_date',
                    crispy.Field(
                        'email_subject',
                        css_class='input-xlarge',
                    ), crispy.Field('send_to_owner'),
                    crispy.Field('attach_excel'), 'recipient_emails',
                    'language',
                    crispy.HTML(
                        render_to_string(
                            'reports/partials/privacy_disclaimer.html'))),
                FormActions(crispy.Submit('submit_btn', 'Submit'))))