25 |
25 |
from wcs.roles import Role
|
26 |
26 |
|
27 |
27 |
import qommon.ident
|
|
28 |
from qommon.ident.idp import is_idp_managing_user_attributes
|
28 |
29 |
from qommon.form import *
|
29 |
30 |
from qommon.admin.emails import EmailsDirectory
|
30 |
31 |
from qommon.backoffice.menu import html_top
|
... | ... | |
41 |
42 |
form = Form(enctype='multipart/form-data')
|
42 |
43 |
# do not display user attribute fields if the site has been set to get
|
43 |
44 |
# them filled by SAML requests
|
44 |
|
if not get_cfg('sp', {}).get('idp-manage-user-attributes', False):
|
|
45 |
if not is_idp_managing_user_attributes():
|
45 |
46 |
formdef = get_publisher().user_class.get_formdef()
|
46 |
47 |
if not formdef or not users_cfg.get('field_name'):
|
47 |
48 |
form.add(StringWidget, 'name', title = _('Name'), required = True, size=30,
|
... | ... | |
79 |
80 |
widget = form.get_widget(f)
|
80 |
81 |
if widget:
|
81 |
82 |
setattr(self.user, f, widget.parse())
|
82 |
|
if not get_cfg('sp', {}).get('idp-manage-user-attributes', False):
|
|
83 |
if not is_idp_managing_user_attributes():
|
83 |
84 |
formdef = get_publisher().user_class.get_formdef()
|
84 |
85 |
if formdef:
|
85 |
86 |
data = formdef.get_data(form)
|
... | ... | |
213 |
214 |
r = TemplateIO(html=True)
|
214 |
215 |
r += htmltext('<ul id="sidebar-actions">')
|
215 |
216 |
|
216 |
|
if get_cfg('sp', {}).get('idp-manage-user-attributes'):
|
|
217 |
if is_idp_managing_user_attributes():
|
217 |
218 |
r += htmltext('<li><a href="edit">%s</a></li>') % _('Manage Roles')
|
218 |
219 |
else:
|
219 |
220 |
r += htmltext('<li><a href="edit">%s</a></li>') % _('Edit')
|
... | ... | |
408 |
409 |
# if attributes are managed by the identity provider, do not expose
|
409 |
410 |
# the possibility to create users, as only the roles field would
|
410 |
411 |
# be shown, and the creation would fail on missing fields.
|
411 |
|
if not get_cfg('sp', {}).get('idp-manage-user-attributes', False):
|
|
412 |
if not is_idp_managing_user_attributes():
|
412 |
413 |
r += htmltext("""<ul id="sidebar-actions">
|
413 |
414 |
<li><a class="new-item" href="new">%s</a></li>
|
414 |
415 |
</ul>""") % _('New User')
|
... | ... | |
469 |
470 |
if ident_methods == ['idp'] and len(get_cfg('idp', {}).items()) == 0:
|
470 |
471 |
return error_page('users',
|
471 |
472 |
_('SAML support must be setup before creating users.'))
|
472 |
|
if get_cfg('sp', {}).get('idp-manage-user-attributes', False):
|
|
473 |
if is_idp_managing_user_attributes():
|
473 |
474 |
raise errors.TraversalError()
|
474 |
475 |
|
475 |
476 |
# XXX: user must be logged in to get here
|