plugins.py 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. from itertools import chain
  2. from pluggy import HookimplMarker
  3. from flask_allows import Permission
  4. impl = HookimplMarker('flaskbb')
  5. @impl(hookwrapper=True, tryfirst=True)
  6. def flaskbb_tpl_admin_settings_menu(user):
  7. """
  8. Flattens the lists that come back from the hook
  9. into a single iterable that can be used to populate
  10. the menu
  11. """
  12. from flaskbb.utils.requirements import IsAdmin # noqa: circular dependency
  13. results = [
  14. ('management.overview', 'Overview', 'fa fa-tasks'),
  15. ('management.unread_reports', 'Reports', 'fa fa-flag'),
  16. ('management.users', 'Users', 'fa fa-user')
  17. ]
  18. if Permission(IsAdmin, identity=user):
  19. results.extend([
  20. ('management.groups', 'Groups', 'fa fa-users'),
  21. ('management.forums', 'Forums', 'fa fa-comments'),
  22. ('management.settings', 'Settings', 'fa fa-cogs'),
  23. ('management.plugins', 'Plugins', 'fa fa-puzzle-piece')
  24. ])
  25. outcome = yield
  26. outcome.force_result(chain(results, *outcome.get_result()))