Ensure the default schema is set when creating objects. Fixes #1735
parent
b80cd43ae6
commit
6999249dcd
|
@ -408,14 +408,26 @@ class SchemaView(PGChildNodeView):
|
||||||
if not status:
|
if not status:
|
||||||
return internal_server_error(errormsg=rset)
|
return internal_server_error(errormsg=rset)
|
||||||
|
|
||||||
|
icon = 'icon-{0}'.format(self.node_type)
|
||||||
|
|
||||||
if scid is not None:
|
if scid is not None:
|
||||||
if len(rset['rows']) == 0:
|
if len(rset['rows']) == 0:
|
||||||
return gone(gettext("""
|
return gone(gettext("""
|
||||||
Could not find the schema in the database.
|
Could not find the schema in the database.
|
||||||
It may have been removed by another user.
|
It may have been removed by another user.
|
||||||
"""))
|
"""))
|
||||||
|
row = rset['rows'][0]
|
||||||
icon = 'icon-{0}'.format(self.node_type)
|
return make_json_response(
|
||||||
|
data=self.blueprint.generate_browser_node(
|
||||||
|
row['oid'],
|
||||||
|
did,
|
||||||
|
row['name'],
|
||||||
|
icon=icon,
|
||||||
|
can_create=row['can_create'],
|
||||||
|
has_usage=row['has_usage']
|
||||||
|
),
|
||||||
|
status=200
|
||||||
|
)
|
||||||
|
|
||||||
for row in rset['rows']:
|
for row in rset['rows']:
|
||||||
res.append(
|
res.append(
|
||||||
|
|
|
@ -100,19 +100,8 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
}, control: 'node-list-by-name',
|
||||||
control: Backform.NodeListByNameControl.extend({
|
cache_node: 'database', cached_level: 'database'
|
||||||
render: function(){
|
|
||||||
// Initialize parent's render method
|
|
||||||
Backform.NodeListByNameControl.prototype.render.apply(this, arguments);
|
|
||||||
|
|
||||||
// Set schema default value to its parent Schema
|
|
||||||
if(this.model.isNew()){
|
|
||||||
this.model.set({'schema': this.model.node_info.schema.label});
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},{
|
},{
|
||||||
id: 'copy_collation', label:'{{ _('Copy collation') }}', cell: 'string',
|
id: 'copy_collation', label:'{{ _('Copy collation') }}', cell: 'string',
|
||||||
control: 'node-ajax-options',
|
control: 'node-ajax-options',
|
||||||
|
|
|
@ -19,8 +19,15 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||||
var ConstraintModel = pgBrowser.Node.Model.extend({
|
var ConstraintModel = pgBrowser.Node.Model.extend({
|
||||||
idAttribute: 'conoid',
|
idAttribute: 'conoid',
|
||||||
initialize: function(attrs, args) {
|
initialize: function(attrs, args) {
|
||||||
var isNew = (_.size(attrs) === 0);
|
if (_.size(attrs) === 0) {
|
||||||
if (!isNew) {
|
var userInfo = pgBrowser.serverInfo[
|
||||||
|
args.node_info.server._id
|
||||||
|
].user,
|
||||||
|
schemaInfo = args.node_info.schema;
|
||||||
|
this.set({
|
||||||
|
'owner': userInfo.name, 'schema': schemaInfo._label
|
||||||
|
}, {silent: true});
|
||||||
|
} else {
|
||||||
this.convalidated_default = this.get('convalidated')
|
this.convalidated_default = this.get('convalidated')
|
||||||
}
|
}
|
||||||
pgBrowser.Node.Model.prototype.initialize.apply(this, arguments);
|
pgBrowser.Node.Model.prototype.initialize.apply(this, arguments);
|
||||||
|
|
|
@ -491,13 +491,13 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||||
initialize: function(attrs, args) {
|
initialize: function(attrs, args) {
|
||||||
var isNew = (_.size(attrs) === 0);
|
var isNew = (_.size(attrs) === 0);
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
// Set Selected Schema
|
var schema = args.node_info.schema._label,
|
||||||
schema = args.node_info.schema._label
|
userInfo = pgBrowser.serverInfo[args.node_info.server._id].user;
|
||||||
this.set({'basensp': schema}, {silent: true});
|
|
||||||
|
|
||||||
// Set Current User
|
// Set Selected Schema and Current User
|
||||||
var userInfo = pgBrowser.serverInfo[args.node_info.server._id].user;
|
this.set({
|
||||||
this.set({'owner': userInfo.name}, {silent: true});
|
'basensp': schema, 'owner': userInfo.name
|
||||||
|
}, {silent: true});
|
||||||
}
|
}
|
||||||
pgBrowser.Node.Model.prototype.initialize.apply(this, arguments);
|
pgBrowser.Node.Model.prototype.initialize.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
|
@ -490,7 +490,8 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||||
},{
|
},{
|
||||||
id: 'schema', label: '{{ _('Schema')}}', cell: 'string',
|
id: 'schema', label: '{{ _('Schema')}}', cell: 'string',
|
||||||
type: 'text', mode: ['create','edit'], node: 'schema',
|
type: 'text', mode: ['create','edit'], node: 'schema',
|
||||||
control: 'node-list-by-id'
|
control: 'node-list-by-id', cache_node: 'database',
|
||||||
|
cache_level: 'database'
|
||||||
},{
|
},{
|
||||||
id: 'description', label:'{{ _('Comment') }}', cell: 'string',
|
id: 'description', label:'{{ _('Comment') }}', cell: 'string',
|
||||||
type: 'multiline', cellHeaderClasses: 'width_percent_50'
|
type: 'multiline', cellHeaderClasses: 'width_percent_50'
|
||||||
|
|
|
@ -89,7 +89,8 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||||
},{
|
},{
|
||||||
id: 'schema', label: '{{ _('Schema')}}', cell: 'string',
|
id: 'schema', label: '{{ _('Schema')}}', cell: 'string',
|
||||||
type: 'text', mode: ['create','edit'], node: 'schema',
|
type: 'text', mode: ['create','edit'], node: 'schema',
|
||||||
control: 'node-list-by-id'
|
control: 'node-list-by-id', cache_node: 'database',
|
||||||
|
cache_level: 'database'
|
||||||
},{
|
},{
|
||||||
id: 'description', label:'{{ _('Comment') }}', cell: 'string',
|
id: 'description', label:'{{ _('Comment') }}', cell: 'string',
|
||||||
type: 'multiline', cellHeaderClasses: 'width_percent_50'
|
type: 'multiline', cellHeaderClasses: 'width_percent_50'
|
||||||
|
|
|
@ -83,7 +83,8 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||||
},{
|
},{
|
||||||
id: 'schema', label: '{{ _('Schema')}}', cell: 'string',
|
id: 'schema', label: '{{ _('Schema')}}', cell: 'string',
|
||||||
type: 'text', mode: ['create','edit'], node: 'schema',
|
type: 'text', mode: ['create','edit'], node: 'schema',
|
||||||
control: 'node-list-by-id'
|
control: 'node-list-by-id', cache_node: 'database',
|
||||||
|
cache_level: 'database'
|
||||||
},{
|
},{
|
||||||
id: 'description', label:'{{ _('Comment') }}', cell: 'string',
|
id: 'description', label:'{{ _('Comment') }}', cell: 'string',
|
||||||
type: 'multiline', cellHeaderClasses: 'width_percent_50'
|
type: 'multiline', cellHeaderClasses: 'width_percent_50'
|
||||||
|
|
|
@ -409,7 +409,7 @@ class PackageView(PGChildNodeView):
|
||||||
|
|
||||||
return make_json_response(
|
return make_json_response(
|
||||||
success=1,
|
success=1,
|
||||||
info=_("Package dropped"),
|
info=_("Packge dropped"),
|
||||||
data={
|
data={
|
||||||
'id': pkgid,
|
'id': pkgid,
|
||||||
'scid': scid,
|
'scid': scid,
|
||||||
|
@ -517,9 +517,8 @@ class PackageView(PGChildNodeView):
|
||||||
u'name'
|
u'name'
|
||||||
]
|
]
|
||||||
|
|
||||||
data['schema'] = self.schema
|
|
||||||
|
|
||||||
if pkgid is not None:
|
if pkgid is not None:
|
||||||
|
data['schema'] = self.schema
|
||||||
SQL = render_template("/".join([self.template_path, 'properties.sql']), scid=scid, pkgid=pkgid)
|
SQL = render_template("/".join([self.template_path, 'properties.sql']), scid=scid, pkgid=pkgid)
|
||||||
status, res = self.conn.execute_dict(SQL)
|
status, res = self.conn.execute_dict(SQL)
|
||||||
if not status:
|
if not status:
|
||||||
|
|
|
@ -85,6 +85,17 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||||
acl: undefined,
|
acl: undefined,
|
||||||
pkgacl: []
|
pkgacl: []
|
||||||
},
|
},
|
||||||
|
initialize: function(attrs, args) {
|
||||||
|
if (_.size(attrs) === 0) {
|
||||||
|
var userInfo = pgBrowser.serverInfo[args.node_info.server._id].user;
|
||||||
|
var schemaInfo = args.node_info.schema;
|
||||||
|
|
||||||
|
this.set({
|
||||||
|
'owner': userInfo.name, 'schema': schemaInfo._label
|
||||||
|
}, {silent: true});
|
||||||
|
}
|
||||||
|
pgAdmin.Browser.Node.Model.prototype.initialize.apply(this, arguments);
|
||||||
|
},
|
||||||
// Define the schema for package node.
|
// Define the schema for package node.
|
||||||
schema: [{
|
schema: [{
|
||||||
id: 'name', label: '{{ _('Name') }}', cell: 'string',
|
id: 'name', label: '{{ _('Name') }}', cell: 'string',
|
||||||
|
@ -101,6 +112,17 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||||
disabled: true, editable: false, visible: function(m) {
|
disabled: true, editable: false, visible: function(m) {
|
||||||
return !m.isNew();
|
return !m.isNew();
|
||||||
}
|
}
|
||||||
|
},{
|
||||||
|
id: 'schema', label:'{{_('Schema')}}', type: 'text', node: 'schema',
|
||||||
|
control: 'node-list-by-name',
|
||||||
|
disabled: function(m) { return !m.isNew(); }, filter: function(d) {
|
||||||
|
// If schema name start with pg_* then we need to exclude them
|
||||||
|
if(d && d.label.match(/^pg_/))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}, cache_node: 'database', cache_level: 'database'
|
||||||
},{
|
},{
|
||||||
id: 'is_sys_object', label: '{{ _('System package?') }}',
|
id: 'is_sys_object', label: '{{ _('System package?') }}',
|
||||||
cell:'boolean', type: 'switch',mode: ['properties']
|
cell:'boolean', type: 'switch',mode: ['properties']
|
||||||
|
|
|
@ -140,7 +140,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}, cache_node: 'database', cache_level: 'database'
|
||||||
},{
|
},{
|
||||||
id: 'comment', label:'{{ _('Comment') }}', type: 'multiline',
|
id: 'comment', label:'{{ _('Comment') }}', type: 'multiline',
|
||||||
mode: ['properties', 'create', 'edit']
|
mode: ['properties', 'create', 'edit']
|
||||||
|
|
|
@ -83,12 +83,13 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||||
id: 'owner', label:'{{ _('Owner') }}', cell: 'string',
|
id: 'owner', label:'{{ _('Owner') }}', cell: 'string',
|
||||||
type: 'text', mode: ['properties', 'create', 'edit'],
|
type: 'text', mode: ['properties', 'create', 'edit'],
|
||||||
disabled: true , control: 'node-list-by-name',
|
disabled: true , control: 'node-list-by-name',
|
||||||
node: 'role'
|
node: 'role', visible: false
|
||||||
},{
|
},{
|
||||||
id: 'schema', label:'{{ _('Schema') }}', cell: 'string',
|
id: 'schema', label:'{{ _('Schema') }}', cell: 'string',
|
||||||
type: 'text', mode: ['properties', 'create', 'edit'],
|
type: 'text', mode: ['properties', 'create', 'edit'],
|
||||||
disabled: true , control: 'node-list-by-name',
|
disabled: function(m) { return !m.isNew(); }, node: 'schema',
|
||||||
node: 'schema'
|
control: 'node-list-by-name', cache_node: 'database',
|
||||||
|
cache_level: 'database'
|
||||||
},{
|
},{
|
||||||
id: 'targettype', label:'{{ _('Target type') }}', cell: 'string',
|
id: 'targettype', label:'{{ _('Target type') }}', cell: 'string',
|
||||||
disabled: 'inSchema', group: '{{ _('Definition') }}',
|
disabled: 'inSchema', group: '{{ _('Definition') }}',
|
||||||
|
|
|
@ -276,15 +276,15 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||||
},
|
},
|
||||||
// Default values!
|
// Default values!
|
||||||
initialize: function(attrs, args) {
|
initialize: function(attrs, args) {
|
||||||
var self = this,
|
var self = this;
|
||||||
isNew = (_.size(attrs) === 0);
|
|
||||||
|
|
||||||
if (isNew) {
|
if (_.size(attrs) === 0) {
|
||||||
var userInfo = pgBrowser.serverInfo[args.node_info.server._id].user;
|
var userInfo = pgBrowser.serverInfo[args.node_info.server._id].user,
|
||||||
var schemaInfo = args.node_info.schema;
|
schemaInfo = args.node_info.schema;
|
||||||
|
|
||||||
this.set({'relowner': userInfo.name}, {silent: true});
|
this.set({
|
||||||
this.set({'schema': schemaInfo._label}, {silent: true});
|
'relowner': userInfo.name, 'schema': schemaInfo._label
|
||||||
|
}, {silent: true});
|
||||||
}
|
}
|
||||||
pgBrowser.Node.Model.prototype.initialize.apply(this, arguments);
|
pgBrowser.Node.Model.prototype.initialize.apply(this, arguments);
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}, cache_node: 'database', cache_level: 'database'
|
||||||
},{
|
},{
|
||||||
id: 'spcname', label:'{{ _('Tablespace') }}', node: 'tablespace',
|
id: 'spcname', label:'{{ _('Tablespace') }}', node: 'tablespace',
|
||||||
type: 'text', control: 'node-list-by-name', disabled: 'inSchema',
|
type: 'text', control: 'node-list-by-name', disabled: 'inSchema',
|
||||||
|
|
|
@ -304,14 +304,13 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Backgrid) {
|
||||||
|
|
||||||
// Default values!
|
// Default values!
|
||||||
initialize: function(attrs, args) {
|
initialize: function(attrs, args) {
|
||||||
var isNew = (_.size(attrs) === 0);
|
if (_.size(attrs) === 0) {
|
||||||
|
var userInfo = pgBrowser.serverInfo[args.node_info.server._id].user,
|
||||||
|
schemaInfo = args.node_info.schema;
|
||||||
|
|
||||||
if (isNew) {
|
this.set({
|
||||||
var userInfo = pgBrowser.serverInfo[args.node_info.server._id].user;
|
'typeowner': userInfo.name, 'schema': schemaInfo._label
|
||||||
var schemaInfo = args.node_info.schema;
|
}, {silent: true});
|
||||||
|
|
||||||
this.set({'typeowner': userInfo.name}, {silent: true});
|
|
||||||
this.set({'schema': schemaInfo._label}, {silent: true});
|
|
||||||
}
|
}
|
||||||
pgBrowser.Node.Model.prototype.initialize.apply(this, arguments);
|
pgBrowser.Node.Model.prototype.initialize.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
@ -338,7 +337,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify, Backgrid) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
}, cache_node: 'database', cache_level: 'database',
|
||||||
control: 'node-list-by-name', select2: {allowClear: false}
|
control: 'node-list-by-name', select2: {allowClear: false}
|
||||||
},{
|
},{
|
||||||
id: 'typtype', label:'{{ _('Type') }}',
|
id: 'typtype', label:'{{ _('Type') }}',
|
||||||
|
|
|
@ -115,19 +115,13 @@ function($, _, S, pgAdmin, alertify, pgBrowser, CodeMirror) {
|
||||||
*/
|
*/
|
||||||
model: pgBrowser.Node.Model.extend({
|
model: pgBrowser.Node.Model.extend({
|
||||||
initialize: function(attrs, args) {
|
initialize: function(attrs, args) {
|
||||||
var isNew = (_.size(attrs) === 0);
|
if (_.size(attrs) === 0) {
|
||||||
if (isNew) {
|
// Set Selected Schema and Current User
|
||||||
// Set Selected Schema
|
var schemaLabel = args.node_info.schema._label || 'public',
|
||||||
var schemaLabel = args.node_info.schema._label;
|
userInfo = pgBrowser.serverInfo[args.node_info.server._id].user;
|
||||||
if (schemaLabel == '') {
|
this.set({
|
||||||
this.set({'schema': 'public'}, {silent: true});
|
'schema': 'public', 'owner': userInfo.name
|
||||||
} else {
|
}, {silent: true});
|
||||||
this.set({'schema': schemaLabel}, {silent: true});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set Current User
|
|
||||||
var userInfo = pgBrowser.serverInfo[args.node_info.server._id].user;
|
|
||||||
this.set({'owner': userInfo.name}, {silent: true});
|
|
||||||
}
|
}
|
||||||
pgBrowser.Node.Model.prototype.initialize.apply(this, arguments);
|
pgBrowser.Node.Model.prototype.initialize.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
@ -149,7 +143,8 @@ function($, _, S, pgAdmin, alertify, pgBrowser, CodeMirror) {
|
||||||
},{
|
},{
|
||||||
id: 'schema', label:'{{ _("Schema") }}', cell: 'string', first_empty: false,
|
id: 'schema', label:'{{ _("Schema") }}', cell: 'string', first_empty: false,
|
||||||
control: 'node-list-by-name', type: 'text', cache_level: 'database',
|
control: 'node-list-by-name', type: 'text', cache_level: 'database',
|
||||||
node: 'schema', mode: ['create', 'edit'], disabled: 'inSchema', select2: { allowClear: false }
|
node: 'schema', mode: ['create', 'edit'], cache_node: 'database',
|
||||||
|
disabled: 'inSchema', select2: { allowClear: false }
|
||||||
},{
|
},{
|
||||||
id: 'system_view', label:'{{ _("System view?") }}', cell: 'string',
|
id: 'system_view', label:'{{ _("System view?") }}', cell: 'string',
|
||||||
type: 'switch', disabled: true, mode: ['properties'],
|
type: 'switch', disabled: true, mode: ['properties'],
|
||||||
|
|
|
@ -89,19 +89,13 @@ function($, _, S, pgAdmin, pgBrowser, CodeMirror) {
|
||||||
*/
|
*/
|
||||||
model: pgBrowser.Node.Model.extend({
|
model: pgBrowser.Node.Model.extend({
|
||||||
initialize: function(attrs, args) {
|
initialize: function(attrs, args) {
|
||||||
var isNew = (_.size(attrs) === 0);
|
if (_.size(attrs) === 0) {
|
||||||
if (isNew) {
|
// Set Selected Schema and, Current User
|
||||||
// Set Selected Schema
|
var schemaLabel = args.node_info.schema._label || 'public',
|
||||||
var schemaLabel = args.node_info.schema._label;
|
userInfo = pgBrowser.serverInfo[args.node_info.server._id].user;
|
||||||
if (schemaLabel == '') {
|
this.set({
|
||||||
this.set({'schema': 'public'}, {silent: true});
|
'schema': schemaLabel, 'owner': userInfo.name
|
||||||
} else {
|
}, {silent: true});
|
||||||
this.set({'schema': schemaLabel}, {silent: true});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set Current User
|
|
||||||
var userInfo = pgBrowser.serverInfo[args.node_info.server._id].user;
|
|
||||||
this.set({'owner': userInfo.name}, {silent: true});
|
|
||||||
}
|
}
|
||||||
pgBrowser.Node.Model.prototype.initialize.apply(this, arguments);
|
pgBrowser.Node.Model.prototype.initialize.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
@ -117,7 +111,9 @@ function($, _, S, pgAdmin, pgBrowser, CodeMirror) {
|
||||||
},{
|
},{
|
||||||
id: 'schema', label:'{{ _("Schema") }}', cell: 'string', first_empty: false,
|
id: 'schema', label:'{{ _("Schema") }}', cell: 'string', first_empty: false,
|
||||||
control: 'node-list-by-name', type: 'text', cache_level: 'database',
|
control: 'node-list-by-name', type: 'text', cache_level: 'database',
|
||||||
node: 'schema', disabled: 'notInSchema', mode: ['create', 'edit'], select2: { allowClear: false }
|
node: 'schema', disabled: 'notInSchema', mode: ['create', 'edit'],
|
||||||
|
select2: { allowClear: false }, cache_node: 'database',
|
||||||
|
cache_level: 'database'
|
||||||
},{
|
},{
|
||||||
id: 'system_view', label:'{{ _("System view?") }}', cell: 'string',
|
id: 'system_view', label:'{{ _("System view?") }}', cell: 'string',
|
||||||
type: 'switch', disabled: true, mode: ['properties']
|
type: 'switch', disabled: true, mode: ['properties']
|
||||||
|
|
Loading…
Reference in New Issue