public inbox for [email protected]  
help / color / mirror / Atom feed
From: Akshay Joshi <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgadmin4][Patch]: RM #3361 Create database dialog does not show template0 and template1 database in Template dropdown
Date: Mon, 18 Jun 2018 19:08:01 +0530
Message-ID: <CANxoLDe3z5BpjSv=B8694Cey+q_LVFPd5Q+_HqzyiaqdjCfzrg@mail.gmail.com> (raw)

Hi Hackers,

Attached is the patch for RM #3361 Create database dialog does not show
template0 and template1 database in Template drop down.

-- 
*Akshay Joshi*

*Sr. Software Architect *



*Phone: +91 20-3058-9517Mobile: +91 976-788-8246*


Attachments:

  [application/octet-stream] RM_3361.patch (1.9K, 3-RM_3361.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
index 4590d6c..8d8133a 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
@@ -301,7 +301,26 @@ class DatabaseView(PGChildNodeView):
 
     @check_precondition(action="get_databases")
     def get_databases(self, gid, sid):
-        res = self.get_nodes(gid, sid, True)
+        """
+        This function is used to get all the databases irrespective of
+        show_system_object flag for templates in create database dialog.
+        :param gid:
+        :param sid:
+        :return:
+        """
+        res = []
+        SQL = render_template(
+            "/".join([self.template_path, 'nodes.sql']),
+            last_system_oid=0,
+        )
+        status, rset = self.conn.execute_dict(SQL)
+
+        if not status:
+            return internal_server_error(errormsg=rset)
+
+        for row in rset['rows']:
+            res.append(row['name'])
+
         return make_json_response(
             data=res,
             status=200
diff --git a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
index 2da27a3..1bb6759 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/static/js/database.js
@@ -340,7 +340,7 @@ define('pgadmin.node.database', [
             else {
               if (data && _.isArray(data)) {
                 _.each(data, function(d) {
-                  res.push({label: d.label, value: d.label,
+                  res.push({label: d, value: d,
                     image: 'pg-icon-database'});
                 });
               }


view thread (2+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [pgadmin4][Patch]: RM #3361 Create database dialog does not show template0 and template1 database in Template dropdown
  In-Reply-To: <CANxoLDe3z5BpjSv=B8694Cey+q_LVFPd5Q+_HqzyiaqdjCfzrg@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox