diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py index b1915c812..377e6f715 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py @@ -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']), diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/js/schema.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/js/schema.js index 607e8ab28..72a5936a2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/js/schema.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/js/schema.js @@ -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']}), diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.1_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.1_plus/sql/create.sql index 946058a71..6e6a81857 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.1_plus/sql/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.1_plus/sql/create.sql @@ -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 %} \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.2_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.2_plus/sql/create.sql index 782491683..2016209b0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.2_plus/sql/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.2_plus/sql/create.sql @@ -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 %} \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/ppas/9.1_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/ppas/9.1_plus/sql/create.sql index b63bb5910..4a071c4b9 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/ppas/9.1_plus/sql/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/ppas/9.1_plus/sql/create.sql @@ -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 %} \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/ppas/9.2_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/ppas/9.2_plus/sql/create.sql index 782491683..2016209b0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/ppas/9.2_plus/sql/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/ppas/9.2_plus/sql/create.sql @@ -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 %} \ No newline at end of file