Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. hier = Hierachy.get_root_nodes().filter(company__slug= 'company')
  2. for site in hier:
  3. children = list()
  4. for plant in site.get_children():
  5. children.append(MenuItem(plant.name,
  6. reverse('pha:companyHierarchy', args=[plant.company.slug, plant.slug,]),
  7. weight=10,
  8. icon="user"))
  9. Menu.add_item("study", MenuItem(site.name, reverse('pha:companyHierarchy', args=[site.company.slug, site.slug,]),
  10. weight=10,
  11. icon="tools",
  12. children=children))
  13.  
  14. class SimpleMiddleware(object):
  15.  
  16. def process_view(self, request, func, args, kwargs):
  17. Menu.items.clear()
  18. hier = Hierachy.get_root_nodes().filter(company__slug= kwargs['slug'])
  19. for site in hier:
  20. children = list()
  21. for plant in site.get_children():
  22. children.append(MenuItem(plant.name,
  23. reverse('pha:companyHierarchy', args=[plant.company.slug, plant.slug,]),
  24. weight=10,
  25. icon="user"))
  26. Menu.add_item("study", MenuItem(site.name, reverse('pha:companyHierarchy', args=[site.company.slug, site.slug,]),
  27. weight=10,
  28. icon="tools",
  29. children=children))
  30.  
  31. return None
  32.  
  33. {% if menus.study %}
  34. <li class="dropdown">
  35. <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown">
  36. Studies
  37. </a>
  38.  
  39. <ul class="dropdown-menu">
  40. {% for nodeMenu in menus.study %}
  41. {% if nodeMenu.children %}
  42. <li class="dropdown-submenu">
  43. <a href="{{nodeMenu.url}}">{{nodeMenu.title}}</a>
  44. <!-- Get plants and studies -->
  45.  
  46. <ul class="dropdown-menu">
  47. {% for child in nodeMenu.children %}
  48. <li><a href="{{child.url}}">{{child.title}}</a></li>
  49. {% endfor %}
  50. </ul>
  51. </li>
  52.  
  53. {% else %}
  54. <li class="">
  55. <a href="{{nodeMenu.url}}">{{nodeMenu.title}}</a>
  56.  
  57. </li>
  58. {% endif %}
  59. {% endfor %}
  60. </ul>
  61.  
  62. </li>
  63. {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement