示例#1
0
class IndexPage(ExamplesPage):
    header = html.h1('Form examples')
    description = html.p('Some examples of iommi Forms')
    all_fields = html.p(
        Action(
            display_name='Example with all types of fields',
            attrs__href='all_fields',
        ),
        html.br(),
        after='example_11',
    )

    class Meta:
        parts = example_links(examples)
示例#2
0
class IndexPage(ExamplesPage):
    header = html.h1('Table examples')

    description = html.p('Some examples of iommi tables')

    all_fields = html.p(
        Action(
            display_name='Example with all available types of columns',
            attrs__href='all_columns',
        ),
        html.br(),
        after='example_6',
    )

    class Meta:
        parts = example_links(examples)
示例#3
0
 class SubmitPage(Page):
     heading = html.h1('TriOptima URL Blessalizer')
     form = SubmitForm()
     set_focus = html.script(
         mark_safe('document.getElementById("id_url").focus();', ))
     admin = html.p(html.a('Admin', attrs__href='/entries'),
                    ' (requires login)')
示例#4
0
class IndexPage(ExamplesPage):
    header = html.h1('Form examples')
    description = html.p('Some examples of iommi Forms')

    examples = example_links(examples)

    all_fields = Action(
        display_name='Example with all types of fields',
        attrs__href='all_fields',
    )
示例#5
0
def test_error_render_in_debug(settings):
    settings.DEBUG = True
    parent = html.p('foo').bind()
    parent._errors = {'foo', 'bar'}
    errors = Errors(parent=parent)
    assert errors
    assert errors.__html__() == (
        '<ul data-iommi-path="error" data-iommi-type="Fragment">'
        '<li data-iommi-path="error__children__error_0" data-iommi-type="Fragment">bar</li>'
        '<li data-iommi-path="error__children__error_1" data-iommi-type="Fragment">foo</li>'
        '</ul>')
示例#6
0
def example_links(examples):
    children = {}

    for i, example in enumerate(examples):
        n = i + 1
        children[f'example_{n}'] = html.p(
            Action(
                display_name=f'Example {n}: {example.description}',
                attrs__href=f'example_{n}',
            ),
            html.br(),
        )

    return Fragment(children=children)
示例#7
0
def example_links(examples):
    result = {}

    for i, example in enumerate(examples):
        n = i + 1
        result[f'example_{n}'] = html.p(
            Action(
                display_name=f'Example {n}: {example.description}',
                attrs__href=f'example_{n}',
            ),
            html.br(),
        )

    return result
示例#8
0
    class AdminPage(Page):
        admin_header = Header('Admin example')

        admin_a = html.p(html.a(
            'Admin',
            attrs__href="iommi-admin/",
        ), )

        log_in = html.a(
            'Log in',
            attrs__href='/iommi-admin/login/?next=/',
            include=lambda request, **_: not request.user.is_authenticated,
        )

        log_out = html.a(
            'Log out',
            attrs__href='/iommi-admin/logout/',
            include=lambda request, **_: request.user.is_authenticated,
        )
示例#9
0
    class AdminPage(Page):
        admin_header = html.h2('Admin example')

        log_in = html.a(
            'Log in',
            attrs__href='/log_in/',
            include=lambda request, **_: not request.user.is_authenticated,
        )

        log_out = html.a(
            'Log out',
            attrs__href='/log_out/',
            include=lambda request, **_: request.user.is_authenticated,
        )

        admin_a = html.p(
            html.a(
                'Admin (needs login)',
                attrs__href=lambda request, **_: "iommi-admin/" if request.user.is_authenticated else None,
            ),
        )
示例#10
0
def test_html_builder_multi_arg():
    assert html.h1('foo',
                   'bar').bind(request=None).__html__() == '<h1>foobar</h1>'
    assert html.h1('foo', html.p('bar')).bind(
        request=None).__html__() == '<h1>foo<p>bar</p></h1>'
示例#11
0
class IndexPage(ExamplesPage):
    header = html.h1('Page examples')
    description = html.p('Some examples of iommi Page')

    class Meta:
        parts = example_links(examples)
示例#12
0
class HelloWorldPage(Page):
    h1 = html.h1('Hello world!')
    p = html.p('This is an iommi page!')
示例#13
0
def thanks(request, short):
    return html.div(html.h1('Thank you for submitting an URL'),
                    html.p('Processing...'),
                    html.a('Submit another', attrs__href='/submit/'))
示例#14
0
class IndexPage(ExamplesPage):
    header = html.h1('Form examples')
    description = html.p('Some examples of iommi Forms')

    examples = example_links(examples)