wagtail_hooks.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. from wagtail.contrib.modeladmin.options import (
  2. ModelAdmin, ModelAdminGroup, modeladmin_register)
  3. from bakerydemo.breads.models import Country, BreadType
  4. from bakerydemo.base.models import People, FooterText
  5. '''
  6. N.B. To see what icons are available for use in Wagtail menus and StreamField block types,
  7. enable the styleguide in settings:
  8. INSTALLED_APPS = (
  9. ...
  10. 'wagtail.contrib.wagtailstyleguide',
  11. ...
  12. )
  13. or see http://kave.github.io/general/2015/12/06/wagtail-streamfield-icons.html
  14. This demo project includes the full font-awesome set via CDN in base.html, so the entire
  15. font-awesome icon set is available to you. Options are at http://fontawesome.io/icons/.
  16. '''
  17. class BreadTypeAdmin(ModelAdmin):
  18. # These stub classes allow us to put various models into the custom "Wagtail Bakery" menu item
  19. # rather than under the default Snippets section.
  20. model = BreadType
  21. class BreadCountryAdmin(ModelAdmin):
  22. model = Country
  23. class BreadModelAdminGroup(ModelAdminGroup):
  24. menu_label = 'Bread Categories'
  25. menu_icon = 'fa-suitcase' # change as required
  26. menu_order = 200 # will put in 3rd place (000 being 1st, 100 2nd)
  27. items = (BreadTypeAdmin, BreadCountryAdmin)
  28. class PeopleModelAdmin(ModelAdmin):
  29. model = People
  30. menu_label = 'People' # ditch this to use verbose_name_plural from model
  31. menu_icon = 'fa-users' # change as required
  32. list_display = ('first_name', 'last_name', 'job_title', 'thumb_image')
  33. class FooterTextAdmin(ModelAdmin):
  34. model = FooterText
  35. class BakeryModelAdminGroup(ModelAdminGroup):
  36. menu_label = 'Bakery Misc'
  37. menu_icon = 'fa-cutlery' # change as required
  38. menu_order = 300 # will put in 4th place (000 being 1st, 100 2nd)
  39. items = (PeopleModelAdmin, FooterTextAdmin)
  40. # When using a ModelAdminGroup class to group several ModelAdmin classes together,
  41. # you only need to register the ModelAdminGroup class with Wagtail:
  42. modeladmin_register(BreadModelAdminGroup)
  43. modeladmin_register(BakeryModelAdminGroup)