Restructured the menu.

This commit is contained in:
Raoul Snyman 2010-03-25 08:05:09 +02:00
parent 3e37dff1b8
commit 60f74bf90a
2 changed files with 27 additions and 8 deletions

View File

@ -108,6 +108,12 @@ class User(BaseModel):
if perm == permission: if perm == permission:
return True return True
return False return False
elif isinstance(permission, list):
for role in self.roles:
for perm in role.permissions:
if perm.name in permission:
return True
return False
else: else:
return False return False

View File

@ -26,18 +26,31 @@
</li> </li>
% endif % endif
<li> <li>
<h2>Account</h2> <h2>Meta</h2>
<ul> <ul>
% if c.current_user: % if c.current_user:
<li><a href="${h.url_for(controller=u'account')}">My Account</a></li> <li>
% if c.current_user.has_permission('Add Posts'): Account
<li><a href="${h.url_for(controller=u'post', action=u'new')}">New Post</a></li> <ul>
<li><a href="${h.url_for(controller=u'account')}">My Details</a></li>
<li><a href="${h.url_for(controller=u'account', action=u'password')}">My Password</a></li>
</ul>
</li>
% if c.current_user.has_permission([u'Add Posts', u'Add Pages', u'Edit My Posts', u'Edit My Pages']):
<li>
Content
<ul>
% if c.current_user.has_permission(u'Add Posts'):
<li><a href="${h.url_for(controller=u'post', action=u'new')}">New Post</a></li>
% endif % endif
% if c.current_user.has_permission('Add Pages'): % if c.current_user.has_permission(u'Add Pages'):
<li><a href="${h.url_for(controller=u'page', action=u'new')}">New Page</a></li> <li><a href="${h.url_for(controller=u'page', action=u'new')}">New Page</a></li>
% endif % endif
% if c.current_user.has_permission('Edit My Posts'): % if c.current_user.has_permission(u'Edit My Posts'):
<li><a href="${h.url_for(controller=u'post', action=u'draft')}">Draft Posts</a></li> <li><a href="${h.url_for(controller=u'post', action=u'draft')}">Draft Posts</a></li>
% endif
</ul>
</li>
% endif % endif
<li><a href="${h.url_for(controller=u'account', action=u'logout')}">Logout</a></li> <li><a href="${h.url_for(controller=u'account', action=u'logout')}">Logout</a></li>
% else: % else: