コード例 #1
0
ファイル: crispies.py プロジェクト: sveetch/PO-Projects
def project_helper(instance=None, form_tag=True):
    """
    Project form helper
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    fields = [SimpleRowColumn('name', css_class='small-12')]
    if not instance:
        fields.append(SimpleRowColumn('slug', css_class='small-12'))
    fields = fields+[
        SimpleRowColumn('domain', css_class='small-12'),
        SimpleRowColumn('description', css_class='small-12'),
        SimpleRowColumn('po_file', css_class='small-12'),
    ]
    
    helper.layout = Layout(
        Fieldset(
            '',
            *fields,
            css_class='no-legend'
        ),
        ButtonHolderPanel(
            Submit(
                'submit',
                _('Save'),
            ),
            css_class='text-right',
        )
    )
    
    return helper
コード例 #2
0
 def helper(self):
     helper = FormHelper()
     helper.error_text_inline = False
     helper.attrs = {
         'autocomplete': 'off',
         'autocorrect': 'off',
         'autocapitalize': 'off',
         'spellcheck': 'false',
     }
     # .sr-only class is for screen reader only (won't be shown visibly)
     # Refer to http://stackoverflow.com/a/27755704 for more explanation
     helper.label_class = 'sr-only'
     helper.layout = Layout(
         Fieldset(
             '',
             Field('email', placeholder=self.fields['email'].label),
             Field('password1', placeholder=self.fields['password1'].label),
             Field('password2', placeholder=self.fields['password2'].label),
         ),
         FormActions(
             Submit(
                 'save',
                 _('Create Account'),
                 css_class='btn-lg btn-block',
             )))
     return helper
コード例 #3
0
ファイル: crispies.py プロジェクト: sveetch/PO-Projects
def inline_catalog_helper(instance=None, form_tag=True):
    """
    Form helper to create a new catalog
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.form_class = "hide-label"
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    # Build the full layout
    helper.layout = Layout(
        Row(
            Field(
                'locale', 
                placeholder=_("Type a locale like 'fr'"), 
                wrapper_class='small-10 columns'
            ),
            Column(
                Submit(
                    'submit',
                    _('Create'),
                    css_class='postfix',
                ),
                css_class='small-2'
            ),
            css_class='collapse postfix-radius',
        )
    )
    
    return helper
コード例 #4
0
ファイル: forms.py プロジェクト: vihariswamy/pycon.tw
 def helper(self):
     helper = FormHelper()
     helper.error_text_inline = False
     helper.label_class = 'sr-only'
     helper.attrs = {
         'autocomplete': 'off',
         'autocorrect': 'off',
         'autocapitalize': 'off',
         'spellcheck': 'false',
     }
     helper.layout = Layout(
         Fieldset(
             '',
             Field(
                 'new_password1',
                 placeholder=self.fields['new_password1'].label,
             ),
             Field(
                 'new_password2',
                 placeholder=self.fields['new_password2'].label,
             ),
         ),
         FormActions(
             Div(Div(
                 Submit('submit',
                        _('Set Password'),
                        css_class='btn btn-primary btn-block btn-lg'),
                 css_class='col-md-offset-1 col-md-10',
             ),
                 css_class='nesting-form-group row')))
     return helper
コード例 #5
0
def post_delete_helper(form_tag=True):
    """
    Message's delete form layout helper
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    helper.layout = Layout(
        ButtonHolderPanel(
            Row(
                Column(
                    'confirm',
                    css_class='small-12 medium-8'
                ),
                Column(
                    Submit('submit', _('Submit')),
                    css_class='small-12 medium-4 text-right'
                ),
            ),
        ),
    )
    
    return helper
コード例 #6
0
 def helper(self):
     helper = FormHelper()
     helper.error_text_inline = False
     helper.label_class = 'sr-only'
     helper.attrs = {
         'autocomplete': 'off', 'autocorrect': 'off',
         'autocapitalize': 'off', 'spellcheck': 'false',
     }
     helper.layout = Layout(
         Fieldset(
             '',
             Field(
                 'new_password1',
                 placeholder=self.fields['new_password1'].label,
             ),
             Field(
                 'new_password2',
                 placeholder=self.fields['new_password2'].label,
             ),
         ),
         FormActions(Div(
             Div(
                 Submit(
                     'submit', _('Set Password'),
                     css_class='btn btn-primary btn-block btn-lg'
                 ),
                 css_class='col-md-offset-1 col-md-10',
             ),
             css_class='nesting-form-group row'
         ))
     )
     return helper
コード例 #7
0
def note_delete_helper(form_tag=True):
    """
    Note delete form layout helper
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    helper.layout = Layout(
        ButtonHolderPanel(
            Row(
                Column(
                    'confirm',
                    css_class='small-12 medium-8'
                ),
                Column(
                    Submit('submit', _('Submit')),
                    css_class='small-12 medium-4 text-right'
                ),
            ),
        ),
    )
    
    return helper
コード例 #8
0
ファイル: forms.py プロジェクト: waffle-iron/onlineoffline
    def helper(self):
        helper = FormHelper()
        helper.attrs = {
            'action': '/contactlist/api/person/',
            'onsubmit': '{ add }',
            'method': 'POST'
        }
        helper.form_id = "person-form"
        helper.form_class = 'form-horizontal'

        helper.layout = Layout(
            Field('person', rows=1, cols=20),
            Field('email', rows=1, cols=20),
            Field('phone', rows=1, cols=20),
        )

        helper.layout.append(
            ButtonHolder(
                Submit(
                    'submit',
                    'Add',
                    css_class='btn btn-sm btn-default',
                ),
                HTML(
                    "<button class='btn btn-sm btn-default', onclick = '{ person_edit_hide }'>Cancel</button>"
                )))
        return helper
コード例 #9
0
ファイル: crispies.py プロジェクト: sveetch/PO-Projects
def catalog_update_helper(instance=None, form_tag=True):
    """
    Form helper to update a catalog
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    helper.layout = Layout(
        Fieldset(
            '',
            Row(
                Column('locale', css_class='small-12'),
                Column('po_file', css_class='small-12'),
            ),
            css_class='no-legend',
        ),
        ButtonHolderPanel(
            Submit(
                'submit',
                _('Save'),
                css_class='small',
            ),
            css_class='text-right',
        )
    )
    
    return helper
コード例 #10
0
def inline_catalog_helper(instance=None, form_tag=True):
    """
    Form helper to create a new catalog
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.form_class = "hide-label"
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    # Build the full layout
    helper.layout = Layout(
        Row(
            Field(
                'locale', 
                placeholder=_("Type a locale like 'fr'"), 
                wrapper_class='small-10 columns'
            ),
            Column(
                Submit(
                    'submit',
                    _('Create'),
                    css_class='postfix',
                ),
                css_class='small-2'
            ),
            css_class='collapse postfix-radius',
        )
    )
    
    return helper
コード例 #11
0
 def helper(self):
     helper = FormHelper()
     helper.error_text_inline = False
     helper.label_class = 'sr-only'
     helper.attrs = {
         'autocomplete': 'off',
         'autocorrect': 'off',
         'autocapitalize': 'off',
         'spellcheck': 'false',
     }
     helper.layout = Layout(
         Fieldset(
             '',
             Field('username', placeholder=self.fields['username'].label),
             Field('password', placeholder=self.fields['password'].label),
         ),
         FormActions(
             Div(
                 Div(
                     HTML(
                         _('<a class="btn btn-link" href="{password_reset_url}">'
                           'Forgot Password?</a>').format(
                               password_reset_url=reverse(
                                   'password_reset'))),
                     css_class='col-xs-6 m-t-2',
                 ),
                 Div(
                     Submit('save',
                            _('Log In'),
                            css_class='btn-lg btn-block'),
                     css_class='col-xs-6',
                 ),
                 css_class='row',
             )))
     return helper
コード例 #12
0
def project_helper(instance=None, form_tag=True):
    """
    Project form helper
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    fields = [SimpleRowColumn('name', css_class='small-12')]
    if not instance:
        fields.append(SimpleRowColumn('slug', css_class='small-12'))
    fields = fields+[
        SimpleRowColumn('domain', css_class='small-12'),
        SimpleRowColumn('description', css_class='small-12'),
        SimpleRowColumn('po_file', css_class='small-12'),
    ]
    
    helper.layout = Layout(
        Fieldset(
            '',
            *fields,
            css_class='no-legend'
        ),
        ButtonHolderPanel(
            Submit(
                'submit',
                _('Save'),
            ),
            css_class='text-right',
        )
    )
    
    return helper
コード例 #13
0
def catalog_update_helper(instance=None, form_tag=True):
    """
    Form helper to update a catalog
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    helper.layout = Layout(
        Fieldset(
            '',
            Row(
                Column('locale', css_class='small-12'),
                Column('po_file', css_class='small-12'),
            ),
            css_class='no-legend',
        ),
        ButtonHolderPanel(
            Submit(
                'submit',
                _('Save'),
                css_class='small',
            ),
            css_class='text-right',
        )
    )
    
    return helper
コード例 #14
0
ファイル: crispies.py プロジェクト: sveetch/sveedocuments
def insert_helper(form_tag=True, edit_mode=False):
    """
    Insert's form layout helper
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    helper.layout = Layout(
        Fieldset(
            _('Content'),
            'title',
            'content',
        ),
        Fieldset(
            _('Display settings'),
            RowFluid(
                Column('slug', css_class='small-12 medium-9'),
                Column('visible', css_class='small-12 medium-3'),
            ),
        ),
        ButtonHolder(
            Submit('submit_and_continue', _('Save and continue')),
            Submit('submit', _('Save')),
        ),
    )
    
    return helper
コード例 #15
0
 def helper(self):
     helper = FormHelper()
     helper.error_text_inline = False
     helper.label_class = 'sr-only'
     helper.attrs = {
         'autocomplete': 'off', 'autocorrect': 'off',
         'autocapitalize': 'off', 'spellcheck': 'false',
     }
     helper.layout = Layout(
         Fieldset(
             '',
             Field('username', placeholder=self.fields['username'].label),
             Field('password', placeholder=self.fields['password'].label),
         ),
         FormActions(Div(
             Div(
                 HTML(_(
                     '<a class="btn btn-link" href="{password_reset_url}">'
                     'Forgot Password?</a>'
                 ).format(password_reset_url=reverse('password_reset'))),
                 css_class='col-xs-6 m-t-2',
             ),
             Div(
                 Submit('save', _('Log In'), css_class='btn-lg btn-block'),
                 css_class='col-xs-6',
             ),
             css_class='row',
         ))
     )
     return helper
コード例 #16
0
ファイル: forms.py プロジェクト: waffle-iron/onlineoffline
    def helper(self):
        helper = FormHelper()
        helper.attrs = {'action': '/contactlist/api/event/'}
        helper.form_id = "event-form"
        helper.form_class = 'form-horizontal'
        helper.form_action = '{ submit }'

        return helper
コード例 #17
0
ファイル: forms.py プロジェクト: joshbrooks/timordata
    def helper(self):
        helper = FormHelper()
        helper.attrs = {'action': '/nhdb/downloadexcel/'}
        helper.form_id = "excel-download-form"
        helper.form_class = 'form-horizontal'
        helper.label_class = 'col-lg-3'
        helper.field_class = 'col-lg-9'

        return helper
コード例 #18
0
 def helper(self):
     helper = FormHelper()
     prev_url, submit_label = self.prev_url, self.submit_label
     helper.attrs = {"novalidate": True}
     helper.use_custom_control = True
     helper.form_class = "needs-validation"
     helper.layout = Layout("title", "image",
                            get_button_container(submit_label, prev_url))
     return helper
コード例 #19
0
ファイル: forms.py プロジェクト: waffle-iron/onlineoffline
 def helper(self):
     helper = FormHelper()
     helper.attrs = {'action': '/contactlist/api/personevent/'}
     helper.form_id = "personevent-form"
     helper.form_class = 'form-horizontal'
     helper.layout = Layout('person', 'event', 'notice')
     helper.layout.append(
         FormActions(Submit('save', 'Save changes'),
                     Button('cancel', 'Cancel')))
     return helper
コード例 #20
0
ファイル: forms.py プロジェクト: Honoo/CViA
    def __init__(self, *args, **kwargs):
        helper = FormHelper()

        helper.form_action = './'
        helper.form_method = 'POST'
        helper.attrs = {'enctype': 'multipart/form-data'}
        helper.add_input(Submit('submit', 'Upload CV'))

        self.helper = helper
        super(UploadFileForm, self).__init__(*args, **kwargs)
コード例 #21
0
ファイル: tests.py プロジェクト: irumiha/django-crispy-forms
    def test_template_context(self):
        helper = FormHelper()
        helper.attrs = {"id": "test-form", "class": "test-forms", "action": "submit/test/form", "autocomplete": "off"}
        node = CrispyFormNode("form", "helper")
        context = node.get_response_dict(helper, {}, False)

        self.assertEqual(context["form_id"], "test-form")
        self.assertEqual(context["form_attrs"]["id"], "test-form")
        self.assertTrue("test-forms" in context["form_class"])
        self.assertTrue("test-forms" in context["form_attrs"]["class"])
        self.assertEqual(context["form_action"], "submit/test/form")
        self.assertEqual(context["form_attrs"]["action"], "submit/test/form")
        self.assertEqual(context["form_attrs"]["autocomplete"], "off")
コード例 #22
0
ファイル: forms.py プロジェクト: Honoo/CViA
    def __init__(self, *args, **kwargs):
        helper = FormHelper()

        helper.form_action = './'
        helper.form_class = 'form-horizontal'
        helper.form_method = 'POST'
        helper.attrs = {'enctype': 'multipart/form-data'}
        helper.label_class = 'col-lg-2'
        helper.field_class = 'col-lg-10'
        helper.add_input(Submit('submit', 'Submit'))

        self.helper = helper
        super(CVForm, self).__init__(*args, **kwargs)
コード例 #23
0
def test_template_context():
    helper = FormHelper()
    helper.attrs = {"id": "test-form", "class": "test-forms", "action": "submit/test/form", "autocomplete": "off"}
    node = CrispyFormNode("form", "helper")
    context = node.get_response_dict(helper, {}, False)

    assert context["form_id"] == "test-form"
    assert context["form_attrs"]["id"] == "test-form"
    assert "test-forms" in context["form_class"]
    assert "test-forms" in context["form_attrs"]["class"]
    assert context["form_action"] == "submit/test/form"
    assert context["form_attrs"]["action"] == "submit/test/form"
    assert context["form_attrs"]["autocomplete"] == "off"
コード例 #24
0
 def helper(self):
     helper = FormHelper()
     helper.error_text_inline = False
     helper.attrs = {
         'autocomplete': 'off',
         'autocorrect': 'off',
         'autocapitalize': 'off',
         'spellcheck': 'false',
     }
     helper.layout = Layout(
         Fieldset(
             '',
             Field('name', placeholder=self.fields['name'].label),
         ), FormActions(Submit('save', _('Update'), css_class=''), ))
     return helper
コード例 #25
0
ファイル: crispies.py プロジェクト: sveetch/sveedocuments
def page_helper(form_tag=True, parent=None, edit_mode=False):
    """
    Page's form layout helper
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    # Put "parent" field in the layout if it is not forced in kwargs
    layout_fields_publish = [
        RowFluid(
            Column(SplitDateTimeField('published'), css_class='small-12 medium-6'),
            Column('slug', css_class='small-12 medium-6'),
        )
    ]
    if not parent:
        layout_fields_publish = ['parent']+layout_fields_publish
    
    helper.layout = Layout(
        Fieldset(
            _('Content'),
            'title',
            'content',
        ),
        Fieldset(
            _('Display settings'),
            RowFluid(
                Column('template', css_class='small-12 medium-6'),
                Column('order', css_class='small-12 medium-3'),
                Column('visible', css_class='small-12 medium-3'),
            ),
        ),
        Fieldset(
            _('Publish settings'),
            *layout_fields_publish
        ),
        Fieldset(
            _('History'),
            'comment',
        ),
        ButtonHolder(
            Submit('submit_and_continue', _('Save and continue')),
            Submit('submit', _('Save')),
        ),
    )
    
    return helper
コード例 #26
0
def category_helper(form_tag=True):
    """
    Category's form layout helper
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    helper.layout = Layout(
        Row(
            Column(
                'title',
                css_class='small-12'
            ),
        ),
        Row(
            Column(
                'slug',
                css_class='small-12 medium-10'
            ),
            Column(
                'order',
                css_class='small-12 medium-2'
            ),
        ),
        Row(
            Column(
                'description',
                css_class='small-12'
            ),
        ),
        Row(
            Column(
                'visible',
                css_class='small-12'
            ),
        ),
        ButtonHolderPanel(
            Submit('submit', _('Submit')),
            css_class='text-right',
        ),
    )
    
    return helper
コード例 #27
0
def test_template_context():
    helper = FormHelper()
    helper.attrs = {
        "id": "test-form",
        "class": "test-forms",
        "action": "submit/test/form",
        "autocomplete": "off",
    }
    node = CrispyFormNode("form", "helper")
    context = node.get_response_dict(helper, {}, False)

    assert context["form_id"] == "test-form"
    assert context["form_attrs"]["id"] == "test-form"
    assert "test-forms" in context["form_class"]
    assert "test-forms" in context["form_attrs"]["class"]
    assert context["form_action"] == "submit/test/form"
    assert context["form_attrs"]["action"] == "submit/test/form"
    assert context["form_attrs"]["autocomplete"] == "off"
コード例 #28
0
    def test_template_context(self):
        helper = FormHelper()
        helper.attrs = {
            'id': 'test-form',
            'class': 'test-forms',
            'action': 'submit/test/form',
            'autocomplete': 'off',
        }
        node = CrispyFormNode('form', 'helper')
        context = node.get_response_dict(helper, {}, False)

        self.assertEqual(context['form_id'], "test-form")
        self.assertEqual(context['form_attrs']['id'], "test-form")
        self.assertTrue("test-forms" in context['form_class'])
        self.assertTrue("test-forms" in context['form_attrs']['class'])
        self.assertEqual(context['form_action'], "submit/test/form")
        self.assertEqual(context['form_attrs']['action'], "submit/test/form")
        self.assertEqual(context['form_attrs']['autocomplete'], "off")
コード例 #29
0
    def test_template_context(self):
        helper = FormHelper()
        helper.attrs = {
            'id': 'test-form',
            'class': 'test-forms',
            'action': 'submit/test/form',
            'autocomplete': 'off',
        }
        node = CrispyFormNode('form', 'helper')
        context = node.get_response_dict(helper, {}, False)

        self.assertEqual(context['form_id'], "test-form")
        self.assertEqual(context['form_attrs']['id'], "test-form")
        self.assertTrue("test-forms" in context['form_class'])
        self.assertTrue("test-forms" in context['form_attrs']['class'])
        self.assertEqual(context['form_action'], "submit/test/form")
        self.assertEqual(context['form_attrs']['action'], "submit/test/form")
        self.assertEqual(context['form_attrs']['autocomplete'], "off")
コード例 #30
0
def test_template_context():
    helper = FormHelper()
    helper.attrs = {
        'id': 'test-form',
        'class': 'test-forms',
        'action': 'submit/test/form',
        'autocomplete': 'off',
    }
    node = CrispyFormNode('form', 'helper')
    context = node.get_response_dict(helper, {}, False)

    assert context['form_id'] == "test-form"
    assert context['form_attrs']['id'] == "test-form"
    assert "test-forms" in context['form_class']
    assert "test-forms" in context['form_attrs']['class']
    assert context['form_action'] == "submit/test/form"
    assert context['form_attrs']['action'] == "submit/test/form"
    assert context['form_attrs']['autocomplete'] == "off"
コード例 #31
0
 def helper(self):
     helper = FormHelper()
     prev_url, submit_label = self.prev_url, self.submit_label
     helper.attrs = {"novalidate": True}
     helper.use_custom_control = True
     helper.form_class = "needs-validation"
     helper.layout = Layout(
         "title",
         "image",
         Field("country", css_class="custom-select"),
         "order_number",
         "description",
         'free_service',
         "extra_one_year_warranty",
         "show_in_slider",
         get_button_container(submit_label, prev_url),
     )
     return helper
コード例 #32
0
 def helper(self):
     helper = FormHelper()
     helper.error_text_inline = False
     helper.attrs = {
         'autocomplete': 'off', 'autocorrect': 'off',
         'autocapitalize': 'off', 'spellcheck': 'false',
     }
     helper.layout = Layout(
         Fieldset(
             '',
             Field('name', placeholder=self.fields['name'].label),
             Field('auth_number'),
         ),
         FormActions(
             Submit('save', _('Update'), css_class=''),
         )
     )
     return helper
コード例 #33
0
    def get_formhelper(self):
        """
        Get a :class:`crispy_forms.helper.FormHelper`.

        You normally do not need to override this directly. Instead
        you should override:

        - :meth:`.get_field_layout`.
        - :meth:`.get_hidden_fields`
        """
        helper = FormHelper()
        layoutargs = list(self.get_field_layout()) + list(
            self.get_button_layout()) + list(self.get_hidden_fields())
        helper.layout = layout.Layout(*layoutargs)
        helper.form_action = '#'
        form_id = self.get_form_id()
        if form_id:
            helper.form_id = form_id
        helper.attrs = self.get_form_attributes()
        return helper
コード例 #34
0
def entity_delete_helper(form_tag=True, has_notes=False):
    """
    Entity delete form layout helper
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    columns = []
    
    # Show 'move to' field if there are some notes
    if has_notes:
        columns.append(
            Column(
                'move_notecards_to',
                css_class='small-12 medium-8'
            ),
        )
    
    columns.append(
        Column(
            'confirm',
            css_class='small-12 medium-8'
        ),
    )
    
    columns.append(
        Column(
            Submit('submit', _('Submit')),
            css_class='small-12 medium-4 text-right'
        ),
    )
    
    helper.layout = Layout(
        ButtonHolderPanel(
            Row(*columns),
        ),
    )
    
    return helper
コード例 #35
0
def note_helper(form_tag=True):
    """
    Note form layout helper
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    helper.layout = Layout(
        Row(
            Column(
                'title',
                css_class='small-12'
            ),
        ),
        Row(
            Column(
                'content',
                css_class='small-12'
            ),
        ),
        Row(
            Column(
                'file',
                css_class='small-12'
            ),
        ),
        Row(
            Column(
                'tags',
                css_class='small-12'
            ),
        ),
        ButtonHolderPanel(
            Submit('submit', _('Submit')),
            css_class='text-right',
        ),
    )
    
    return helper
コード例 #36
0
ファイル: crispies.py プロジェクト: sveetch/sveedocuments
def attachment_helper(form_tag=True, edit_mode=False):
    """
    Attachment's form layout helper
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    helper.layout = Layout(
        RowFluid(
            Column('title', css_class='small-12 medium-4'),
            Column('slug', css_class='small-12 medium-4'),
            Column('file', css_class='small-12 medium-4'),
        ),
        ButtonHolder(
            Submit('submit', _('Save')),
        ),
    )
    
    return helper
コード例 #37
0
 def helper(self):
     helper = FormHelper()
     helper.error_text_inline = False
     helper.attrs = {
         'autocomplete': 'off', 'autocorrect': 'off',
         'autocapitalize': 'off', 'spellcheck': 'false',
     }
     helper.label_class = 'sr-only'
     helper.layout = Layout(
         Fieldset(
             '',
             Field('email', placeholder=self.fields['email'].label),
             Field('password1', placeholder=self.fields['password1'].label),
             Field('password2', placeholder=self.fields['password2'].label),
         ),
         FormActions(
             Submit(
                 'save', _('Create Account'), css_class='btn-lg btn-block',
             )
         )
     )
     return helper
コード例 #38
0
ファイル: forms.py プロジェクト: adrianliaw/pycontw2016
 def helper(self):
     helper = FormHelper()
     helper.error_text_inline = False
     helper.attrs = {
         'autocomplete': 'off', 'autocorrect': 'off',
         'autocapitalize': 'off', 'spellcheck': 'false',
     }
     helper.label_class = 'sr-only'
     helper.layout = Layout(
         Fieldset(
             '',
             Field('email', placeholder=self.fields['email'].label),
             Field('password1', placeholder=self.fields['password1'].label),
             Field('password2', placeholder=self.fields['password2'].label),
         ),
         FormActions(
             Submit(
                 'save', _('Create Account'), css_class='btn-lg btn-block',
             )
         )
     )
     return helper
コード例 #39
0
def post_helper(form_tag=True, edit_mode=False):
    """
    Post's form layout helper
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    fieldsets = [
        Row(
            Column(
                'text',
                css_class='small-12'
            ),
        ),
    ]
    
    # Threadwatch option is not in edit form
    if not edit_mode:
        fieldsets.append(
            Row(
                Column(
                    'threadwatch',
                    css_class='small-12'
                ),
            ),
        )
    
    fieldsets = fieldsets+[
        ButtonHolderPanel(
            Submit('submit', _('Submit')),
            css_class='text-right',
        ),
    ]
    
    helper.layout = Layout(*fieldsets)
    
    return helper
コード例 #40
0
ファイル: forms.py プロジェクト: Honoo/CViA
    def __init__(self, *args, **kwargs):
        helper = FormHelper()

        helper.form_action = './'
        helper.form_class = 'form-horizontal'
        helper.form_method = 'POST'
        helper.attrs = {'enctype': 'multipart/form-data'}
        helper.label_class = 'col-lg-2'
        helper.field_class = 'col-lg-10'
        helper.layout = Layout(
            "job_title",
            "description",
            "location",
            Div(
                Div("skills", css_class="col-lg-8"),
                Div("skills_weightage", css_class="col-lg-4"),
                css_class="row",
            ),
            Div(
                Div("experience", css_class="col-lg-8"),
                Div("experience_weightage", css_class="col-lg-4"),
                css_class="row",
            ),
            Div(
                Div("education", css_class="col-lg-8"),
                Div("education_weightage", css_class="col-lg-4"),
                css_class="row",
            ),
            Div(
                Div("languages", css_class="col-lg-8"),
                Div("languages_weightage", css_class="col-lg-4"),
                css_class="row",
            ),
        )
        helper.add_input(Submit('submit', 'Submit'))

        self.helper = helper
        super(JobDescriptionForm, self).__init__(*args, **kwargs)
コード例 #41
0
 def helper(self):
     helper = FormHelper()
     prev_url, submit_label = self.prev_url, self.submit_label
     helper.attrs = {"novalidate": True}
     helper.use_custom_control = True
     helper.form_class = "needs-validation"
     helper.layout = Layout(
         "title",
         "image",
         "dry",
         'wet',
         'offroad',
         'comfort',
         "snow",
         'noise',
         'treadware',
         'value',
         Field("brand", css_class="custom-select"),
         "description",
         'extra',
         get_button_container(submit_label, prev_url),
     )
     return helper
コード例 #42
0
ファイル: models.py プロジェクト: Cahersan/django-formulator
    def form_class_factory(self, form_class=forms.Form):
        
        # again make sure that we have everything we need to create a class
        self.full_clean()

        helper = FormHelper()

        attrs = {}
        layouts = []
        
        # Checks for the existance of fields with repeat_min and/or repeat_max 
        # attributes.
        for fieldset in self.fieldsets:
            fieldset_fields = fieldset.fields

            fieldset_layout = layout.Fieldset(fieldset.safe_legend, *[f.field_id for f in fieldset_fields])
            layouts.append(fieldset_layout)

            for field in fieldset_fields:
                attrs[field.field_id] = field.formfield_instance_factory()

        helper.form_id = self.form_id
        helper.form_action = self.form_action
        helper.form_method = self.METHODS[self.form_method]
        helper.attrs = {
            'accept-charset': self.form_accept_charset,
            'autocomplete': self.form_autocomplete,
            'novalidate': self.form_novalidate,
            'enctype': self.form_enctype,
            'target': self.form_target
        }

        helper.layout = layout.Layout(*layouts)

        attrs['helper'] = helper
        return type(str(self.form_id), (form_class,), attrs)
コード例 #43
0
ファイル: crispies.py プロジェクト: sveetch/django-datebook
def notes_helper(form_tag=True):
    """
    Datebook's notes form layout helper
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    # Build the full layout
    helper.layout = Layout(
        SimpleRowColumn('notes', wrapper_class='hide-label'),
        SimpleRowColumn(
            ButtonHolderPanel(
                Submit(
                    'submit',
                    _('Submit'),
                ),
                css_class='text-right',
            ),
        )
    )
    
    return helper
コード例 #44
0
ファイル: crispies.py プロジェクト: sveetch/django-datebook
def year_helper(form_tag=True):
    """
    Datebook's year form layout helper
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.form_class = "hide-label right clearfix"
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    # Build the full layout
    helper.layout = Layout(
        Field(
            'year',
            wrapper_class='left',
        ),
        Submit(
            'submit',
            _('New year'),
            css_class='tiny',
        ),
    )
    
    return helper
コード例 #45
0
ファイル: crispies.py プロジェクト: sveetch/django-datebook
def month_helper(form_tag=True):
    """
    Datebook's month form layout helper
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    # Build the full layout
    helper.layout = Layout(
        Row(
            Column(
                Field('owner'),
                css_class='small-12 medium-7 hide-label'
            ),
            Column(
                Field('period'),
                css_class='small-12 medium-3 hide-label'
            ),
            Column(
                ButtonHolder(
                    Submit(
                        'submit',
                        _('Save'),
                        css_class='tiny expand',
                    ),
                    css_class='text-right',
                ),
                css_class='small-12 medium-2'
            ),
            css_class='collapse',
        ),
    )
    
    return helper
コード例 #46
0
ファイル: forms.py プロジェクト: waffle-iron/onlineoffline
    def helper(self):
        helper = FormHelper()
        helper.attrs = {
            'action': '/contactlist/api/person/{ edit.id }/',
            'onsubmit': '{ submit_edit }',
            'method': 'PUT'
        }
        helper.form_id = "person-edit-form"
        helper.form_class = 'form-horizontal'

        helper.layout = Layout(
            Field('person',
                  id="person_edit_name",
                  value='{ edit.person }',
                  rows=1,
                  cols=20),
            Field('email',
                  id="person_edit_email",
                  value='{ edit.email }',
                  rows=1,
                  cols=20),
            Field('phone',
                  id="person_edit_phone",
                  value='{ edit.phone }',
                  rows=1,
                  cols=20),
        )

        helper.layout.append(
            ButtonHolder(
                Submit('submit', 'Edit', css_class='btn btn-sm btn-default'),
                Button('cancel',
                       'Cancel',
                       css_class='btn btn-sm btn-default',
                       onclick='{ person_edit_hide }')))
        return helper
コード例 #47
0
 def helper(self):
     helper = FormHelper()
     helper.error_text_inline = False
     helper.attrs = {
         'autocomplete': 'off', 'autocorrect': 'off',
         'autocapitalize': 'off', 'spellcheck': 'false',
     }
     # .sr-only class is for screen reader only (won't be shown visibly)
     # Refer to http://stackoverflow.com/a/27755704 for more explanation
     helper.label_class = 'sr-only'
     helper.layout = Layout(
         Fieldset(
             '',
             Field('email', placeholder=self.fields['email'].label),
             Field('password1', placeholder=self.fields['password1'].label),
             Field('password2', placeholder=self.fields['password2'].label),
         ),
         FormActions(
             Submit(
                 'save', _('Create Account'), css_class='btn-lg btn-block',
             )
         )
     )
     return helper
コード例 #48
0
ファイル: crispies.py プロジェクト: sveetch/django-datebook
def day_helper(form_tag=True, form_action='.', **kwargs):
    """
    DayEntry's form layout helper
    """
    helper = FormHelper()
    helper.form_action = form_action
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    # Tuple containing next day date and resolved url to its form
    next_day = kwargs.pop('next_day', None)
    # Mode to ensure compatibility with DayToDayModelForm (just a save button and no vacation)
    day_to_model_mode = kwargs.pop('day_to_model_mode', False)
    # Resolved url to the 'DayToDayModelForm' form
    day_to_model_url = kwargs.pop('day_to_model_url', None)
    # Resolved url to the day removing form
    remove_url = kwargs.pop('remove_url', None)
    
    # Menu elements (buttons and links)
    menu_elements = []
    
    # Build button groups
    buttons = [Submit('submit', _('Save'))]
    if not day_to_model_mode and next_day:
        buttons.append(Submit('submit_and_next', _('Save and continue to next day')))
    groups = []
    if remove_url:
        groups.append(ButtonGroup(
            Div(
                HTML('<a class="button tiny alert" href="{0}">'.format(remove_url)),
                HTML(_('Remove this entry')),
                HTML('</a>'),
            ),
            css_class='left'
        ))
    groups.append(ButtonGroup(
        *buttons,
        css_class='right'
    ))
    menu_elements.append(
        Div(
            *groups,
            css_class='clearfix'
        )
    )
        
    # For some links under the form's buttons
    links = []
    if not day_to_model_mode:
        if next_day:
            links.append( 
                Div(
                    HTML('<a class="button tiny secondary" href="{0}">'.format(next_day[1])),
                    HTML(_('Pass and continue to next day')),
                    HTML('</a>'),
                )
            )
        if day_to_model_url:
            links.append( 
                Div(
                    HTML('<a class="button tiny secondary" href="{0}">'.format(day_to_model_url)),
                    HTML(_('Use it as a day model')),
                    HTML('</a>'),
                )
            )
    if links:
        menu_elements.append(
            Div(
                ButtonGroup(
                    *links,
                    css_class='right'
                ),
                css_class='clearfix'
            )
        )
    
    # Menu where belong the buttons and links
    menu = Panel(
        *menu_elements,
        css_class='text-right'
    )
    
    # Build the full layout
    helper.layout = Layout(
        Row(
            Column('vacation', css_class='small-6 medium-4 medium-offset-8 text-right'),
        ),
        Row(
            Column('start_datetime', css_class='small-12 medium-4'),
            Column('pause', css_class='small-12 medium-2'),
            Column('stop_datetime', css_class='small-12 medium-4'),
            Column('overtime', css_class='small-12 medium-2'),
            css_class='opacited'
        ),
        Row(
            Column('content', css_class='small-12'),
            css_class='opacited'
        ),
        menu,
    )
    # Replace 'vacation' field with 'title' field for DayToDayModelForm form
    if day_to_model_mode:
        helper.layout.pop(0)
        helper.layout.insert(0,
            Row(
                Column('title'),
            ),
        )

    return helper
コード例 #49
0
def thread_helper(form_tag=True, edit_mode=False, for_moderator=False):
    """
    Thread's form layout helper
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    fieldsets = [
        Row(
            Column(
                'subject',
                css_class='small-12'
            ),
        ),
    ]
    
    # Category field only in edit form
    if edit_mode:
        fieldsets.append(
            Row(
                Column(
                    'category',
                    css_class='small-12'
                ),
            ),
        )
    
    if for_moderator:
        fieldsets.append(
            Row(
                Column(
                    'sticky',
                    css_class='small-12 medium-4'
                ),
                Column(
                    'announce',
                    css_class='small-12 medium-4'
                ),
                Column(
                    'closed',
                    css_class='small-12 medium-4'
                ),
            ),
        )
    
    # First message is not in edit form
    if not edit_mode:
        fieldsets.append(
            Row(
                Column(
                    'text',
                    css_class='small-12'
                ),
            ),
        )
    
    if for_moderator:
        fieldsets.append(
            Row(
                Column(
                    'visible',
                    css_class='small-12'
                ),
            ),
        )
    
    # Threadwatch option is not in edit form
    if not edit_mode:
        fieldsets.append(
            Row(
                Column(
                    'threadwatch',
                    css_class='small-12'
                ),
            ),
        )
    
    fieldsets = fieldsets+[
        ButtonHolderPanel(
            Submit('submit', _('Submit')),
            css_class='text-right',
        ),
    ]
    
    helper.layout = Layout(*fieldsets)
    
    return helper
コード例 #50
0
def entity_helper(form_tag=True, kind=None):
    """
    Entity form layout helper
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.attrs = {'data_abide': ''}
    helper.form_tag = form_tag
    
    fieldset = [
        Row(
            Column(
                'name',
                css_class='small-12'
            ),
        ),
    ]
    
    if kind is None:
        fieldset.append(
            Row(
                Column(
                    'kind',
                    css_class='small-12'
                ),
            ),
        )
    
    fieldset = fieldset+[
        Row(
            Column(
                'adress',
                css_class='small-12'
            ),
        ),
        Row(
            Column(
                'town',
                css_class='small-12 medium-8'
            ),
            Column(
                'zipcode',
                css_class='small-12 medium-4'
            ),
        ),
        Row(
            Column(
                'phone',
                css_class='small-12 medium-6'
            ),
            Column(
                'fax',
                css_class='small-12 medium-6'
            ),
        ),
        ButtonHolderPanel(
            Submit('submit', _('Submit')),
            css_class='text-right',
        ),
    ]
    helper.layout = Layout(*fieldset)
    
    return helper