Skip to content

Commit

Permalink
Merge pull request #473 from chrisburr/use-listStatesForWeb
Browse files Browse the repository at this point in the history
[v4r0] Use listStatesForWeb endpoint
  • Loading branch information
TaykYoku authored Jun 2, 2021
2 parents ab3e7b1 + d284462 commit 783f232
Showing 1 changed file with 21 additions and 41 deletions.
62 changes: 21 additions & 41 deletions WebApp/handler/UPHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,13 @@ def web_listPublicStates(self):
user = session["user"]["username"]

up = self.__getUP()
retVal = yield self.threadTask(up.getUserProfileNames, {'PublishAccess': 'ALL'})

retVal = yield self.threadTask(up.listStatesForWeb, {'PublishAccess': 'ALL'})
if not retVal['OK']:
raise WErr.fromSERROR(retVal)

data = retVal['Value']

if data is None:
records = retVal['Value']
if not records:
raise WErr(404, "There are no public states!")

paramNames = ['user', 'group', 'vo', 'name']

mydesktops = {'name': 'My Desktops',
'group': '',
'vo': '',
Expand Down Expand Up @@ -283,40 +278,25 @@ def web_listPublicStates(self):
}
]
}
for i in data:
application = i.replace('Web/application/', '')
up = UserProfileClient(i)
retVal = up.listAvailableVars()
if not retVal['OK']:
raise WErr.fromSERROR(retVal)
else:
states = retVal['Value']

for state in states:
record = dict(zip(paramNames, state))
record['app'] = application
retVal = yield self.threadTask(up.getVarPermissions, record['name'])
if not retVal['OK']:
raise WErr.fromSERROR(retVal)
for record in records:
permissions = record["permissions"]
if permissions['PublishAccess'] == 'ALL':
if record["app"] == 'desktop':
record['type'] = 'desktop'
record['leaf'] = 'true'
record['iconCls'] = 'core-desktop-icon',
if record['user'] == user:
mydesktops['children'].append(record)
else:
shareddesktops['children'].append(record)
else:
record['type'] = 'application'
record['leaf'] = 'true'
record['iconCls'] = 'core-application-icon'
if record['user'] == user:
myapplications['children'].append(record)
else:
permissions = retVal['Value']
if permissions['PublishAccess'] == 'ALL':
if application == 'desktop':
record['type'] = 'desktop'
record['leaf'] = 'true'
record['iconCls'] = 'core-desktop-icon',
if record['user'] == user:
mydesktops['children'].append(record)
else:
shareddesktops['children'].append(record)
else:
record['type'] = 'application'
record['leaf'] = 'true'
record['iconCls'] = 'core-application-icon'
if record['user'] == user:
myapplications['children'].append(record)
else:
sharedapplications['children'].append(record)
sharedapplications['children'].append(record)

self.finish(desktopsApplications)

Expand Down

0 comments on commit 783f232

Please sign in to comment.