Beispiel #1
0
def install():
  logging.info("> common.config.install")
  staticblock_ref = Block.add_model('staticblock', 'common.blocks.StaticBlock')
  block = Block(name='Main Menu', slug='mainmenu', position='mainmenu',
                model='common.blocks.MenuBlock', args={'name':'mainmenu'},
                active=True)
  block.save()
  
  block = Block(name='Administration', slug='admin-sidebar',
                position='adminsidebar', model='common.blocks.AdminMenuBlock',
                args={}, active=True)
  block.save()

  block = Block(name='Usermenu', slug='usermenu',
                position='header', model='common.blocks.UserMenuBlock',
                args={}, active=True)
  block.save()

  logging.info("   creating mainmenu")
  menu = Menu(name='mainmenu', slug='mainmenu', position='mainmenu',
              block=block.uuid)
  menu.save()
  
  menuitem = MenuItem(name='Home', slug='home', link='/', menu=menu.slug)
  menuitem.save()
  
  anonymous_ref = Role(name='anonymous', core=True, order=0)
  anonymous_ref.save()

  authenticated_ref = Role(name='authenticated', core=True, order=1)
  authenticated_ref.save()

  anonymous_ref = Role(name='administrator', core=True, order=5)
  anonymous_ref.save()
Beispiel #2
0
 def render(self, context):
   menu = Menu.get(name=self.name.resolve(context))
   res = "<ul id=\"menu-%s\" class=\"menu clearfix %s\">" % (menu.key().id(), menu.name)
   items = menu.top_items()
   for item in items:
     res = res + MenuNode.render_item(self.request.resolve(context), item, context)
   res = res + "</ul>"
   return res
Beispiel #3
0
  def __init__(self, *args, **kwargs):
    super(MenuItemForm, self).__init__(*args, **kwargs)
    self.fields['menu'].widget = forms.Select(choices=Menu.get_choices())

    exclude = []
    if self.instance:
      exclude.append(self.instance.uuid)
    items = [('', _('Top'))] + MenuItem.get_choices(exclude=exclude)
    self.fields['parentlink'].widget = forms.Select(choices=items, attrs={'size':10})
Beispiel #4
0
 def render(cls, context, name=""):
     menu = Menu.get(slug=name)
     context.update({"menu": menu})
     return cls.render_block(template_name="block_menu.html", block_title=_(name), context=context)