class Meta: iommi_style = None parts__menu__sub_menu = dict( home=MenuItem(url='/'), admin=MenuItem(url=lambda **_: reverse(ExampleAdmin.all_models)), change_password=MenuItem( url=lambda **_: reverse(Auth.change_password)), logout=MenuItem(url=lambda **_: reverse(Auth.logout)), ) parts__footer = Fragment( after=LAST, children=dict( hr=html.hr(), style=StyleSelector(title='Change iommi style'), ))
class FooPage(Page): menu = Menu( sub_menu=dict( root=MenuItem(url='/'), menu_test=MenuItem(), f_a_1=MenuItem(display_name='Example 1: echo submitted data', url="form_example_1/"), f_a_2=MenuItem(display_name='Example 2: create a Foo', url="form_example_2/"), f_a_3=MenuItem(display_name='Example 3: edit a Foo', url="form_example_3/"), f_a_4=MenuItem(display_name='Example 4: custom buttons', url="form_example_4/"), f_a_5=MenuItem(display_name='Example 5: automatic AJAX endpoint', url="form_example_5/"), f_a_k=MenuItem(display_name='Kitchen sink', url="form_kitchen/"), ), )
class Meta: @staticmethod def actions__submit__post_handler(request, form, **_): style = form.fields.style.value settings.IOMMI_DEFAULT_STYLE = style return HttpResponseRedirect(request.get_full_path()) style = Field.choice( choices=[k for k, v in items(iommi.style._styles) if not v.internal], initial=lambda form, field, **_: getattr( settings, 'IOMMI_DEFAULT_STYLE', iommi.style.DEFAULT_STYLE), ) menu = Menu(sub_menu=dict( root=MenuItem(url='/'), page_examples=MenuItem(url='/page'), form_examples=MenuItem(url='/form'), table_examples=MenuItem(url='/table'), menu_examples=MenuItem(url='/menu'), supernaut=MenuItem(url='/supernaut'), admin=MenuItem(url='/iommi-admin'), login=MenuItem( display_name='Log in', url='/iommi-admin/login/?next=/', include=lambda request, **_: not request.user.is_authenticated, ), log_out=MenuItem( display_name='Log out', url='/iommi-admin/logout/', include=lambda request, **_: request.user.is_authenticated,