Ejemplo n.º 1
0
    class IndexPage(Page):
        header = html.h1('iommi examples')

        form_header = html.h2('Form examples')

        # We can create html fragments...
        f_a_1 = html.a('Example 1: echo submitted data', attrs__href="form_example_1/")
        f_b_1 = html.br()
        f_a_2 = html.a('Example 2: create a Foo', attrs__href="form_example_2/")
        f_b_2 = html.br()
        f_a_3 = html.a('Example 3: edit a Foo', attrs__href="form_example_3/")
        f_b_3 = html.br()
        f_a_4 = html.a('Example 4: custom buttons', attrs__href="form_example_4/")
        f_b_4 = html.br()
        f_a_5 = html.a('Example 5: automatic AJAX endpoint', attrs__href="form_example_5/")
        f_b_5 = html.br()
        f_a_k = html.a('Kitchen sink', attrs__href="form_kitchen/")

        table_header = html.h2('Table examples')

        # ...or just throw a big chunk of html in here
        table_links = mark_safe("""
        <a href="table_readme_example_1/">Example 1 from the README</a><br>
        <a href="table_readme_example_2/">Example 2 from the README</a><br>
        <a href="table_auto_example_1/">Example 1 of auto table</a><br>
        <a href="table_auto_example_2/">Example 2 of auto table</a><br>
        <a href="table_kitchen_sink/">Kitchen sink</a><br>
        <a href="table_as_view/">Table.as_view() example</a><br>
        """)

        page_header = html.h2('Page examples')

        page_links = mark_safe("""
        <a href="page_busy/">A busy page with lots of stuff</a><br>
        <a href="all_field_sorts">Show different type of form field types</a><br>
        <a href="all_column_sorts">Show different type of table column types</a>
        """)

        menu_examples = mark_safe("""
        <h2>Menu examples</h2>
        
        <a href="menu_test/">A menu example</a><br>
        """)

        # You can also nest pages
        admin = AdminPage()

        select_style = StyleSelector()
Ejemplo n.º 2
0
    class IndexPage(Page):
        header = html.h1('iommi examples')

        form_header = html.h2('Form examples')

        # We can create html fragments...
        f_a_1 = html.a('Example 1: echo submitted data',
                       attrs__href="form_example_1/")
        f_b_1 = html.br()
        f_a_2 = html.a('Example 2: create a Foo',
                       attrs__href="form_example_2/")
        f_b_2 = html.br()
        f_a_3 = html.a('Example 3: edit a Foo', attrs__href="form_example_3/")
        f_b_3 = html.br()
        f_a_4 = html.a('Example 4: custom buttons',
                       attrs__href="form_example_4/")
        f_b_4 = html.br()
        f_a_5 = html.a('Example 5: automatic AJAX endpoint',
                       attrs__href="form_example_5/")
        f_b_5 = html.br()
        f_a_k = html.a('Kitchen sink', attrs__href="form_kitchen/")

        table_header = html.h2('Table examples')

        # ...or just throw a big chunk of html in here
        table_links = mark_safe("""
        <a href="table_readme_example_1/">Example 1 from the README</a><br>
        <a href="table_readme_example_2/">Example 2 from the README</a><br>
        <a href="table_kitchen_sink/">Kitchen sink</a><br>
        """)

        page_header = html.h2('Page examples')

        page_links = mark_safe("""
        <a href="page_busy/">A busy page with lots of stuff</a><br>
        """)

        # You can also nest pages
        admin = AdminPage()
Ejemplo n.º 3
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,
            ),
        )
Ejemplo n.º 4
0
def all_models(app, table, **kwargs):
    column_cls = table.call_target.cls.get_meta().member_class

    def app_data():
        for app_name, models in apps.all_models.items():
            for name, cls in models.items():
                if app.get(app_name, {}).get(name, {}).get('include', True):
                    yield Struct(app_name=app_name, model_name=name, model=cls)

    table = setdefaults_path(
        table,
        sortable=False,
        rows=app_data(),
        columns=dict(
            app_name=column_cls(auto_rowspan=True),
            model_name=column_cls(cell__url=lambda row, **_: '%s/%s/' %
                                  (row.app_name, row.model_name)),
        ))

    return Page(parts__header=admin_h1,
                parts__title=html.h2('All models'),
                parts__table=table(),
                **kwargs)
Ejemplo n.º 5
0
    class AdminPage(Page):
        admin_header = html.h2('Admin example')

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