Commits

Bernardo Cabezas Serra  committed bd92b8d

Simple django-cms menu for all news

  • Participants
  • Parent commits b87a96a

Comments (0)

Files changed (1)

File cmsplugin_advancednews/menu.py

+# -*- coding: UTF-8 -*-
+# @author: bcabezas@apsl.net
+
+from menus.base import Menu, NavigationNode
+from cms.menu_bases import CMSAttachMenu
+from menus.menu_pool import menu_pool
+from django.utils.translation import ugettext_lazy as _
+from .models import News
+
+class NewsMenu(CMSAttachMenu):
+    """Submenu de Colegiados"""
+    name = "Submenu Noticias"
+
+    def get_nodes(self, request):
+        nodes = []
+        for newsitem in News.published.all():
+            node = NavigationNode(
+                title=newsitem.lazy_translation_getter('title', newsitem.slug),
+                url=newsitem.get_absolute_url(),
+                id=newsitem.pk)
+            nodes.append(node)
+        return nodes
+
+menu_pool.register_menu(NewsMenu)