Re: output all available roles
Ralf Schlatterbeck <[email protected]>
| Newsgroups | gmane.comp.bug-tracking.roundup.user |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Jun 15, 2015 at 04:03:41PM +0300, Anthony Pankov wrote:
> Greetings.
>
> Is there any way to output in html all available user roles?
>
> I've tried db.security.role but get no luck.
>
I'm using something like the following in a template named
"user.role.html" which you call as
..../user?@template=role
Note that the following code tries to fetch the localized value for some
strings via gettext.
<table class="list" border=1 tal:condition="context/roles/is_view_ok"
tal:define=
" roles python:[v for k,v in sorted (db._db.security.role.items ())]
; quote python:''
">
<tal:block tal:repeat="role roles">
<tr>
<th class="group" tal:content="python:'%(name)s' % role.__dict__"/>
</tr>
<tr tal:repeat="perm python:
sorted (role.permissions, key = lambda p: p.__dict__ ['klass'])">
<tal:block tal:define=
"d python: utils.permdict (perm)
;x python: ' %(description)s (%(name)s'
+ [ ''
, ( ' for %(quote)s%(klass)s%(quote)s'
+ ['', ': %(properties)s'][bool(perm.properties)]
+ ' only'
)
]
[bool(perm.klass)]
+ ')'">
<td tal:content="python:i18n.gettext(x)%d"/>
</tal:block>
</tr>
</tal:block>
</table>
Ralf
--
Dr. Ralf Schlatterbeck Tel: +43/2243/26465-16
Open Source Consulting www: http://www.runtux.com
Reichergasse 131, A-3411 Weidling email: [email protected]
allmenda.com member email: [email protected]
------------------------------------------------------------------------------