public inbox for [email protected]  
help / color / mirror / Atom feed
From: Pradip Parkale <[email protected]>
To: Akshay Joshi <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [pgAdmin][SonarQube] : Remove duplicates string literals.
Date: Thu, 3 Sep 2020 19:19:09 +0530
Message-ID: <CAJ9T6Ss3trXEnFPTwi+BV0JGLjxN8-D3YsjtsnE7-MFSzN0_EA@mail.gmail.com> (raw)
In-Reply-To: <CANxoLDduNdt4Uyz-mxUHMLhVd9jKzmKvUNmWg4m0nzjwQq4j8w@mail.gmail.com>
References: <CAJ9T6SvWCLEOctFXnynEefeo-df40RoE-m6JjCqjvOPXzJ01fg@mail.gmail.com>
	<CANxoLDduNdt4Uyz-mxUHMLhVd9jKzmKvUNmWg4m0nzjwQq4j8w@mail.gmail.com>

Hi Akshay,

Please find the updated patch.


On Thu, Sep 3, 2020 at 6:24 PM Akshay Joshi <[email protected]>
wrote:

> Hi Pradip
>
> Following are the review comments:
>
>    - ROLE_NOT_FOUND already in wrapped in gettext() then no need to use
>    like gone(_(ROLE_NOT_FOUND)). In fact, can we use
>
>    self.not_found_error_msg()instead of new constant.
>
>    - Same with ERROR_FETCHING_ROLE_INFORMATION it's already in gettext,
>    also we can use this constant for string "
>
>    Error retrieving roles from the database server"
>
>
>
> On Thu, Sep 3, 2020 at 4:30 PM Pradip Parkale <
> [email protected]> wrote:
>
>> Hi Hackers,
>>
>> Attached is a patch for removing duplicates string literals.
>>         /server_groups/servers/roles/__init__.py  - 8 places
>>
>>
>>
>> --
>> Thanks & Regards,
>> Pradip Parkale
>> Software Engineer | EnterpriseDB Corporation
>>
>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
> *pgAdmin Hacker | Sr. Software Architect*
> *EDB Postgres <http://edbpostgres.com>*
>
> *Mobile: +91 976-788-8246*
>


-- 
Thanks & Regards,
Pradip Parkale
Software Engineer | EnterpriseDB Corporation


Attachments:

  [application/octet-stream] sonar_Qube_v2.patch (6.5K, 3-sonar_Qube_v2.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/roles/__init__.py b/web/pgadmin/browser/server_groups/servers/roles/__init__.py
index 5c78c09ee..314cba7d7 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/roles/__init__.py
@@ -20,6 +20,7 @@ from pgadmin.utils.ajax import make_json_response, \
     make_response as ajax_response, precondition_required, \
     internal_server_error, forbidden, success_return, gone
 from pgadmin.utils.driver import get_driver
+from pgadmin.utils.constants import ERROR_FETCHING_ROLE_INFORMATION
 
 from config import PG_DEFAULT_DRIVER
 
@@ -111,6 +112,10 @@ class RoleView(PGChildNodeView):
         'variables': [{'get': 'variables'}],
     })
 
+    @staticmethod
+    def not_found_error_message():
+        return "Could not find the role information."
+
     def _validate_input_dict_for_new(self, data, req_keys):
         """
         This functions validates the input dict and check for required
@@ -619,10 +624,7 @@ rolmembership:{
 
         if not status:
             return internal_server_error(
-                _(
-                    "Error retrieving roles from the database server.\n{0}"
-                ).format(res)
-            )
+                _(ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(res))
 
         self.transform(res)
 
@@ -640,11 +642,7 @@ rolmembership:{
 
         if not status:
             return internal_server_error(
-                _(
-                    "Error fetching role information from the database "
-                    "server.\n{0}"
-                ).format(rset)
-            )
+                _(ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(rset))
 
         res = []
         for row in rset['rows']:
@@ -676,10 +674,7 @@ rolmembership:{
         if not status:
             return internal_server_error(
                 _(
-                    "Error fetching role information from the database "
-                    "server.\n{0}"
-                ).format(rset)
-            )
+                    ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(rset))
 
         for row in rset['rows']:
             return make_json_response(
@@ -693,7 +688,7 @@ rolmembership:{
                 status=200
             )
 
-        return gone(_("Could not find the role information."))
+        return gone(_(self.not_found_error_message()))
 
     def transform(self, rset):
         for row in rset['rows']:
@@ -729,14 +724,11 @@ rolmembership:{
 
         if not status:
             return internal_server_error(
-                _(
-                    "Error retrieving roles from the database server.\n{0}"
-                ).format(res)
-            )
+                _(ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(res))
 
         self.transform(res)
         if len(res['rows']) == 0:
-            return gone(_("Could not find the role information."))
+            return gone(_(self.not_found_error_message()))
 
         res['rows'][0]['is_sys_obj'] = (
             res['rows'][0]['oid'] <= self.datlastsysoid)
@@ -841,8 +833,7 @@ rolmembership:{
 
         if not status:
             return internal_server_error(
-                _("Could not retrieve the role information.\n{0}").format(msg)
-            )
+                _(ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(msg))
 
         status, rset = self.conn.execute_dict(
             render_template(self.sql_path + self._NODES_SQL,
@@ -853,10 +844,7 @@ rolmembership:{
         if not status:
             return internal_server_error(
                 _(
-                    "Error fetching role information from the database "
-                    "server.\n{0}"
-                ).format(rset)
-            )
+                    ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(rset))
         for row in rset['rows']:
             return jsonify(
                 node=self.blueprint.generate_browser_node(
@@ -867,7 +855,7 @@ rolmembership:{
                 )
             )
 
-        return gone(_("Could not find the role information."))
+        return gone(_(self.not_found_error_message()))
 
     @check_precondition(action='update')
     @validate_request
@@ -900,11 +888,7 @@ rolmembership:{
 
         if not status:
             return internal_server_error(
-                _(
-                    "Error fetching role information from the database "
-                    "server.\n{0}"
-                ).format(rset)
-            )
+                _(ERROR_FETCHING_ROLE_INFORMATION + "\n{0}").format(rset))
 
         for row in rset['rows']:
             return jsonify(
@@ -917,7 +901,7 @@ rolmembership:{
                 )
             )
 
-        return gone(_("Could not find the role information."))
+        return gone(_(self.not_found_error_message()))
 
     @check_precondition(action='msql')
     @validate_request
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/server.js b/web/pgadmin/browser/server_groups/servers/static/js/server.js
index 9170e0d44..e48524924 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/server.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/server.js
@@ -744,7 +744,6 @@ define('pgadmin.node.server', [
         // Default values!
         initialize: function(attrs, args) {
           var isNew = (_.size(attrs) === 0);
-          console.warn('warn');
 
           if (isNew) {
             this.set({'gid': args.node_info['server_group']._id});
diff --git a/web/pgadmin/utils/constants.py b/web/pgadmin/utils/constants.py
index 88ae50de2..79ed661fb 100644
--- a/web/pgadmin/utils/constants.py
+++ b/web/pgadmin/utils/constants.py
@@ -29,3 +29,7 @@ PGADMIN_NODE = 'pgadmin.node.%s'
 UNAUTH_REQ = "Unauthorized request."
 SERVER_CONNECTION_CLOSED = gettext(
     'Not connected to server or connection with the server has been closed.')
+
+# Role module constant
+ERROR_FETCHING_ROLE_INFORMATION = \
+    "Error fetching role information from the database server."
diff --git a/web/regression/python_test_utils/test_utils.py b/web/regression/python_test_utils/test_utils.py
index 022856c0c..43be73820 100644
--- a/web/regression/python_test_utils/test_utils.py
+++ b/web/regression/python_test_utils/test_utils.py
@@ -1681,8 +1681,7 @@ def get_test_user(self, user_details,
 
 def create_user_wise_test_client(user):
     """
-    This function creates new test client and pem database connection as per
-    provided user and execute the test cases.
+    This function creates new test client and execute the test cases.
     :return: None
     """
 


view thread (4+ 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], [email protected]
  Subject: Re: [pgAdmin][SonarQube] : Remove duplicates string literals.
  In-Reply-To: <CAJ9T6Ss3trXEnFPTwi+BV0JGLjxN8-D3YsjtsnE7-MFSzN0_EA@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