wagtail_hooks.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. from wagtail.contrib.modeladmin.options import (
  2. ModelAdmin, ModelAdminGroup, modeladmin_register)
  3. from bakerydemo.breads.models import Country, BreadIngredient, 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.styleguide',
  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 BreadIngredientAdmin(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 = BreadIngredient
  21. class BreadTypeAdmin(ModelAdmin):
  22. model = BreadType
  23. class BreadCountryAdmin(ModelAdmin):
  24. model = Country
  25. class BreadModelAdminGroup(ModelAdminGroup):
  26. menu_label = 'Bread Categories'
  27. menu_icon = 'fa-suitcase' # change as required
  28. menu_order = 200 # will put in 3rd place (000 being 1st, 100 2nd)
  29. items = (BreadIngredientAdmin, BreadTypeAdmin, BreadCountryAdmin)
  30. class PeopleModelAdmin(ModelAdmin):
  31. model = People
  32. menu_label = 'People' # ditch this to use verbose_name_plural from model
  33. menu_icon = 'fa-users' # change as required
  34. list_display = ('first_name', 'last_name', 'job_title', 'thumb_image')
  35. class FooterTextAdmin(ModelAdmin):
  36. model = FooterText
  37. class BakeryModelAdminGroup(ModelAdminGroup):
  38. menu_label = 'Bakery Misc'
  39. menu_icon = 'fa-cutlery' # change as required
  40. menu_order = 300 # will put in 4th place (000 being 1st, 100 2nd)
  41. items = (PeopleModelAdmin, FooterTextAdmin)
  42. # When using a ModelAdminGroup class to group several ModelAdmin classes together,
  43. # you only need to register the ModelAdminGroup class with Wagtail:
  44. modeladmin_register(BreadModelAdminGroup)
  45. modeladmin_register(BakeryModelAdminGroup)