コード例 #1
0
ファイル: test_utils.py プロジェクト: iamFIREcracker/expensio
    def test_describe_invalid_form_with_valid_form(self):
        # Given
        input1 = Input('input1')
        input2 = Input('input2')
        input3 = Input('input3')
        form = Form(input1, input2, input3)

        # When
        desc = describe_invalid_form(form)

        # Then
        self.assertEquals(dict(), desc)
コード例 #2
0
ファイル: test_utils.py プロジェクト: iamFIREcracker/expensio
    def test_describe_invalid_form_with_at_least_one_invalid_input_field(self):
        # Given
        input1 = Input('input1')
        input1.note = 'Required'
        input2 = Input('input2')
        input3 = Input('input3')
        input3.note = 'Invalid: YYYY/MM/DD'
        form = Form(input1, input2, input3)

        # When
        desc = describe_invalid_form(form)

        # Then
        self.assertEquals(
            dict(input1='Required', input3='Invalid: YYYY/MM/DD'), desc)
コード例 #3
0
from __future__ import print_function
from web.form import Button, Form, Textbox, net
from infogami.utils import i18n

class BetterButton(Button):
    def render(self):
        label = self.attrs.get('label', self.name)
        safename = net.websafe(self.name)
        x = '<button name="%s"%s>%s</button>' % (safename, self.addatts(), label)
        return x

_ = i18n.strings.get_namespace('/account/preferences')

template_preferences = Form(
    Textbox("path", description=_.template_root),
    BetterButton('save', label=_.save)
)

if __name__ == "__main__":
    print(template_preferences().render())
コード例 #4
0
from web.form import Form, Hidden, Textarea, Textbox, Validator

required = Validator("Required", lambda x: x and x.strip())

review_form = Form(Hidden('edition', required), Textbox('title'),
                   Textarea('text', required))
コード例 #5
0
ファイル: forms.py プロジェクト: cclauss/infogami
from infogami.utils.context import context


class BetterButton(Button):
    def render(self):
        label = self.attrs.get('label', self.name)
        safename = net.websafe(self.name)
        x = f'<button name="{safename}"{self.addatts()}>{label}</button>'
        return x


_ = i18n.strings.get_namespace('/account/login')

login = Form(
    Hidden('redirect'),
    Textbox('username', notnull, description=_.username),
    Password('password', notnull, description=_.password),
    Checkbox('remember', description=_.remember_me),
)

vlogin = regexp(r"^[A-Za-z0-9-_]{3,20}$",
                'must be between 3 and 20 letters and numbers')
vpass = regexp(r".{3,20}", 'must be between 3 and 20 characters')
vemail = regexp(r".*@.*", "must be a valid email address")
not_already_used = Validator(
    'This email is already used',
    lambda email: db.get_user_by_email(context.site, email) is
    None,  # type: ignore
)

_ = i18n.strings.get_namespace('/account/register')
コード例 #6
0
ファイル: test_form.py プロジェクト: Alexlr10/DoceMel
def test_id_escape_issue():
    f = Form(Textbox("x", id="x <unsafe>"))
    assert "<unsafe>" not in f.render()
    assert "<unsafe>" not in f.render_css()
コード例 #7
0
PointParamExtendedForm = Form(Dropdown('zpoint', [('', '')], description="zpoint"),
                              Textbox('x', size=12),
                              Textbox('y', size=12),
                              Textbox('width', size=12),
                              Textbox('width_new', size=12),
                              Textbox('doubledash', size=12),
                              Textbox('tripledash', size=12),
                              Textbox('leftp', size=12),
                              Textbox('rightp', size=12),
                              Textbox('downp', size=12),
                              Textbox('upp', size=12),
                              Textbox('dir', size=12),
                              Textbox('leftp2', size=12),
                              Textbox('rightp2', size=12),
                              Textbox('downp2', size=12),
                              Textbox('upp2', size=12),
                              Textbox('dir2', size=12),
                              Textbox('tensionand', size=12),
                              Textbox('penshifted', size=12),
                              Textbox('pointshifted', size=12),
                              Textbox('angle', size=12),
                              Textbox('penwidth', size=12),
                              Textbox('overx', size=12),
                              Textbox('overbase', size=12),
                              Textbox('overcap', size=12),
                              Textbox('overasc', size=12),
                              Textbox('overdesc', size=12),

                              Textbox('theta', size=12),
                              Textbox('serif_h_bot', size=12),
                              Textbox('serif_h_top', size=12),
                              Textbox('serif_v_left', size=12),
                              Textbox('serif_v_right', size=12))
コード例 #8
0
ファイル: form.py プロジェクト: SourceNote/webpy-note
 def test_id_escape_issue(self):
     f = Form(Textbox("x", id="x <unsafe>"))
     self.assertTrue("<unsafe>" not in f.render())
     self.assertTrue("<unsafe>" not in f.render_css())