Subject: [pgadmin4] fix for RM1417

From: Harshal Dhumal <[email-masked]>
Date: Mon, 8 Aug 2016 20:29:21 +0530

Hi,

PFA patch for issue RM1417.

Changes: Fixed privileges parsing issue while editing privileges of exiting
object.

Additional Note: This was general issue and was not related to runtime or
pg 9.6.

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
index 70246f6..418122e 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
@@ -58,6 +58,7 @@
    *  + privileges - Privileges for that role.
    **/
   var PrivilegeRoleModel = pgNode.PrivilegeRoleModel = pgNode.Model.extend({
+    idAttribute: 'grantee',
     defaults: {
       grantee: undefined,
       grantor: undefined,
diff --git a/web/pgadmin/browser/server_groups/servers/utils.py b/web/pgadmin/browser/server_groups/servers/utils.py
index 356b808..4aa04ea 100644
--- a/web/pgadmin/browser/server_groups/servers/utils.py
+++ b/web/pgadmin/browser/server_groups/servers/utils.py
@@ -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:

-- 
Sent via pgadmin-hackers mailing list ([email-masked])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

---

From: Dave Page <[email-masked]>
Date: Mon, 8 Aug 2016 16:32:08 +0100

Thanks - patch applied.

On Mon, Aug 8, 2016 at 3:59 PM, Harshal Dhumal
<[email-masked]> wrote:
> Additional Note: This was general issue and was not related to runtime or pg
> 9.6.
>
>
>
> --
> Harshal Dhumal
> Software Engineer
>

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company