mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Allow default ACLs to be specified when creating schemas. Fixes #1108.
This commit is contained in:
parent
5928f70a1d
commit
8b0e65dc57
@ -508,7 +508,7 @@ It may have been removed by another user.
|
||||
)
|
||||
)
|
||||
try:
|
||||
self.format_request_acls(data, specific=['nspacl'])
|
||||
self.format_request_acls(data)
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'sql/create.sql']),
|
||||
data=data, conn=self.conn, _=gettext
|
||||
@ -665,7 +665,7 @@ It may have been removed by another user.
|
||||
SQL = self.get_sql(gid, sid, data, scid)
|
||||
if SQL and SQL.strip('\n') and SQL.strip(' '):
|
||||
return make_json_response(
|
||||
data=SQL,
|
||||
data=SQL.strip('\n'),
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
@ -708,7 +708,7 @@ It may have been removed by another user.
|
||||
return " -- " + gettext("Definition incomplete.")
|
||||
|
||||
# Privileges
|
||||
self.format_request_acls(data, specific=['nspacl'])
|
||||
self.format_request_acls(data)
|
||||
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'sql/create.sql']),
|
||||
|
@ -377,7 +377,7 @@ function($, _, S, pgAdmin, pgBrowser, Backform, alertify) {
|
||||
canEdit: false, canDelete: true, control: 'unique-col-collection'
|
||||
},{
|
||||
type: 'nested', control: 'tab', group: '{{ _('Default Privileges') }}',
|
||||
mode: ['edit'],
|
||||
mode: ['create','edit'],
|
||||
schema:[{
|
||||
id: 'deftblacl', model: pgBrowser.Node.PrivilegeRoleModel.extend(
|
||||
{privileges: ['a', 'r', 'w', 'd', 'D', 'x', 't']}),
|
||||
|
@ -4,41 +4,37 @@
|
||||
{% if data.name %}
|
||||
CREATE SCHEMA {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
|
||||
|
||||
AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %};
|
||||
AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %}{% endif %};
|
||||
{# Alter the comment/description #}
|
||||
{% if data.description %}
|
||||
|
||||
COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
|
||||
IS {{ data.description|qtLiteral }};
|
||||
|
||||
{% endif %}
|
||||
{# ACL for the schema #}
|
||||
{% if data.nspacl %}
|
||||
{% for priv in data.nspacl %}
|
||||
|
||||
{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{# Default privileges on tables #}
|
||||
{% for defacl, type in [
|
||||
('deftblacl', 'TABLES'), ('defseqacl', 'SEQUENCES'),
|
||||
('deffuncacl', 'FUNCTIONS')]
|
||||
%}
|
||||
{% if data[defacl] %}{% set acl = data[defacl] %}
|
||||
{% for priv in data.deftblacl %}
|
||||
{% for priv in acl %}
|
||||
|
||||
{{ DEFAULT_PRIVILEGE.SET(
|
||||
conn, 'SCHEMA', data.name, type, priv.grantee,
|
||||
priv.without_grant, priv.with_grant
|
||||
) }}{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{# Security Labels on schema #}
|
||||
{% if data.seclabels and data.seclabels|length > 0 %}
|
||||
{% for r in data.seclabels %}
|
||||
{{ SECLABLE.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
{{ -- _('Incomplete definition') }}
|
||||
{% endif %}
|
||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
@ -4,41 +4,37 @@
|
||||
{% if data.name %}
|
||||
CREATE SCHEMA {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
|
||||
|
||||
AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %};
|
||||
AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %}{% endif %};
|
||||
{# Alter the comment/description #}
|
||||
{% if data.description %}
|
||||
|
||||
COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
|
||||
IS {{ data.description|qtLiteral }};
|
||||
|
||||
{% endif %}
|
||||
{# ACL for the schema #}
|
||||
{% if data.nspacl %}
|
||||
{% for priv in data.nspacl %}
|
||||
|
||||
{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{# Default privileges on tables #}
|
||||
{% for defacl, type in [
|
||||
('deftblacl', 'TABLES'), ('defseqacl', 'SEQUENCES'),
|
||||
('deffuncacl', 'FUNCTIONS'), ('deftypeacl', 'TYPES')]
|
||||
%}
|
||||
{% if data[defacl] %}{% set acl = data[defacl] %}
|
||||
{% for priv in data.deftblacl %}
|
||||
{% for priv in acl %}
|
||||
|
||||
{{ DEFAULT_PRIVILEGE.SET(
|
||||
conn, 'SCHEMA', data.name, type, priv.grantee,
|
||||
priv.without_grant, priv.with_grant
|
||||
) }}{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{# Security Labels on schema #}
|
||||
{% if data.seclabels and data.seclabels|length > 0 %}
|
||||
{% for r in data.seclabels %}
|
||||
|
||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
{{ -- _('Incomplete definition') }}
|
||||
{% endif %}
|
||||
{% endif %}
|
@ -4,41 +4,37 @@
|
||||
{% if data.name %}
|
||||
CREATE SCHEMA {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
|
||||
|
||||
AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %};
|
||||
AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %}{% endif %};
|
||||
{# Alter the comment/description #}
|
||||
{% if data.description %}
|
||||
|
||||
COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
|
||||
IS {{ data.description|qtLiteral }};
|
||||
|
||||
{% endif %}
|
||||
{# ACL for the schema #}
|
||||
{% if data.nspacl %}
|
||||
{% for priv in data.nspacl %}
|
||||
|
||||
{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{# Default privileges on tables #}
|
||||
{% for defacl, type in [
|
||||
('deftblacl', 'TABLES'), ('defseqacl', 'SEQUENCES'),
|
||||
('deffuncacl', 'FUNCTIONS')]
|
||||
%}
|
||||
{% if data[defacl] %}{% set acl = data[defacl] %}
|
||||
{% for priv in data.deftblacl %}
|
||||
{% for priv in acl %}
|
||||
|
||||
{{ DEFAULT_PRIVILEGE.SET(
|
||||
conn, 'SCHEMA', data.name, type, priv.grantee,
|
||||
priv.without_grant, priv.with_grant
|
||||
) }}{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{# Security Labels on schema #}
|
||||
{% if data.seclabels and data.seclabels|length > 0 %}
|
||||
{% for r in data.seclabels %}
|
||||
|
||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
{{ -- _('Incomplete definition') }}
|
||||
{% endif %}
|
||||
{% endif %}
|
@ -4,41 +4,37 @@
|
||||
{% if data.name %}
|
||||
CREATE SCHEMA {{ conn|qtIdent(data.name) }}{% if data.namespaceowner %}
|
||||
|
||||
AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %};
|
||||
AUTHORIZATION {{ conn|qtIdent(data.namespaceowner) }}{% endif %}{% endif %};
|
||||
{# Alter the comment/description #}
|
||||
{% if data.description %}
|
||||
|
||||
COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
|
||||
IS {{ data.description|qtLiteral }};
|
||||
|
||||
{% endif %}
|
||||
{# ACL for the schema #}
|
||||
{% if data.nspacl %}
|
||||
{% for priv in data.nspacl %}
|
||||
|
||||
{{ PRIVILEGE.APPLY(conn, 'SCHEMA', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{# Default privileges on tables #}
|
||||
{% for defacl, type in [
|
||||
('deftblacl', 'TABLES'), ('defseqacl', 'SEQUENCES'),
|
||||
('deffuncacl', 'FUNCTIONS'), ('deftypeacl', 'TYPES')]
|
||||
%}
|
||||
{% if data[defacl] %}{% set acl = data[defacl] %}
|
||||
{% for priv in data.deftblacl %}
|
||||
{% for priv in acl %}
|
||||
|
||||
{{ DEFAULT_PRIVILEGE.SET(
|
||||
conn, 'SCHEMA', data.name, type, priv.grantee,
|
||||
priv.without_grant, priv.with_grant
|
||||
) }}{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{# Security Labels on schema #}
|
||||
{% if data.seclabels and data.seclabels|length > 0 %}
|
||||
{% for r in data.seclabels %}
|
||||
|
||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
{{ -- _('Incomplete definition') }}
|
||||
{% endif %}
|
||||
{% endif %}
|
Loading…
Reference in New Issue
Block a user