Hi,

Please find the attached updated patch.

On Fri, Nov 18, 2016 at 7:45 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Fri, Nov 18, 2016 at 1:03 PM, Khushboo Vashi
> <khushboo.va...@enterprisedb.com> wrote:
> > Hi,
> >
> > Please find the attached patch for RM #1801: Properly handle databases
> with
> > datallowconn == false.
> >
> > Issue: While connecting the database, allowconn parameter was not in
> > consideration.  Also, the database properties query call was on the
> selected
> > database which was not correct.
> >
> > Fix: Put the check of  allowconn, while connecting the database in JS
> file.
> > Also, the database properties query call set to the maintenance database.
>
> All good, but this is just infrastructure for what's really required;
> i.e. disabling menu options to do things like backups, run the query
> tool etc. (anything that needs a connection). Can you resolve that
> please?
>
>
Fixed


> Thanks.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/browser/collection.py b/web/pgadmin/browser/collection.py
index e4a83a2..391ccf9 100644
--- a/web/pgadmin/browser/collection.py
+++ b/web/pgadmin/browser/collection.py
@@ -66,7 +66,7 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
             "id": "%s/%s" % (self.node_type, node_id),
             "label": label,
             "icon": self.node_icon if not icon else icon,
-            "inode": self.node_inode,
+            "inode": self.node_inode if 'inode' not in kwargs else kwargs['inode'],
             "_type": self.node_type,
             "_id": node_id,
             "_pid": parent_id,
diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
index ed08ef6..e4401a7 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
@@ -214,7 +214,8 @@ class DatabaseView(PGChildNodeView):
                     allowConn=row['datallowconn'],
                     canCreate=row['cancreate'],
                     canDisconn=canDisConn,
-                    canDrop = canDrop
+                    canDrop=canDrop,
+                    inode=True if row['datallowconn'] else False
                 )
             )
 
@@ -276,11 +277,13 @@ class DatabaseView(PGChildNodeView):
 
     @check_precondition(action="properties")
     def properties(self, gid, sid, did):
+        conn = self.manager.connection()
+
         SQL = render_template(
             "/".join([self.template_path, 'properties.sql']),
-            did=did, conn=self.conn, last_system_oid=0
+            did=did, conn=conn, last_system_oid=0
         )
-        status, res = self.conn.execute_dict(SQL)
+        status, res = conn.execute_dict(SQL)
 
         if len(res['rows']) == 0:
             return gone(
@@ -292,9 +295,9 @@ class DatabaseView(PGChildNodeView):
 
         SQL = render_template(
             "/".join([self.template_path, 'acl.sql']),
-            did=did, conn=self.conn
+            did=did, conn=conn
         )
-        status, dataclres = self.conn.execute_dict(SQL)
+        status, dataclres = conn.execute_dict(SQL)
         if not status:
             return internal_server_error(errormsg=res)
 
@@ -302,9 +305,9 @@ class DatabaseView(PGChildNodeView):
 
         SQL = render_template(
             "/".join([self.template_path, 'defacl.sql']),
-            did=did, conn=self.conn
+            did=did, conn=conn
         )
-        status, defaclres = self.conn.execute_dict(SQL)
+        status, defaclres = conn.execute_dict(SQL)
         if not status:
             return internal_server_error(errormsg=res)
 
@@ -314,10 +317,10 @@ class DatabaseView(PGChildNodeView):
         # Fetching variable for database
         SQL = render_template(
             "/".join([self.template_path, 'get_variables.sql']),
-            did=did, conn=self.conn
+            did=did, conn=conn
         )
 
-        status, res1 = self.conn.execute_dict(SQL)
+        status, res1 = conn.execute_dict(SQL)
 
         if not status:
             return internal_server_error(errormsg=res1)
@@ -535,12 +538,13 @@ class DatabaseView(PGChildNodeView):
             request.data, encoding='utf-8'
         )
 
+        conn = self.manager.connection()
         if did is not None:
             # Fetch the name of database for comparison
-            status, rset = self.conn.execute_dict(
+            status, rset = conn.execute_dict(
                 render_template(
                     "/".join([self.template_path, 'nodes.sql']),
-                    did=did, conn=self.conn, last_system_oid=0
+                    did=did, conn=conn, last_system_oid=0
                 )
             )
             if not status:
@@ -556,7 +560,6 @@ class DatabaseView(PGChildNodeView):
                 data['name'] = data['old_name']
 
         status = self.manager.release(did=did)
-        conn = self.manager.connection()
         for action in ["rename_database", "tablespace"]:
             SQL = self.get_offline_sql(gid, sid, data, did, action)
             SQL = SQL.strip('\n').strip(' ')
@@ -565,6 +568,18 @@ class DatabaseView(PGChildNodeView):
                 if not status:
                     return internal_server_error(errormsg=msg)
 
+        if not self.manager.db_info[did]['datallowconn']:
+            return jsonify(
+                node=self.blueprint.generate_browser_node(
+                    did,
+                    sid,
+                    data['name'],
+                    "icon-database-not-connected",
+                    connected=False,
+                    allowConn=False
+                )
+            )
+
         self.conn = self.manager.connection(database=data['name'], auto_reconnect=True)
         status, errmsg = self.conn.connect()
 
@@ -655,10 +670,11 @@ class DatabaseView(PGChildNodeView):
         SQL = ''
         if did is not None:
             # Fetch the name of database for comparison
-            status, rset = self.conn.execute_dict(
+            conn = self.manager.connection()
+            status, rset = conn.execute_dict(
                 render_template(
                     "/".join([self.template_path, 'nodes.sql']),
-                    did=did, conn=self.conn, last_system_oid=0
+                    did=did, conn=conn, last_system_oid=0
                 )
             )
             if not status:
@@ -677,7 +693,8 @@ class DatabaseView(PGChildNodeView):
             for action in ["rename_database", "tablespace"]:
                 SQL += self.get_offline_sql(gid, sid, data, did, action)
 
-            SQL += self.get_online_sql(gid, sid, data, did)
+            if rset['rows'][0]['datallowconn']:
+                SQL += self.get_online_sql(gid, sid, data, did)
         else:
             SQL += self.get_new_sql(gid, sid, data, did)
 
@@ -696,31 +713,37 @@ class DatabaseView(PGChildNodeView):
                 return _(" -- definition incomplete")
 
         acls = []
-        try:
-            acls = render_template(
-                "/".join([self.template_path, 'allowed_privs.json'])
-            )
-            acls = json.loads(acls, encoding='utf-8')
-        except Exception as e:
-            current_app.logger.exception(e)
+        SQL_acl = ''
 
-        # Privileges
-        for aclcol in acls:
-            if aclcol in data:
-                allowedacl = acls[aclcol]
-                data[aclcol] = parse_priv_to_db(
-                    data[aclcol], allowedacl['acl']
+        if data['datallowconn']:
+            try:
+                acls = render_template(
+                    "/".join([self.template_path, 'allowed_privs.json'])
                 )
+                acls = json.loads(acls, encoding='utf-8')
+            except Exception as e:
+                current_app.logger.exception(e)
+
+            # Privileges
+            for aclcol in acls:
+                if aclcol in data:
+                    allowedacl = acls[aclcol]
+                    data[aclcol] = parse_priv_to_db(
+                        data[aclcol], allowedacl['acl']
+                    )
+
+            SQL_acl = render_template(
+                        "/".join([self.template_path, 'grant.sql']),
+                        data=data, conn=self.conn
+                    )
 
+        conn = self.manager.connection()
         SQL = render_template(
             "/".join([self.template_path, 'create.sql']),
-            data=data, conn=self.conn
+            data=data, conn=conn
         )
         SQL += "\n"
-        SQL += render_template(
-            "/".join([self.template_path, 'grant.sql']),
-            data=data, conn=self.conn
-        )
+        SQL += SQL_acl
         return SQL
 
     def get_online_sql(self, gid, sid, data, did=None):
@@ -812,52 +835,56 @@ class DatabaseView(PGChildNodeView):
         """
         This function will generate sql for sql panel
         """
+
+        conn = self.manager.connection()
         SQL = render_template(
             "/".join([self.template_path, 'properties.sql']),
-            did=did, conn=self.conn, last_system_oid=0
+            did=did, conn=conn, last_system_oid=0
         )
-        status, res = self.conn.execute_dict(SQL)
+        status, res = conn.execute_dict(SQL)
         if not status:
             return internal_server_error(errormsg=res)
 
-        SQL = render_template(
-            "/".join([self.template_path, 'acl.sql']),
-            did=did, conn=self.conn
-        )
-        status, dataclres = self.conn.execute_dict(SQL)
-        if not status:
-            return internal_server_error(errormsg=res)
-        res = self.formatdbacl(res, dataclres['rows'])
+        if res['rows'][0]['datallowconn']:
+            SQL = render_template(
+                "/".join([self.template_path, 'acl.sql']),
+                did=did, conn=self.conn
+            )
+            status, dataclres = self.conn.execute_dict(SQL)
+            if not status:
+                return internal_server_error(errormsg=dataclres)
+            res = self.formatdbacl(res, dataclres['rows'])
 
-        SQL = render_template(
-            "/".join([self.template_path, 'defacl.sql']),
-            did=did, conn=self.conn
-        )
-        status, defaclres = self.conn.execute_dict(SQL)
-        if not status:
-            return internal_server_error(errormsg=res)
+            SQL = render_template(
+                "/".join([self.template_path, 'defacl.sql']),
+                did=did, conn=self.conn
+            )
+            status, defaclres = self.conn.execute_dict(SQL)
+            if not status:
+                return internal_server_error(errormsg=defaclres)
 
-        res = self.formatdbacl(res, defaclres['rows'])
+            res = self.formatdbacl(res, defaclres['rows'])
 
         result = res['rows'][0]
 
-        SQL = render_template(
-            "/".join([self.template_path, 'get_variables.sql']),
-            did=did, conn=self.conn
-        )
-        status, res1 = self.conn.execute_dict(SQL)
-        if not status:
-            return internal_server_error(errormsg=res1)
+        if result['datallowconn']:
+            SQL = render_template(
+                "/".join([self.template_path, 'get_variables.sql']),
+                did=did, conn=self.conn
+            )
+            status, res1 = self.conn.execute_dict(SQL)
+            if not status:
+                return internal_server_error(errormsg=res1)
 
-        # Get Formatted Security Labels
-        if 'seclabels' in result:
-            # Security Labels is not available for PostgreSQL <= 9.1
-            frmtd_sec_labels = parse_sec_labels_from_db(result['seclabels'])
-            result.update(frmtd_sec_labels)
+            # Get Formatted Security Labels
+            if 'seclabels' in result:
+                # Security Labels is not available for PostgreSQL <= 9.1
+                frmtd_sec_labels = parse_sec_labels_from_db(result['seclabels'])
+                result.update(frmtd_sec_labels)
 
-        # Get Formatted Variables
-        frmtd_variables = parse_variables_from_db(res1['rows'])
-        result.update(frmtd_variables)
+            # Get Formatted Variables
+            frmtd_variables = parse_variables_from_db(res1['rows'])
+            result.update(frmtd_variables)
 
         sql_header = "-- Database: {0}\n\n-- ".format(result['name'])
         if hasattr(str, 'decode'):
@@ -865,7 +892,7 @@ class DatabaseView(PGChildNodeView):
 
         sql_header += render_template(
             "/".join([self.template_path, 'delete.sql']),
-            datname=result['name'], conn=self.conn
+            datname=result['name'], conn=conn
         )
 
         SQL = self.get_new_sql(gid, sid, result, did)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.4_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.4_plus/sql/update.sql
index 647711c..4235f5c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.4_plus/sql/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.4_plus/sql/update.sql
@@ -19,7 +19,7 @@ ALTER TABLE {{ conn|qtIdent(view_schema, view_name) }}
 {% endif %}
 {% if def and def != o_data.definition.rstrip(';') %}
 CREATE OR REPLACE VIEW {{ conn|qtIdent(view_schema, view_name) }}
-    WITH (check_option={{ data.check_option|default('no', 'true') if data.check_option else o_data.check_option|default('no', 'true') }}{{', ' }}security_barrier={{ data.security_barrier|lower if data.security_barrier else o_data.security_barrier|default('false', 'true')|lower }})
+    WITH ({% if (data.check_option or o_data.check_option) %}check_option={{ data.check_option if data.check_option else o_data.check_option }}{{', ' }}{% endif %}security_barrier={{ data.security_barrier|lower if data.security_barrier else o_data.security_barrier|default('false', 'true')|lower }})
     AS
     {{ def }};
 {% else %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.4_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.4_plus/sql/update.sql
index 647711c..4235f5c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.4_plus/sql/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.4_plus/sql/update.sql
@@ -19,7 +19,7 @@ ALTER TABLE {{ conn|qtIdent(view_schema, view_name) }}
 {% endif %}
 {% if def and def != o_data.definition.rstrip(';') %}
 CREATE OR REPLACE VIEW {{ conn|qtIdent(view_schema, view_name) }}
-    WITH (check_option={{ data.check_option|default('no', 'true') if data.check_option else o_data.check_option|default('no', 'true') }}{{', ' }}security_barrier={{ data.security_barrier|lower if data.security_barrier else o_data.security_barrier|default('false', 'true')|lower }})
+    WITH ({% if (data.check_option or o_data.check_option) %}check_option={{ data.check_option if data.check_option else o_data.check_option }}{{', ' }}{% endif %}security_barrier={{ data.security_barrier|lower if data.security_barrier else o_data.security_barrier|default('false', 'true')|lower }})
     AS
     {{ def }};
 {% else %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
index 47fc273..9c82be5 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
@@ -102,6 +102,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
           }
 
           if (i && d) {
+            if (!d.allowConn) return false;
             if (_.isUndefined(d.is_connecting) || !d.is_connecting) {
               d.is_connecting = true;
 
@@ -229,7 +230,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
           }
 
           pgBrowser.tree.addIcon(item, {icon: data.icon});
-          if (!data.connected) {
+          if (!data.connected && data.allowConn) {
             connect_to_database(this, data, pgBrowser.tree, item, true);
             return false;
           }
@@ -242,13 +243,23 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
           }
 
           pgBrowser.tree.addIcon(item, {icon: data.icon});
-          if (!data.connected) {
+          if (!data.connected && data.allowConn) {
             connect_to_database(this, data, pgBrowser.tree, item, false);
             return false;
           }
 
           return pgBrowser.Node.callbacks.selected.apply(this, arguments);
         },
+
+        refresh: function(cmd, i) {
+          var self = this,
+              t = pgBrowser.tree,
+              item = i || t.selected(),
+              d = t.itemData(item);
+
+          if (!d.allowConn) return;
+          pgBrowser.Node.callbacks.refresh.apply(this, arguments);
+        }
       },
       model: pgBrowser.Node.Model.extend({
         defaults: {
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/alter_offline.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/alter_offline.sql
index afebb6c..6f2b461 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/alter_offline.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/alter_offline.sql
@@ -1,6 +1,20 @@
 {% if data %}
-{% if action == "rename_database" and data.old_name != data.name %}
+{% if action == "rename_database" %} {% if data.old_name != data.name %}
 ALTER DATABASE {{ conn|qtIdent(data.old_name) }} RENAME TO {{ conn|qtIdent(data.name) }};
+{% endif %}
+{# Change the owner #}
+{% if data.datowner %}
+ALTER DATABASE {{ conn|qtIdent(data.name) }} OWNER TO {{ conn|qtIdent(data.datowner) }};
+{% endif %}
+{# Change the comments/description #}
+{% if data.comments is defined %}
+COMMENT ON DATABASE {{ conn|qtIdent(data.name) }}
+    IS {{ data.comments|qtLiteral }};
+{% endif %}
+{# Change the connection limit #}
+{% if data.datconnlimit %}
+ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.datconnlimit }};
+{% endif %}
 {% endif %}{% if action == "tablespace" and  data.spcname %}
 
 ALTER DATABASE {{ conn|qtIdent(data.name) }} SET TABLESPACE {{ conn|qtIdent(data.spcname) }};
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/alter_online.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/alter_online.sql
index e69c9b5..680ab23 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/alter_online.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/alter_online.sql
@@ -3,19 +3,6 @@
 {% import 'macros/privilege.macros' as PRIVILEGE %}
 {% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
 {% if data %}
-{# Change the owner #}
-{% if data.datowner %}
-ALTER DATABASE {{ conn|qtIdent(data.name) }} OWNER TO {{ conn|qtIdent(data.datowner) }};
-{% endif %}
-{# Change the comments/description #}
-{% if data.comments is defined %}
-COMMENT ON DATABASE {{ conn|qtIdent(data.name) }}
-    IS {{ data.comments|qtLiteral }};
-{% endif %}
-{# Change the connection limit #}
-{% if data.datconnlimit %}
-ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.datconnlimit }};
-{% endif %}
 {# Change the variables/options #}
 {% if data.variables and data.variables|length > 0 %}
 {% set variables = data.variables %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/alter_offline.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/alter_offline.sql
index afebb6c..6f2b461 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/alter_offline.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/alter_offline.sql
@@ -1,6 +1,20 @@
 {% if data %}
-{% if action == "rename_database" and data.old_name != data.name %}
+{% if action == "rename_database" %} {% if data.old_name != data.name %}
 ALTER DATABASE {{ conn|qtIdent(data.old_name) }} RENAME TO {{ conn|qtIdent(data.name) }};
+{% endif %}
+{# Change the owner #}
+{% if data.datowner %}
+ALTER DATABASE {{ conn|qtIdent(data.name) }} OWNER TO {{ conn|qtIdent(data.datowner) }};
+{% endif %}
+{# Change the comments/description #}
+{% if data.comments is defined %}
+COMMENT ON DATABASE {{ conn|qtIdent(data.name) }}
+    IS {{ data.comments|qtLiteral }};
+{% endif %}
+{# Change the connection limit #}
+{% if data.datconnlimit %}
+ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.datconnlimit }};
+{% endif %}
 {% endif %}{% if action == "tablespace" and  data.spcname %}
 
 ALTER DATABASE {{ conn|qtIdent(data.name) }} SET TABLESPACE {{ conn|qtIdent(data.spcname) }};
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/alter_online.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/alter_online.sql
index 8d31f29..fd402b2 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/alter_online.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/alter_online.sql
@@ -3,19 +3,6 @@
 {% import 'macros/privilege.macros' as PRIVILEGE %}
 {% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
 {% if data %}
-{# Change the owner #}
-{% if data.datowner %}
-ALTER DATABASE {{ conn|qtIdent(data.name) }} OWNER TO {{ conn|qtIdent(data.datowner) }};
-{% endif %}
-{# Change the comments/description #}
-{% if data.comments is defined %}
-COMMENT ON DATABASE {{ conn|qtIdent(data.name) }}
-    IS {{ data.comments|qtLiteral }};
-{% endif %}
-{# Change the connection limit #}
-{% if data.datconnlimit %}
-ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.datconnlimit }};
-{% endif %}
 {# Change the security labels #}
 {% if data.seclabels and data.seclabels|length > 0 %}
 {% set seclabels = data.seclabels %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/alter_offline.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/alter_offline.sql
index afebb6c..59f9e59 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/alter_offline.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/alter_offline.sql
@@ -1,6 +1,20 @@
 {% if data %}
-{% if action == "rename_database" and data.old_name != data.name %}
+{% if action == "rename_database" %} {% if data.old_name != data.name %}
 ALTER DATABASE {{ conn|qtIdent(data.old_name) }} RENAME TO {{ conn|qtIdent(data.name) }};
+{% endif %}
+{# Change the owner #}
+{% if data.datowner %}
+ALTER DATABASE {{ conn|qtIdent(data.name) }} OWNER TO {{ conn|qtIdent(data.datowner) }};
+{% endif %}
+{# Change the comments/description #}
+{% if data.comments is defined %}
+COMMENT ON DATABASE {{ conn|qtIdent(data.name) }}
+IS {{ data.comments|qtLiteral }};
+{% endif %}
+{# Change the connection limit #}
+{% if data.datconnlimit %}
+ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.datconnlimit }};
+{% endif %}
 {% endif %}{% if action == "tablespace" and  data.spcname %}
 
 ALTER DATABASE {{ conn|qtIdent(data.name) }} SET TABLESPACE {{ conn|qtIdent(data.spcname) }};
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/alter_online.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/alter_online.sql
index 71f516a..7e5e0c3 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/alter_online.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/alter_online.sql
@@ -3,19 +3,6 @@
 {% import 'macros/privilege.macros' as PRIVILEGE %}
 {% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
 {% if data %}
-{# Change the owner #}
-{% if data.datowner %}
-ALTER DATABASE {{ conn|qtIdent(data.name) }} OWNER TO {{ conn|qtIdent(data.datowner) }};
-{% endif %}
-{# Change the comments/description #}
-{% if data.comments is defined %}
-COMMENT ON DATABASE {{ conn|qtIdent(data.name) }}
-IS {{ data.comments|qtLiteral }};
-{% endif %}
-{# Change the connection limit #}
-{% if data.datconnlimit %}
-ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.datconnlimit }};
-{% endif %}
 {# Change the security labels #}
 {% if data.seclabels and data.seclabels|length > 0 %}
 {% set seclabels = data.seclabels %}
diff --git a/web/pgadmin/browser/templates/browser/js/node.js b/web/pgadmin/browser/templates/browser/js/node.js
index f82f04b..7b2b5d3 100644
--- a/web/pgadmin/browser/templates/browser/js/node.js
+++ b/web/pgadmin/browser/templates/browser/js/node.js
@@ -126,7 +126,15 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
             name: 'show_query_tool', node: self.type, module: self,
             applies: ['context'], callback: 'show_query_tool',
             priority: 998, label: '{{ _("Query Tool...") }}',
-            icon: 'fa fa-bolt'
+            icon: 'fa fa-bolt',
+            enable: function(itemData, item, data) {
+              if (itemData._type == 'database' && itemData.allowConn)
+                return true;
+              else if(itemData._type != 'database')
+                return true;
+              else
+                return false;
+            }
           }]);
         }
       }
@@ -164,6 +172,11 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
       if (itemData._type == 'server-group' || itemData._type == 'server') {
         return false;
       }
+
+      // Do not display the menu if the database connection is not allowed
+      if (itemData._type == 'database' && !itemData.allowConn)
+        return false;
+
       var node = pgBrowser.Nodes[itemData._type],
         parentData = node.getTreeNodeHierarchy(item);
       if ( _.indexOf(['create','insert','update', 'delete'], data.script) != -1) {
@@ -960,9 +973,6 @@ function($, _, S, pgAdmin, Menu, Backbone, Alertify, pgBrowser, Backform) {
             // Save it for release it later
             j.data('obj-view', view);
 
-            // Create status bar
-            createStatusBar('footer');
-
             // Create proper buttons
 
             var buttons = [];
diff --git a/web/pgadmin/tools/backup/templates/backup/js/backup.js b/web/pgadmin/tools/backup/templates/backup/js/backup.js
index 9d86386..f1a29d1 100644
--- a/web/pgadmin/tools/backup/templates/backup/js/backup.js
+++ b/web/pgadmin/tools/backup/templates/backup/js/backup.js
@@ -285,11 +285,19 @@ TODO LIST FOR BACKUP:
           var t = pgBrowser.tree, i = item, d = itemData;
           var parent_item = t.hasParent(i) ? t.parent(i): null,
               parent_data = parent_item ? t.itemData(parent_item) : null;
-            if(!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data))
-              return (
-                (_.indexOf(backup_supported_nodes, d._type) !== -1 &&
-                parent_data._type != 'catalog') ? true: false
-              );
+            if(!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data)) {
+                if (_.indexOf(backup_supported_nodes, d._type) !== -1 &&
+                parent_data._type != 'catalog') {
+                    if (d._type == 'database' && d.allowConn)
+                      return true;
+                    else if(d._type != 'database')
+                      return true;
+                    else
+                      return false;
+                }
+                else
+                  return false;
+            }
             else
               return false;
         };
diff --git a/web/pgadmin/tools/datagrid/templates/datagrid/js/datagrid.js b/web/pgadmin/tools/datagrid/templates/datagrid/js/datagrid.js
index 93e9b2f..59d10f5 100644
--- a/web/pgadmin/tools/datagrid/templates/datagrid/js/datagrid.js
+++ b/web/pgadmin/tools/datagrid/templates/datagrid/js/datagrid.js
@@ -56,7 +56,14 @@ define(
          */
         query_tool_menu_enabled = function(obj) {
           if(!_.isUndefined(obj) && !_.isNull(obj))
-            return (_.indexOf(unsupported_nodes, obj._type) !== -1 ? false: true);
+            if(_.indexOf(unsupported_nodes, obj._type) == -1) {
+              if (obj._type == 'database' && obj.allowConn)
+                return true;
+              else if(obj._type != 'database')
+                return true;
+              else
+                return false;
+             }
           else
             return false;
         };
diff --git a/web/pgadmin/tools/grant_wizard/templates/grant_wizard/js/grant_wizard.js b/web/pgadmin/tools/grant_wizard/templates/grant_wizard/js/grant_wizard.js
index 79c02c3..de4b7a3 100644
--- a/web/pgadmin/tools/grant_wizard/templates/grant_wizard/js/grant_wizard.js
+++ b/web/pgadmin/tools/grant_wizard/templates/grant_wizard/js/grant_wizard.js
@@ -155,8 +155,19 @@ define([
               var t = pgBrowser.tree, i = item, d = itemData;
               var parent_item = t.hasParent(i) ? t.parent(i): null,
                   parent_data = parent_item ? t.itemData(parent_item) : null;
-              if(!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data))
-                return ((_.indexOf(supported_nodes, d._type) !== -1 && parent_data._type != 'catalog') ? true: false);
+              if(!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data)) {
+                if (_.indexOf(supported_nodes, d._type) !== -1 &&
+                  parent_data._type != 'catalog') {
+                    if (d._type == 'database' && d.allowConn)
+                      return true;
+                    else if(d._type != 'database')
+                      return true;
+                    else
+                      return false;
+                }
+                else
+                  return false;
+              }
               else
                 return false;
             };
diff --git a/web/pgadmin/tools/maintenance/templates/maintenance/js/maintenance.js b/web/pgadmin/tools/maintenance/templates/maintenance/js/maintenance.js
index 5fcf70c..0466e74 100644
--- a/web/pgadmin/tools/maintenance/templates/maintenance/js/maintenance.js
+++ b/web/pgadmin/tools/maintenance/templates/maintenance/js/maintenance.js
@@ -154,11 +154,19 @@ define(
          var t = pgBrowser.tree, i = item, d = itemData;
          var parent_item = t.hasParent(i) ? t.parent(i): null,
              parent_data = parent_item ? t.itemData(parent_item) : null;
-           if(!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data))
-             return (
-               (_.indexOf(maintenance_supported_nodes, d._type) !== -1 &&
-               parent_data._type != 'catalog') ? true: false
-             );
+           if(!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data)) {
+             if (_.indexOf(maintenance_supported_nodes, d._type) !== -1 &&
+               parent_data._type != 'catalog') {
+               if (d._type == 'database' && d.allowConn)
+                 return true;
+               else if(d._type != 'database')
+                 return true;
+               else
+                 return false;
+              }
+              else
+                return false;
+           }
            else
              return false;
         };
diff --git a/web/pgadmin/tools/restore/templates/restore/js/restore.js b/web/pgadmin/tools/restore/templates/restore/js/restore.js
index 7064fa3..b76927c 100644
--- a/web/pgadmin/tools/restore/templates/restore/js/restore.js
+++ b/web/pgadmin/tools/restore/templates/restore/js/restore.js
@@ -240,11 +240,19 @@ define([
           var t = pgBrowser.tree, i = item, d = itemData;
           var parent_item = t.hasParent(i) ? t.parent(i): null,
               parent_data = parent_item ? t.itemData(parent_item) : null;
-            if(!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data))
-              return (
-                (_.indexOf(restore_supported_nodes, d._type) !== -1 &&
-                is_parent_catalog(itemData, item, data) ) ? true: false
-              );
+            if(!_.isUndefined(d) && !_.isNull(d) && !_.isNull(parent_data)) {
+              if (_.indexOf(restore_supported_nodes, d._type) !== -1 &&
+                is_parent_catalog(itemData, item, data) ) {
+                  if (d._type == 'database' && d.allowConn)
+                    return true;
+                  else if(d._type != 'database')
+                    return true;
+                  else
+                    return false;
+              }
+              else
+                return false;
+            }
             else
               return false;
         };
-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to