allow hiding of controller macros, e.g. portlets

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2921 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2008-10-17 09:38:41 +00:00
parent 36da38c555
commit 10d4a15ca4
5 changed files with 21 additions and 11 deletions

View file

@ -8,7 +8,8 @@
<div class="action"
tal:attributes="class action/cssClass;
id action/dialogName|nothing;
title action/description;">
title action/description;"
i18n:attributes="title">
<a href="#" target="target_window" title="Description text"
tal:omit-tag="not:action/url"
tal:attributes="href action/url;
@ -18,7 +19,8 @@
i18n:attributes="title"><img src="#" alt="icon"
tal:condition="action/icon"
tal:attributes="src string:$resourceBase${action/icon};
alt action/description" />
alt action/description"
i18n:attributes="alt" />
<span i18n:translate=""
tal:condition="action/title"
tal:content="action/title">Action Title</span></a>

View file

@ -83,7 +83,7 @@ class Macros(dict):
def __init__(self, controller):
self.controller = controller
self.identifiers = set()
self.identifiers = {}
def register(self, slot, identifier=None, template=None, name=None,
priority=50, **kw):
@ -91,21 +91,28 @@ class Macros(dict):
# make sure a certain resource is only registered once
if identifier in self.identifiers:
return
self.identifiers.add(identifier)
#self.identifiers.add(identifier)
self.identifiers[identifier] = True
if template is None:
template = self.standardTemplate
if name is None:
name = slot
macro = Macro(template, name, priority, **kw)
macro = Macro(template, name, priority, identifier=identifier, **kw)
entry = self.setdefault(slot, [])
entry.append(macro)
def hide(self, identifier):
self.identifiers[identifier] = False
def __getitem__(self, key):
return list(sorted(self.get(key, []), key=lambda x: x.priority))
return [m for m in sorted(self.get(key, []), key=lambda x: x.priority)
if self.identifiers.get(m.identifier, True)]
class Macro(object):
identifier = ''
def __init__(self, template, name, priority, **kw):
self.template = template
self.name = name

BIN
browser/icons/ledgrey.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

View file

@ -48,10 +48,11 @@ class Person(object):
def age(self):
return self.ageAt(date.today())
def ageAt(self, date):
if not self.birthDate:
def ageAt(self, dt):
bd = self.birthDate
if not bd:
return None
return int((date - self.birthDate).days/365.25)
return int((dt - date(bd.year, bd.month, bd.day)).days/365.25)
class Address(object):

View file

@ -35,9 +35,9 @@ def simplePublishing():
return StatesDefinition('simple_publishing',
State('private', 'private', ('show', 'archive', 'remove'), color='red'),
State('draft', 'draft', ('publish', 'hide', 'archive', 'remove'),
color='yellow'),
color='blue'),
State('published', 'published', ('retract', 'archive'), color='green'),
State('archived', 'archived', ('show', 'remove'), color='lightblue'),
State('archived', 'archived', ('show', 'remove'), color='grey'),
State('removed', 'removed', ('show',), icon='cancel.png'),
Transition('show', 'show', 'draft'),
Transition('hide', 'hide', 'private'),