Skip to content

Commit

Permalink
show acquired users (requested by desy)
Browse files Browse the repository at this point in the history
svn path=/ZMS/branches/zms4/; revision=5556
  • Loading branch information
zmsdev committed Apr 23, 2020
1 parent 5d679fb commit e1b93d5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
11 changes: 8 additions & 3 deletions Products/zms/_accessmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,23 +559,28 @@ def getSecurityRoles(self):
# --------------------------------------------------------------------------
# AccessManager.getSecurityUsers:
# --------------------------------------------------------------------------
def getSecurityUsers(self):
def getSecurityUsers(self, acquired=False):
userDefs = {}
root = self.getRootElement()
d = root.getConfProperty('ZMS.security.users', {})
if root == self:
userDefs = copy.deepcopy(d)
else:
home_id = self.getHome().id
home_ids = list(self.getHome().getPhysicalPath())
for name in d:
value = d[name]
nodes = value.get('nodes', {})
nodekeys = [x for x in nodes if nodes[x].get('home_id') == home_id]
if len(nodekeys) > 0:
aq_nodekeys = [x for x in nodes if nodes[x].get('home_id') in home_ids]
if len(nodekeys) > 0 or (acquired and len(aq_nodekeys) > 0):
userDef = {'nodes':{}}
for key in value:
if key not in userDef:
userDef[key] = value[key]
if acquired:
userDef['acquired'] = len(nodekeys) == 0
nodekeys.extend(aq_nodekeys)
for nodekey in nodekeys:
userDef['nodes'][nodekey] = nodes[nodekey]
userDefs[name] = userDef
Expand Down Expand Up @@ -734,7 +739,7 @@ def getValidUserids(self, search_term='', search_term_param=None, without_node_c
d['plugin'] = plugin
editurl = userFldr.absolute_url()+'/'+user.get('editurl','%s/manage_main'%pluginid)
container = userFldr.aq_parent
v = '<a href="%s" title="%s" target="_blank"><i class="%s"></i></a>'%(editurl,'%s.%s (%s)'%(container.id,plugin.title_or_id(),plugin.meta_type),plugin.zmi_icon)
v = '<a href="%s" title="%s" target="_blank"><img src="%s"/></a>'%(editurl,'%s.%s (%s)'%(container.id,plugin.title_or_id(),plugin.meta_type),plugin.zmi_icon)
t = 'html'
else:
v = user[extra]
Expand Down
23 changes: 14 additions & 9 deletions Products/zms/zpt/ZMS/manage_users.zpt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function zmiModalInsertUserOpen(context) {
<tal:block tal:define="
userFolder python:here.getUserFolder();
userAdderPlugin python:here.getUserAdderPlugin();
userDefs python:here.getSecurityUsers();
userDefs python:here.getSecurityUsers(request.get('show_acquired',False));
roleDefs python:here.getSecurityRoles();
userNames python:here.sort_list(list(userDefs));
langs_optpl python:[[x,here.getLanguageLabel(x)] for x in here.getLanguages(request)];
Expand Down Expand Up @@ -234,11 +234,11 @@ function zmiModalInsertUserOpen(context) {
</div>
<div class="form-group row activity_start">
<label class="col-sm-2 control-label" for="attrActiveStart"><span tal:content="structure python:here.getZMILangStr('ATTR_START_DAT')">the label</span></label>
<div class="input-group" tal:content="structure python:here.getDateTimeInput(fmName='userform',elName='attrActiveStart',value=here.getUserAttr(request['id'],'attrActiveStart',None),fmt_str='DATE_FMT',REQUEST=request)">the control</div>
<div class="input-group" tal:content="structure python:here.getDateTimeInput(fmName='userform',elName='attrActiveStart',value=here.getUserAttr(request['id'],'attrActiveStart',None),fmt_str='DATE_FMT')">the control</div>
</div>
<div class="form-group row activity_end">
<label class="col-sm-2 control-label" for="attrActiveEnd"><span tal:content="structure python:here.getZMILangStr('ATTR_END_DAT')">the label</span></label>
<div class="input-group" tal:content="structure python:here.getDateTimeInput(fmName='userform',elName='attrActiveEnd',value=here.getUserAttr(request['id'],'attrActiveEnd',None),fmt_str='DATE_FMT',REQUEST=request)">the control</div>
<div class="input-group" tal:content="structure python:here.getDateTimeInput(fmName='userform',elName='attrActiveEnd',value=here.getUserAttr(request['id'],'attrActiveEnd',None),fmt_str='DATE_FMT')">the control</div>
</div>
<tal:block tal:condition="python:userObj.get('password')==True">
<div id="tr_password" class="form-group row">
Expand Down Expand Up @@ -459,6 +459,7 @@ function zmiModalInsertUserOpen(context) {
<th>
<div class="btn-group">
<a class="btn btn-secondary" href="javascript:;" onclick="zmiModalInsertUserOpen(this)" tal:attributes="title python:'%s %s / %s '%(here.getZMILangStr('ATTR_USERS'), here.getZMILangStr('BTN_SEARCH'), here.getZMILangStr('BTN_INSERT'))"><i class="fas fa-plus"></i></a>
<a class="btn btn-secondary" tal:attributes="href python:'?lang=%s&show_acquired:boolean=%s'%(request['lang'],str(not request.get('show_acquired',False))); title python:'show acquired'; class python:'btn '+['btn-secondary','btn-success'][request.get('show_acquired')==True]" tal:condition="python:here.getPortalMaster() is not None"><i class="fas fa-share"></i></a>
<a class="btn btn-secondary" tal:attributes="href python:'manage_users_sitemap?lang=%s'%request['lang']; title python:here.getZMILangStr('TAB_SITEMAP')"><i class="fas fa-sitemap"></i></a>
<a class="btn btn-secondary" href="javascript:;" onclick="zmiModal('#importUsers',{title:$(this).attr('title')})" tal:attributes="title python:'%s...'%here.getZMILangStr('BTN_IMPORT')"><i class="fas fa-upload"></i></a>
<a class="btn btn-secondary" href="javascript:;" onclick="var $fm=$(this).closest('form');$('input[name=btn]',$fm).val('export');$fm.attr('target','_blank').submit();" tal:attributes="title python:here.getZMILangStr('BTN_EXPORT')"><i class="fas fa-download"></i></a>
Expand All @@ -467,16 +468,19 @@ function zmiModalInsertUserOpen(context) {
</th>
</tr>
</thead>
<tbody tal:define="securityUsers python:here.getSecurityUsers()">
<tbody tal:define="securityUsers python:here.getSecurityUsers(request.get('show_acquired',False))">
<tr tal:repeat="userName userNames" tal:attributes="id userName" class="userName">
<td>
<td tal:define="
securityUser python:securityUsers.get(userName,{});
acquired python:securityUser.get('acquired',False);
nodes python:securityUser.get('nodes',{});">
<tal:block tal:content="repeat/userName/number"></tal:block>.
<input type="checkbox" name="ids:list" tal:attributes="value userName"/>
<i class="icon-spinner icon-spin fas fa-share" tal:condition="acquired"></i>
<a data-placement="top"
tal:attributes="href python:'?lang=%s&id=%s'%(request['lang'],userName)"
tal:attributes="href python:'?lang=%s&id=%s'%(request['lang'],userName); class python:['','text-muted'][acquired];"
><span><i class="icon-spinner icon-spin fas fa-spinner fa-spin"></i> <tal:block tal:content="userName">userName</tal:block></span>
</a><tal:block
tal:define="global nodes python:securityUsers.get(userName,{}).get('nodes',{})"
tal:condition="python:len(nodes)>0"
</a><tal:block tal:condition="python:len(nodes)>0"
>&nbsp;(<tal:block tal:define="
all_roles python:sum([nodes[x].get('roles',[]) for x in nodes],[]);
distinct_roles python:standard.distinct_list(all_roles);
Expand Down Expand Up @@ -556,6 +560,7 @@ function zmiModalInsertUserOpen(context) {
security_users python:list(here.getConfProperty('ZMS.security.users',{}).values());
security_roles python:list(here.getConfProperty('ZMS.security.roles',{}).values());
">
<tal:block tal:content="repeat/validRole/number"></tal:block>.
<input type="checkbox" name="ids:list" tal:attributes="value validRole" />
<a target="" tal:attributes="href python:'?lang=%s&id=%s'%(request['lang'],validRole)"><i class="fas fa-users"></i><tal:block tal:content="validRole">validRole</tal:block></a>
( <tal:block tal:content="python:'%i %s'%(len(roleDefs[validRole]['nodes']),here.getZMILangStr('ATTR_NODE'))"># nodes</tal:block>
Expand Down

0 comments on commit e1b93d5

Please sign in to comment.