def _build_fields(self, steps):
     fields = []
     if steps.prev:
         if steps.prev == steps.first:
             first_step = ProperButton('wizard_goto_step',
                                       steps.first,
                                       'Previous',
                                       input_type='submit',
                                       css_class='btn')
             fields.append(first_step)
         else:
             first_step = ProperButton('wizard_goto_step',
                                       steps.first,
                                       'First',
                                       input_type='submit',
                                       css_class='btn')
             previous_step = ProperButton('wizard_goto_step',
                                          steps.prev,
                                          'Previous',
                                          input_type='submit',
                                          css_class='btn')
             fields.extend([first_step, previous_step])
     if steps.current == steps.last:
         finish = layout.Submit('submit',
                                'Finish',
                                css_class='btn btn-primary')
         fields.append(finish)
     else:
         next_step = layout.Submit('submit',
                                   'Next',
                                   css_class='btn btn-primary')
         fields.append(next_step)
     return fields
Beispiel #2
0
 def default_bootstrap_layout(self, form, actions=None):
     actions = [] if actions is None else actions
     form_fields = []
     small_fields = (forms.ChoiceField, forms.IntegerField,
                     forms.DateTimeField)
     for name, field in form.fields.items():
         attrs = {}
         if isinstance(field, small_fields):
             attrs['field_class'] = 'col-lg-2 col-md-3 col-xs-4'
         if isinstance(field.widget, forms.widgets.MultiWidget):
             form_fields.append(
                 CrispyMultiWidgetField(name, wrapper_class='multifield'))
         else:
             form_fields.append(CrispyField(name, **attrs))
     form_layout = layout.Layout(*form_fields)
     form_actions = []
     for action in actions:
         if action['type'] == 'submit':
             args = {}
             if 'class' in action:
                 args['css_class'] = 'btn-{0}'.format(action['class'])
             form_actions.append(
                 layout.Submit(action['name'], action['value'], **args))
         if action['type'] == 'reset':
             args = {}
             if 'class' in action:
                 args['css_class'] = 'btn-{0}'.format(action['class'])
             form_actions.append(
                 layout.Reset(action['name'], action['value'], **args))
     if not actions:
         form_actions.append(layout.Submit('submit', 'Submit'))
     form_layout.append(bootstrap.FormActions(*form_actions))
     return form_layout
Beispiel #3
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = cfh.FormHelper()
     self.helper.form_id = 'SearchByRoomForm'
     self.helper.form_method = 'post'
     self.helper.add_input(cfl.Submit('submit_room', '1. Räume finden'))
     self.helper.add_input(
         cfl.Submit('submit_visitgroup', '2. Kontaktgruppen finden'))
     self.helper.add_input(
         cfl.Submit('submit_xlsx', '3. Kontaktgruppen-Excel herunterladen'))
Beispiel #4
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',
                )))
    def init_helper(self):
        # Put required HTML attribute on required fields so they are managed by
        # Abide (if enabled)
        if "data_abide" in self.attrs:
            for field_name, field in self.fields.items():
                if hasattr(self, 'instance'):
                    field_value = getattr(self.instance, field_name, None)
                else:
                    field_value = None
                if field.required \
                    and not ((isinstance(field, FileField) or
                              isinstance(field, ImageField))
                             and field_value):
                    field.widget.attrs["required"] = ""
                    field.abide_msg = _("This field is required.")

        if not self.layout:
            # Start with an empty layout
            self.helper = FormHelper(self)
        else:
            # Start from the given layout
            self.helper = FormHelper()
            self.helper.layout = deepcopy(self.layout)

        # Try to reverse form_action url, else fallback to use it as a simple
        # string
        try:
            self.helper.form_action = reverse(self.action)
        except NoReverseMatch:
            self.helper.form_action = self.action

        if self.title:
            html = crispy_forms_layout.HTML(self.title_templatestring.format(self.title))
            self.helper.layout.insert(0, html)

        if self.form_id is not None:
            self.helper.form_id = self.form_id

        self.helper.form_class = self.classes
        self.helper.form_method = self.method
        self.helper.form_error_title = self.error_title
        self.helper.attrs = self.attrs

        if self.submit:
            if isinstance(self.submit, crispy_forms_layout.Submit):
                self.helper.add_input(self.submit)
            elif isinstance(self.submit, str):
                self.helper.add_input(crispy_forms_layout.Submit('submit', self.submit))
            else:
                self.helper.add_input(crispy_forms_layout.Submit('submit', _("Submit")))
Beispiel #6
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
Beispiel #7
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = HQFormHelper()
        self.helper.form_method = 'get'
        self.helper.layout = crispy.Layout(
            'csv_domain_list', FormActions(crispy.Submit('', 'Check Domains')))
Beispiel #8
0
    def __init__(self, *args, **kwargs):
        photographer = kwargs.pop('photographer')
        session = kwargs.pop('session')

        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(
                'Creación de solicitud de imágenes',
                'image_quantity',
                'preview_size',
            ),
            bootstrap.FormActions(
                layout.Submit('submit_button',
                              'Crear solicitud',
                              css_id='form-submit-button'), ),
        )

        assert isinstance(photographer, LuminaUser)
        assert photographer.is_photographer()

        assert isinstance(session, models.Session)

        self.instance.session = session

        self.fields[
            'preview_size'].queryset = models.PreviewSize.objects.for_photographer_ordered(
                photographer)
Beispiel #9
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
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = "donation-form"
        self.helper.add_input(layout.Submit("valider", self.button_label))

        self.helper.layout = Layout()
Beispiel #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": "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
Beispiel #12
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
Beispiel #13
0
    def __init__(self, initial, **kwargs):
        self.user = initial.pop('user')
        super(DisableUserForm, self).__init__(initial=initial, **kwargs)
        self.helper = FormHelper()

        self.helper.form_method = 'POST'
        self.helper.form_class = 'form-horizontal'
        self.helper.form_action = '#'

        self.helper.label_class = 'col-sm-3 col-md-2'
        self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6'

        action = _("Disable") if self.user.is_active else _("Enable")
        css_class = 'btn-danger' if self.user.is_active else 'btn-primary'
        self.helper.layout = crispy.Layout(
            crispy.Field('reason'),
            crispy.Field('reset_password'),
            hqcrispy.FormActions(
                crispy.Submit(
                    "submit",
                    action,
                    css_class="btn %s" % css_class,
                ),
                css_class='modal-footer',
            ),
        )
Beispiel #14
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) not in [forms.CheckboxInput, forms.CheckboxSelectMultiple]:
                widget.attrs['class'] = 'span12'

        helper = BaseFormHelper(self)

        helper.form_method = "GET"
        helper.form_class = None

        helper.add_fluid_row('studies', 4, "span3")
        helper.add_fluid_row('species', 4, "span3")
        helper.add_fluid_row('name', 4, "span3")
        helper.add_fluid_row('tags', 4, "span3")

        helper.layout.append(
            cfb.FormActions(
                cfl.Submit('submit', 'Apply filters'),
            )
        )

        return helper
Beispiel #15
0
	def __init__(self, *args, **kwargs):
		super().__init__(*args, **kwargs)
		self.helper = FormHelper()
		self.helper.form_action = ""
		self.helper.form_method = "POST"
		self.helper.form_show_labels = False		
		self.helper.form_class = 'form-horizontal'
		self.fields['address_st1'].help_text = "Street Line 1"
		self.fields['address_st2'].help_text = "Street Line 2"
		self.fields['address_city'].help_text = "City"
		self.fields['address_state'].help_text = "State"
		self.fields['address_zip'].help_text = "Zip Code"
		self.helper.layout = layout.Layout(
			layout.Fieldset(
				_("Mailing Address"),
				layout.Row(
					layout.Column("address_st1",css_class='form-group col-12 mb-0'),
					css_class='form-row'
				),
				layout.Row(
					layout.Column("address_st2",css_class='form-group col-12 mb-0'),
					css_class='form-row'
				),			
				layout.Row(
					layout.Column("address_city",css_class='form-group col-6 mb-0'),
					layout.Column("address_state",css_class='form-group col-4 mb-0'),
					layout.Column("address_zip",css_class='form-group col-2 mb-0'),
					css_class='form-row'
				),		
			),
			layout.ButtonHolder(
				layout.Submit('submit', _('Unsubscribe')),
				css_class='col-12'
			)				
		)
    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'
Beispiel #17
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"), ))
Beispiel #18
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"), )
Beispiel #19
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"), )
Beispiel #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": "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
Beispiel #21
0
 def __init__(self, use_domain_field, *args, **kwargs):
     super(ProBonoForm, self).__init__(*args, **kwargs)
     if not use_domain_field:
         self.fields['domain'].required = False
     self.helper = FormHelper()
     self.helper.form_class = 'form form-horizontal'
     self.helper.layout = crispy.Layout(
         crispy.Fieldset(
             _('Pro-Bono Application'),
             'contact_email',
             'organization',
             crispy.Div(
                 'domain',
                 style=('' if use_domain_field else 'display:none'),
             ),
             'project_overview',
             'pay_only_features_needed',
             'duration_of_project',
             'num_expected_users',
             'dimagi_contact',
         ),
         FormActions(
             crispy.ButtonHolder(
                 crispy.Submit('submit_pro_bono',
                               _('Submit Pro-Bono Application')))),
     )
Beispiel #22
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"), )
Beispiel #23
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),
        )
Beispiel #24
0
    def __init__(self, *args, **kwargs):
        super(TagNewForm, self).__init__(*args, **kwargs)

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

        self.helper.layout = layout.Layout(
            # layout.Fieldset(
            #     _("Main data"),
            #     layout.Field("hashtag_text", css_class="input-block-level"),
            # ),
            layout.Field("hashtag_text", css_class="input-block-level"),
            bootstrap.FormActions(layout.Submit('submit', _('Save')), ))


# class TagNewProcessForm(forms.Form):
#     politician = forms.ModelChoiceField
#     new_tag = forms.CharField(
#         label=_("New Tag Label"),
#         queryset=Tag.object.all(),
#         required=True,
#     )
#
#     def __init__(self, request, *args, **kwargs):
#         super(TagNewProcessForm, self).__init__(*args, **kwargs)
#         self.request = request
#         self.fields['new_tag'].queryset = self.fields['new_tag'].queryset.exclude()
Beispiel #25
0
    def __init__(self, initial, **kwargs):
        self.username = initial.pop('username')
        super(DisableTwoFactorForm, self).__init__(initial=initial, **kwargs)
        self.helper = FormHelper()

        self.helper.form_method = 'POST'
        self.helper.form_class = 'form-horizontal'
        self.helper.form_action = '#'

        self.helper.label_class = 'col-sm-3 col-md-2'
        self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6'

        self.helper.layout = crispy.Layout(
            crispy.Fieldset(
                _("Basic Information"),
                crispy.Field('username'),
                crispy.Field('verification_mode'),
                crispy.Field('via_who'),
                crispy.Field('disable_for_days'),
            ),
            hqcrispy.FormActions(
                crispy.Submit(
                    "disable",
                    _("Disable"),
                    css_class="btn btn-danger",
                ),
                css_class='modal-footer',
            ),
        )
Beispiel #26
0
    def __init__(self, user, *args, **kwargs):
        super(NotificationSettingsForm, self).__init__(*args, **kwargs)
        self.user = user

        self.helper = FormHelper()
        self.helper.add_input(layout.Submit("notification_subscription_submit", _("Submit")))
        self.helper.form_show_labels = True

        unsubscribed_from = UnsubscribedChannel.objects.filter(user=user).values_list(
            "channel", flat=True
        )

        subscribed_to = []
        choices = []
        for channel in CHANNELS:
            choices.append((channel["key"], channel["name"]))

            if channel["key"] not in unsubscribed_from:
                subscribed_to.append(channel["key"])

        self.fields["subscribed"] = forms.MultipleChoiceField(
            choices=choices,
            initial=subscribed_to,
            widget=forms.CheckboxSelectMultiple,
            required=False,
        )
        self.fields["subscribed"].label = _("Subscribed events")
Beispiel #27
0
class DomicilioFilterFormHelper_OLD(helper.FormHelper):
    form_class = "form form-inline"
    form_id = "domicilio-search-form"
    form_method = "GET"
    form_tag = True
    html5_required = True
    layout = layout.Layout(
        layout.Div(
            layout.Fieldset(
                "<span class='fa fa-search'></span> Búsqueda de Domicilios",
                layout.Div(
                    bootstrap.InlineField("id", wrapper_class="col-2"),
                    bootstrap.InlineField("nombre", wrapper_class="col-8"),
                    bootstrap.InlineField("active", wrapper_class="col-2"),
                    css_class="row",
                ),
                css_class="col-11 border p-3",
            ),
            bootstrap.FormActions(
                layout.Submit("submit", "Filtrar"),
                css_class="col-1 text-right align-self-center",
            ),
            css_class="row",
        )
    )
Beispiel #28
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'))))
Beispiel #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'))))

        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
Beispiel #30
0
    def __init__(self, user=None, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = helper.FormHelper()
        self.helper.form_action = 'image_list'
        self.helper.form_id = 'form-image-search'

        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-lg-2'
        self.helper.field_class = 'col-lg-8'

        assert isinstance(user, LuminaUser)
        assert user.is_photographer()

        self.helper.layout = helper.Layout(
            forms_utils.DatePickerField('fecha_creacion_desde'),
            forms_utils.DatePickerField('fecha_creacion_hasta'),
            'customer',
            'session_type',
            'page',
            bootstrap.FormActions(
                layout.Submit('submit_button',
                              'Buscar',
                              css_id='form-submit-button'), ),
        )
        self.fields['customer'].queryset = Customer.objects.customers_of(user)
        self.fields[
            'session_type'].queryset = SessionType.objects.for_photographer_ordered(
                user)