Fixed privileges parsing issue while editing privileges of existing object. Fixes #1417

This commit is contained in:
Harshal Dhumal 2016-08-08 16:31:57 +01:00 committed by Dave Page
parent a025c0ebf0
commit 8918b8894d
2 changed files with 19 additions and 0 deletions

View File

@ -58,6 +58,7 @@
* + privileges - Privileges for that role.
**/
var PrivilegeRoleModel = pgNode.PrivilegeRoleModel = pgNode.Model.extend({
idAttribute: 'grantee',
defaults: {
grantee: undefined,
grantor: undefined,

View File

@ -63,6 +63,24 @@ def parse_priv_to_db(str_privileges, allowed_acls=[]):
priv_with_grant = []
priv_without_grant = []
if isinstance(priv['privileges'], dict) and 'changed' in priv['privileges']:
tmp = []
for p in priv['privileges']['changed']:
tmp_p = {'privilege_type': p['privilege_type'],
'privilege': False,
'with_grant': False}
if 'with_grant' in p:
tmp_p['privilege'] = True
tmp_p['with_grant'] = p['with_grant']
if 'privilege' in p:
tmp_p['privilege'] = p['privilege']
tmp.append(tmp_p)
priv['privileges'] = tmp
for privilege in priv['privileges']:
if privilege['privilege_type'] not in db_privileges: