[Grant Wizard] Added support for Materialized View in the Grant Wizard.

Also - done proper view clean up when the wizard is cancelled.
This commit is contained in:
Surinder Kumar
2016-05-25 17:40:36 +05:30
committed by Ashesh Vashi
parent b1aa956af8
commit 4741992ad7
10 changed files with 51 additions and 24 deletions

View File

@@ -281,7 +281,19 @@ def properties(gid, sid, did, node_id, node_type):
if ntype in ['schema', 'view']:
SQL = render_template("/".join(
[server_prop['template_path'], '/sql/view.sql']),
node_id=node_id, nspname=nspname)
node_id=node_id, node_type='v', nspname=nspname)
status, res = conn.execute_dict(SQL)
if not status:
return internal_server_error(errormsg=res)
res_data.extend(res['rows'])
# Fetch Materialzed Views against schema
if ntype in ['schema', 'mview']:
SQL = render_template("/".join(
[server_prop['template_path'], '/sql/view.sql']),
node_id=node_id, node_type='m', nspname=nspname)
status, res = conn.execute_dict(SQL)
if not status:

View File

@@ -206,6 +206,7 @@ define([
resizable: true,
autoReset: false,
maximizable: false,
closable: false,
closableByDimmer: false
}
};
@@ -219,7 +220,7 @@ define([
// Add pgadmin_grant_wizard_body class to dialog
$(this.elements.body).addClass('pgadmin_grant_wizard_body');
},
}
},
/**
@@ -521,6 +522,11 @@ define([
case 'View':
object_type = 'table';
break;
case 'Materialized View':
object_type = 'table';
break;
default:
break;
}
/**
@@ -1041,6 +1047,7 @@ define([
height: '',
curr_page: 0,
show_left_panel: false,
show_header_cancel_btn: true,
disable_finish: true
},

View File

@@ -15,10 +15,6 @@
"type": "TABLE",
"acl": ["a", "w", "d", "D", "x", "t"]
},
"view": {
"type": "VIEW",
"acl": ["a", "w", "d", "D", "x", "t"]
},
"sequence": {
"type": "SEQUENCE",
"acl": ["w", "U"]

View File

@@ -2,7 +2,7 @@
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
{% for obj in data.objects -%}
{% for priv in data.priv -%}
{% if obj.object_type == 'Table' or obj.object_type == 'View' %}
{% if obj.object_type == 'Table' or obj.object_type == 'View' or obj.object_type == 'Materialized View'%}
{{ PRIVILEGE.SET(conn, 'TABLE', priv['grantee'], obj.name, priv['without_grant'], priv['with_grant'], obj.nspname ) }}
{% endif %}
{% endfor -%}

View File

@@ -1,8 +1,9 @@
{# ===== Fetch list of Database object types(View) ===== #}
{% if node_id %}
{% if node_id and node_type %}
{% set ntype = "View" if node_type == 'v' else "Materialized View" %}
SELECT
c.relname AS name,
'View' AS object_type,
'{{ ntype }}' AS object_type,
'icon-view' AS icon,
'{{ nspname }}' AS nspname
FROM
@@ -20,7 +21,7 @@ WHERE
((r.ev_class = c.oid)
AND (bpchar(r.ev_type) = '1'::bpchar))
))
) OR (c.relkind = 'v'::char)
) AND (c.relkind = '{{ node_type }}'::char)
)
AND c.relnamespace = {{ node_id }}::oid
ORDER BY

View File

@@ -15,10 +15,6 @@
"type": "TABLE",
"acl": ["a", "w", "d", "D", "x", "t"]
},
"view": {
"type": "VIEW",
"acl": ["a", "w", "d", "D", "x", "t"]
},
"sequence": {
"type": "SEQUENCE",
"acl": ["w", "U"]

View File

@@ -2,7 +2,7 @@
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
{% for obj in data.objects -%}
{% for priv in data.priv -%}
{% if obj.object_type == 'Table' or obj.object_type == 'View' %}
{% if obj.object_type == 'Table' or obj.object_type == 'View' or obj.object_type == 'Materialized View'%}
{{ PRIVILEGE.SET(conn, 'TABLE', priv['grantee'], obj.name, priv['without_grant'], priv['with_grant'], obj.nspname ) }}
{% endif %}
{% endfor -%}

View File

@@ -1,9 +1,11 @@
{# ===== Fetch list of Database object types(View) ===== #}
{% if node_id %}
{% if node_id and node_type %}
{% set ntype = "View" if node_type == 'v' else "Materialized View" %}
{% set view_icon = "icon-view" if node_type == 'v' else "icon-mview" %}
SELECT
c.relname AS name,
'View' AS object_type,
'icon-view' AS icon,
'{{ ntype }}' AS object_type,
'{{ view_icon }}' AS icon,
'{{ nspname }}' AS nspname
FROM
pg_class c
@@ -20,7 +22,7 @@ WHERE
((r.ev_class = c.oid)
AND (bpchar(r.ev_type) = '1'::bpchar))
))
) OR (c.relkind = 'v'::char)
) AND (c.relkind = '{{ node_type }}'::char)
)
AND c.relnamespace = {{ node_id }}::oid
ORDER BY