Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

55 lines (44 sloc) 1.626 kB
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db.models import Q
from django.core.exceptions import ValidationError
from cms.apphook_pool import apphook_pool
from cms.models import Page
from menus.base import Menu
class CMSAttachMenu(Menu):
cms_enabled = True
instance = None
name = None
def __init__(self, *args, **kwargs):
super(CMSAttachMenu, self).__init__(*args, **kwargs)
if self.cms_enabled and not
raise ValidationError(
"the menu %s is a CMSAttachMenu but has no name defined!" %
def get_apphooks(cls):
Returns a list of apphooks to which this CMSAttachMenu is attached.
Calling this does NOT produce DB queries.
apps = []
for key, _ in apphook_pool.get_apphooks():
app = apphook_pool.get_apphook(key)
if cls in app.menus:
return apps
def get_instances(cls):
Return a list (queryset, really) of all CMS Page objects (in this case)
that are currently using this CMSAttachMenu either directly as a
navigation_extender, or, as part of an apphook.
Calling this DOES perform a DB query.
parent_apps = []
for app in cls.get_apphooks():
return Page.objects.filter(
| Q(navigation_extenders=cls.__name__)
Jump to Line
Something went wrong with that request. Please try again.