python类FormHelper()的实例源码

forms.py 文件源码 项目:gwells 作者: bcgov 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def helper(self):
        helper = FormHelper()
        helper.form_id = 'id-searchForm'
        helper.form_method = 'get'
        helper.form_action = ''

        helper.layout = Layout(
            Fieldset(
                '',
                'well',
                'addr',
                'legal',
                'owner',
                # start_lat_long and end_lat_long are programatically generated
                # based on an identifyWells operation on the client.
                Hidden('start_lat_long', ''),
                Hidden('end_lat_long', ''),
            ),
            FormActions(
                Submit('s', 'Search', css_class='formButtons'),
                HTML('<a class="btn btn-default" id="reset-id-s" href="{% url \'search\' %}">Reset</a>'),
                )
        )

        return helper
forms.py 文件源码 项目:gwells 作者: bcgov 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_tag = False
        self.helper.disable_csrf = True
        self.helper.form_show_labels = False
        self.helper.render_required_fields = True
        self.helper.render_hidden_fields = True
        self.helper.layout = Layout(
            HTML('<tr valign="top">'),
            HTML('<td>'),
            'liner_perforation_from',
            HTML('</td>'),
            HTML('<td>'),
            'liner_perforation_to',
            HTML('</td><td width="75">&nbsp;{% if form.instance.pk %}{{ form.DELETE }}{% endif %}</td>'),
            HTML('</tr>'),
        )
        super(LinerPerforationForm, self).__init__(*args, **kwargs)
forms.py 文件源码 项目:gwells 作者: bcgov 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_tag = False
        self.helper.disable_csrf = True
        self.helper.layout = Layout(
            Fieldset(
                'Filter Pack',
                Div(
                    Div(AppendedText('filter_pack_from', 'ft'), css_class='col-md-2'),
                    Div(AppendedText('filter_pack_to', 'ft'), css_class='col-md-2'),
                    Div(AppendedText('filter_pack_thickness', 'in'), css_class='col-md-2'),
                    css_class='row',
                ),
                Div(
                    Div('filter_pack_material', css_class='col-md-3'),
                    Div('filter_pack_material_size', css_class='col-md-3'),
                    css_class='row',
                ),
            )
        )
        super(ActivitySubmissionFilterPackForm, self).__init__(*args, **kwargs)
forms.py 文件源码 项目:gwells 作者: bcgov 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_tag = False
        self.helper.disable_csrf = True
        self.helper.layout = Layout(
            Fieldset(
                'Well Development',
                Div(
                    Div('development_method', css_class='col-md-3'),
                    css_class='row',
                ),
                Div(
                    Div(AppendedText('development_hours', 'hrs'), css_class='col-md-3'),
                    css_class='row',
                ),
                Div(
                    Div('development_notes', css_class='col-md-6'),
                    css_class='row',
                ),
            )
        )
        super(ActivitySubmissionDevelopmentForm, self).__init__(*args, **kwargs)
forms.py 文件源码 项目:gwells 作者: bcgov 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_tag = False
        self.helper.disable_csrf = True
        self.helper.layout = Layout(
            Fieldset(
                'Water Quality',
                Div(
                    Div('water_quality_characteristics', css_class='col-md-3'),
                    css_class='row',
                ),
                Div(
                    Div('water_quality_colour', css_class='col-md-3'),
                    css_class='row',
                ),
                Div(
                    Div('water_quality_odour', css_class='col-md-3'),
                    css_class='row',
                ),
            )
        )

        super(ActivitySubmissionWaterQualityForm, self).__init__(*args, **kwargs)
forms.py 文件源码 项目:gwells 作者: bcgov 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_tag = False
        self.helper.disable_csrf = True
        self.helper.layout = Layout(
            Fieldset(
                'General Comments',
                Div(
                    Div('comments', css_class='col-md-12'),
                    css_class='row',
                ),
                Div(
                    Div('alternative_specs_submitted', css_class='col-md-12'),
                    css_class='row',
                ),
                Div(
                    Div(HTML('<p style="font-style: italic;">Declaration: By submitting this well construction, alteration or decommission report, as the case may be, I declare that it has been done in accordance with the requirements of the Water Sustainability Act and the Groundwater Protection Regulation.</p>'), css_class='col-md-12'),
                    css_class='row',
                ),
            )
        )
        super(ActivitySubmissionCommentForm, self).__init__(*args, **kwargs)
views.py 文件源码 项目:studentsdb 作者: PyDev777 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        super(CustAuthForm, self).__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.form_action = reverse('users:auth_login')
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-sm-3'
        self.helper.field_class = 'col-sm-9'
        self.helper.error_text_inline = False
        self.helper.layout = Layout(
            Hidden('next', value=reverse('home')),
            Fieldset('', 'username', 'password',
                     HTML(u'<strong><a href="%s" class="btn btn-link col-sm-offset-3 modal-link">%s</a></strong>' % (reverse('password_reset'), _(u'Forgot your password?'))),
                     'captcha'),
            ButtonHolder(Submit('submit_button', _(u'Log in')),
                         Button('cancel_button', _(u'Cancel'), css_class='btn-default')))
views.py 文件源码 项目:studentsdb 作者: PyDev777 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        super(CustPswResetForm, self).__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.form_action = reverse('password_reset')
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-md-3'
        self.helper.field_class = 'col-md-9'
        self.helper.error_text_inline = False
        self.helper.add_input(Submit('submit_button', _(u'Confirm')))
        self.helper.add_input(Button('cancel_button', _(u'Cancel'), css_class='btn-default'))

        # self.helper.layout = Layout(
        #     # Hidden('next', value=reverse('home')),
        #     HTML(u"<p>%s</p>" % _(u"Forgot your password? Enter your email in the form below and we'll send you instructions for creating a new one.")),
        #     Fieldset('', 'email', 'captcha'),
        #     ButtonHolder(Submit('submit_button', _(u'Confirm')),
        #                  Button('cancel_button', _(u'Cancel'), css_class='btn-default')))
views.py 文件源码 项目:studentsdb 作者: PyDev777 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        super(CustPswChangeForm, self).__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.form_action = reverse('password_change')
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-md-3'
        self.helper.field_class = 'col-md-9'
        self.helper.error_text_inline = False
        self.helper.add_input(Submit('submit_button', _(u'Confirm')))
        self.helper.add_input(Button('cancel_button', _(u'Cancel'), css_class='btn-default'))


# def custom_activation_complete(request):
#     print 'custom_activation_complete'
#     return render(request, 'registration/activation_complete.html', {})
students.py 文件源码 项目:studentsdb 作者: PyDev777 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        super(StudentAddForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.form_class = 'form-horizontal'
        self.helper.form_method = 'POST'
        self.helper.form_action = reverse('students_add')
        self.helper.help_text_inline = False
        self.helper.label_class = 'col-sm-4'
        self.helper.field_class = 'col-sm-7'
        self.helper.layout = Layout(
            Fieldset('', 'first_name', 'last_name', 'middle_name',
                     AppendedText('birthday', '<span class="glyphicon glyphicon-calendar"></span>'),
                     'photo', 'ticket', 'student_group', 'notes'),
            ButtonHolder(
                Submit('save_button', _(u'Save')),
                Button('cancel_button', _(u'Cancel'), css_class='btn-default')))
views.py 文件源码 项目:flowcelltool 作者: bihealth 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def get_context_data(self, pk, **kwargs):
        context = super().get_context_data(**kwargs)
        self.object = models.BarcodeSet.objects.get(pk=pk)  # noqa
        context['object'] = self.object
        context['formset'] = kwargs['formset']
        context['helper'] = FormHelper()
        context['helper'].form_tag = False
        context['helper'].template = \
            'bootstrap4/table_inline_formset.html'
        return context


# FlowCell Views --------------------------------------------------------------


#: All fields for the flow cell
views.py 文件源码 项目:flowcelltool 作者: bihealth 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def get_context_data(self, pk, **kwargs):
        context = super().get_context_data(**kwargs)
        self.object = models.FlowCell.objects.get(pk=pk)  # noqa
        context['object'] = self.object
        context['formset'] = kwargs['formset']
        context['helper'] = FormHelper()
        context['helper'].layout = Layout(
            Field('name', css_class='form-control-sm'),
            Field('reference', css_class='form-control-sm'),
            Field('barcode_set',
                  css_class='barcode-set-field form-control-sm'),
            Field('barcode', css_class='barcode-field form-control-sm'),
            Field('barcode_set2',
                  css_class='barcode-set-field2 form-control-sm'),
            Field('barcode2', css_class='barcode-field2 form-control-sm'),
            Field('lane_numbers', css_class='form-control-sm'),
        )
        context['helper'].form_tag = False
        context['helper'].template = \
            'bootstrap4/table_inline_formset.html'
        return context
views.py 文件源码 项目:studentsdb2 作者: trivvet 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        super(RegistrationForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)

        # set form tag attributes
        self.helper.action = reverse('registration_register')
        self.helper.form_method = 'POST'
        self.helper.form_class = 'form-horizontal'

        # set form field properties
        self.helper.help_text_inline = True
        self.helper.html5_required = True
        self.helper.attrs = {'novalidate': ''}
        self.helper.label_class = 'col-sm-4 control-label'
        self.helper.field_class = 'col-sm-8'

        # add buttons
        self.helper.layout.append(Layout(
            FormActions(
                Submit('register_button', _(u'Register')),
                Submit('cancel_button', _(u'Cancel'), css_class='btn-link')
            )
        ))
contact_admin.py 文件源码 项目:studentsdb2 作者: trivvet 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        super(ContactForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()

        # set form tag attributes
        self.helper.action = reverse('contact_admin')
        self.helper.form_method = 'POST'
        self.helper.form_class = 'form-horizontal contact-form'

        # set form field properties
        self.helper.help_text_inline = True
        self.helper.html5_required = False
        self.helper.attrs = {'novalidate': ''}
        self.helper.label_class = 'col-sm-2 control-label'
        self.helper.field_class = 'col-sm-10'


        # add buttons
        self.helper.add_input(Submit('send_button', _(u'Submit')))
logs.py 文件源码 项目:studentsdb2 作者: trivvet 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        super(LogUpdateForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)

        # set form tag attributes
        self.helper.action = reverse_lazy('logs_edit', kwargs['instance'].id)
        self.helper.form_method = 'POST'
        self.helper.form_class = 'form-horizontal'

        # set form field properties
        self.helper.help_text_inline = True
        self.helper.html5_required = False
        self.helper.attrs = {'novalidate': ''}
        self.helper.label_class = 'col-sm-3 control-label'
        self.helper.field_class = 'col-sm-9'


        # add buttons
        self.helper.layout.append(Layout(
            FormActions(
                Submit('add_button', _(u'Save')),
                Submit('cancel_button', _(u'Cancel'), css_class='btn-link')
            )
        ))
groups.py 文件源码 项目:studentsdb2 作者: trivvet 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        super(GroupAddForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)

        # set form tag attributes
        self.helper.action = reverse('groups_add')
        self.helper.form_method = 'POST'
        self.helper.form_class = 'form-horizontal'

        # set form field properties
        self.helper.help_text_inline = True
        self.helper.html5_required = True
        self.helper.attrs = {'novalidate': ''}
        self.helper.label_class = 'col-sm-4 control-label'
        self.helper.field_class = 'col-sm-8'

        # add buttons
        self.helper.layout.append(Layout(
            FormActions(
                Submit('add_button', _(u'Add')),
                Submit('cancel_button', _(u'Cancel'), css_class='btn-link')
            )
        ))
forms.py 文件源码 项目:waves-demo 作者: lirmm 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        super(SignupForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.fields["email"].widget.input_type = "email"  # ugly hack
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-md-4 col-xs-4 hidden-sm hidden-xs'
        self.helper.field_class = 'col-md-8 col-xs-12'
        # self.helper.form_show_labels = False
        if 'bootstrap' in settings.CRISPY_TEMPLATE_PACK:
            email_field = PrependedText('email', '@', placeholder="Enter Email", autofocus="")
        else:
            email_field = Field('email', placeholder="Enter Email", autofocus="")
        self.helper.layout = Layout(
            email_field,
            Field('name', placeholder="Enter your full name"),
            Field('password1', placeholder="Enter Password"),
            Field('password2', placeholder="Confirm Password"),
            Field('register_for_api', placeholder="Register for our API access"),
            Field('country', placeholder="Select your country"),
            Field('institution', placeholder="Your institution"),
            Field('phone', placeholder="Phone"),
            Field('comment', placeholder="Any comment ?"),
            Field('tos', ),
            Submit('sign_up', 'Sign up', css_class="btn btn-lg btn-primary btn-block"),
        )
forms.py 文件源码 项目:nav 作者: UNINETT 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        super(ViewForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'custom'
        self.helper.form_action = ''
        self.helper.form_method = 'GET'
        self.helper.layout = Layout(
            Fieldset(
                'Choose statistic',
                Row(
                    Column('view', css_class='medium-5'),
                    Column('timeframe', css_class='medium-3'),
                    Column('rows', css_class='medium-1'),
                    Column(LabelSubmit('submit', 'Show statistics',
                                       css_class='postfix'),
                           css_class='medium-3'),
                )
            )
        )
forms.py 文件源码 项目:nav 作者: UNINETT 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        super(AccountLogSearchForm, self).__init__(*args, **kwargs)
        css_class_large = 'large-4 medium-6'
        css_class_small = 'large-2 medium-6'
        self.helper = FormHelper()
        self.helper.form_action = ''
        self.helper.form_method = 'GET'
        self.helper.form_class = 'custom'
        self.helper.layout = Layout(
            Row(
                Column('query', css_class=css_class_large),
                Column('time', css_class=css_class_large),
                Column('port_type', css_class=css_class_small),
                Column('dns_lookup', css_class=css_class_small),
            ),
            Submit('send', 'Search', css_class='small')
        )
forms.py 文件源码 项目:nav 作者: UNINETT 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwargs):
        super(JustificationForm, self).__init__(*args, **kwargs)

        # Set correct helper text based on if this is an edit or add
        submit_value = 'Add reason'
        fieldset_legend = 'Add detention reason'
        if self.initial.get('justificationid'):
            submit_value = 'Save changes'
            fieldset_legend = 'Edit detention reason'

        # Create helper for crispy layout
        self.helper = FormHelper()
        self.helper.form_action = 'arnold-justificatons'
        self.helper.layout = Layout(
            Fieldset(
                fieldset_legend,
                'name', 'description', 'justificationid'
            ),
            Submit('submit', submit_value, css_class='small')
        )


问题


面经


文章

微信
公众号

扫码关注公众号