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)
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)
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)')
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', )
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>')
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)
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
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, )
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, ), )
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>'
class IndexPage(ExamplesPage): header = html.h1('Page examples') description = html.p('Some examples of iommi Page') class Meta: parts = example_links(examples)
class HelloWorldPage(Page): h1 = html.h1('Hello world!') p = html.p('This is an iommi page!')
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/'))
class IndexPage(ExamplesPage): header = html.h1('Form examples') description = html.p('Some examples of iommi Forms') examples = example_links(examples)