admin: pimp the role page (list related forms...)
This commit is contained in:
parent
fd719e6c6b
commit
83b38af34a
|
@ -24,6 +24,7 @@ from qommon import errors
|
|||
from qommon.admin.menu import html_top, command_icon, error_page
|
||||
|
||||
from wcs.roles import Role
|
||||
from wcs.formdef import FormDef
|
||||
|
||||
class RoleUI:
|
||||
def __init__(self, role):
|
||||
|
@ -86,17 +87,69 @@ class RolePage(Directory):
|
|||
self.role.name
|
||||
'</h2>'
|
||||
|
||||
if self.role.details:
|
||||
'<p>'
|
||||
self.role.details
|
||||
'</p>'
|
||||
if self.role.details or self.role.emails:
|
||||
'<div class="bo-block">'
|
||||
if self.role.details:
|
||||
'<p>'
|
||||
self.role.details
|
||||
'</p>'
|
||||
|
||||
if self.role.emails:
|
||||
_('Emails:')
|
||||
if self.role.emails:
|
||||
_('Emails:')
|
||||
'<ul>'
|
||||
for email in self.role.emails:
|
||||
'<li>%s</li>' % email
|
||||
'</ul>'
|
||||
'</div>'
|
||||
|
||||
if self.role.emails_to_members or self.role.allows_backoffice_access:
|
||||
'<div class="bo-block">'
|
||||
'<h2>%s</h2>' % _('Options')
|
||||
'<ul>'
|
||||
for email in self.role.emails:
|
||||
'<li>%s</li>' % email
|
||||
if self.role.emails_to_members:
|
||||
'<li>%s</li>' % _('Holders of this role will receive all emails adressed to the role.')
|
||||
if self.role.allows_backoffice_access:
|
||||
'<li>%s</li>' % _('Holders of this role are granted access to the backoffice.')
|
||||
'</ul>'
|
||||
'</div>'
|
||||
|
||||
# list forms in two columns,
|
||||
# - 1 forms where the recipient is this role
|
||||
# - 2 forms where the sender is this role
|
||||
formdefs = FormDef.select()
|
||||
formdefs.sort(lambda x,y: cmp(x.name, y.name))
|
||||
receiver_formdefs = [x for x in formdefs if x.receiver_id == self.role.id]
|
||||
sender_formdefs = [x for x in formdefs if self.role.id in (x.roles or [])]
|
||||
|
||||
'<div class="splitcontent-left">'
|
||||
'<div class="bo-block">'
|
||||
'<h2>%s</h2>' % _('Forms handled by this role')
|
||||
'<ul>'
|
||||
for formdef in receiver_formdefs:
|
||||
'<li><a href="../../forms/%d">' % formdef.id
|
||||
formdef.name
|
||||
'</a></li>'
|
||||
if not receiver_formdefs:
|
||||
'<li>%s</li>' % _('no form associated to this role')
|
||||
'</ul>'
|
||||
'</div>'
|
||||
'</div>'
|
||||
|
||||
'<div class="splitcontent-right">'
|
||||
'<div class="bo-block">'
|
||||
'<h2>%s</h2>' % _('Forms private to this role')
|
||||
'<ul>'
|
||||
for formdef in sender_formdefs:
|
||||
'<li><a href="../../forms/%d">' % formdef.id
|
||||
formdef.name
|
||||
'</a></li>'
|
||||
if not sender_formdefs:
|
||||
'<li>%s</li>' % _('no form associated to this role')
|
||||
'</ul>'
|
||||
'</div>'
|
||||
'</div>'
|
||||
|
||||
|
||||
|
||||
def get_sidebar [html] (self):
|
||||
'<ul>'
|
||||
|
|
Loading…
Reference in New Issue