public inbox for [email protected]  
help / color / mirror / Atom feed
[pgAdmin4][Patch] - RM 6274 - LDAP auth module is not translatable
2+ messages / 2 participants
[nested] [flat]

* [pgAdmin4][Patch] - RM 6274 - LDAP auth module is not translatable
@ 2021-04-08 11:37  Khushboo Vashi <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Khushboo Vashi @ 2021-04-08 11:37 UTC (permalink / raw)
  To: pgadmin-hackers

Hi,

Please find the attached patch to fix RM #6274 - LDAP auth module is not
translatable.

Thanks,
Khushboo


Attachments:

  [application/octet-stream] RM_6274.patch (5.8K, 3-RM_6274.patch)
  download | inline diff:
diff --git a/web/pgadmin/authenticate/__init__.py b/web/pgadmin/authenticate/__init__.py
index bc0868ddf..9166c2ffd 100644
--- a/web/pgadmin/authenticate/__init__.py
+++ b/web/pgadmin/authenticate/__init__.py
@@ -13,7 +13,6 @@ import flask
 import pickle
 from flask import current_app, flash, Response, request, url_for,\
     render_template
-from flask_babelex import gettext
 from flask_security import current_user
 from flask_security.views import _security, _ctx
 from flask_security.utils import config_value, get_post_logout_redirect, \
@@ -90,7 +89,7 @@ def login():
                 return flask.redirect('{0}?next={1}'.format(url_for(
                     'authenticate.kerberos_login'), url_for('browser.index')))
 
-            flash(gettext(msg), 'danger')
+            flash(msg, 'danger')
             return flask.redirect(get_post_logout_redirect())
 
         session['_auth_source_manager_obj'] = current_auth_obj
@@ -98,7 +97,7 @@ def login():
 
     elif isinstance(msg, Response):
         return msg
-    flash(gettext(msg), 'danger')
+    flash(msg, 'danger')
     response = flask.redirect(get_post_logout_redirect())
     return response
 
diff --git a/web/pgadmin/authenticate/ldap.py b/web/pgadmin/authenticate/ldap.py
index 2f0f61b7c..f53c843cc 100644
--- a/web/pgadmin/authenticate/ldap.py
+++ b/web/pgadmin/authenticate/ldap.py
@@ -26,7 +26,8 @@ from pgadmin.tools.user_management import create_user
 from pgadmin.utils.constants import LDAP
 
 
-ERROR_SEARCHING_LDAP_DIRECTORY = "Error searching the LDAP directory: {}"
+ERROR_SEARCHING_LDAP_DIRECTORY = gettext(
+    "Error searching the LDAP directory: {}")
 
 
 class LDAPAuthentication(BaseAuthentication):
@@ -53,7 +54,8 @@ class LDAPAuthentication(BaseAuthentication):
         self.anonymous_bind = getattr(config, 'LDAP_ANONYMOUS_BIND', False)
 
         if self.bind_user and not self.bind_pass:
-            return False, "LDAP configuration error: Set the bind password."
+            return False, gettext(
+                "LDAP configuration error: Set the bind password.")
 
         # if no dedicated ldap user is configured then use the login
         # username and password
@@ -121,17 +123,17 @@ class LDAPAuthentication(BaseAuthentication):
         except LDAPSocketOpenError as e:
             current_app.logger.exception(
                 "Error connecting to the LDAP server: {}\n".format(e))
-            return False, "Error connecting to the LDAP server:" \
-                          " {}\n".format(e.args[0])
+            return False, gettext("Error connecting to the LDAP server: {}\n"
+                                  ).format(e.args[0])
         except LDAPBindError as e:
             current_app.logger.exception(
                 "Error binding to the LDAP server.")
-            return False, "Error binding to the LDAP server."
+            return False, gettext("Error binding to the LDAP server.")
         except Exception as e:
             current_app.logger.exception(
                 "Error connecting to the LDAP server: {}\n".format(e))
-            return False, "Error connecting to the LDAP server:" \
-                          " {}\n".format(e.args[0])
+            return False, gettext("Error connecting to the LDAP server: {}\n"
+                                  ).format(e.args[0])
 
         # Enable TLS if STARTTLS is configured
         if self.start_tls:
@@ -140,7 +142,8 @@ class LDAPAuthentication(BaseAuthentication):
             except LDAPStartTLSError as e:
                 current_app.logger.exception(
                     "Error starting TLS: {}\n".format(e))
-                return False, "Error starting TLS: {}\n".format(e.args[0])
+                return False, gettext("Error starting TLS: {}\n"
+                                      ).format(e.args[0])
 
         return True, None
 
@@ -179,7 +182,7 @@ class LDAPAuthentication(BaseAuthentication):
         except LDAPSSLConfigurationError as e:
             current_app.logger.exception(
                 "LDAP configuration error: {}\n".format(e))
-            return False, "LDAP configuration error: {}\n".format(
+            return False, gettext("LDAP configuration error: {}\n").format(
                 e.args[0])
         return True, tls
 
@@ -194,7 +197,8 @@ class LDAPAuthentication(BaseAuthentication):
         tls = None
 
         if isinstance(uri, str):
-            return False, "LDAP configuration error: Set the proper LDAP URI."
+            return False, gettext(
+                "LDAP configuration error: Set the proper LDAP URI.")
 
         if uri.scheme == 'ldaps' or config.LDAP_USE_STARTTLS:
             status, tls = self.__configure_tls()
@@ -224,8 +228,8 @@ class LDAPAuthentication(BaseAuthentication):
             search_base_dn = config.LDAP_SEARCH_BASE_DN
             if (not search_base_dn or search_base_dn == '<Search-Base-DN>')\
                     and (self.anonymous_bind or self.dedicated_user):
-                return False, "LDAP configuration error:" \
-                              " Set the Search Domain."
+                return False, gettext("LDAP configuration error: "
+                                      "Set the Search Domain.")
             elif not search_base_dn or search_base_dn == '<Search-Base-DN>':
                 search_base_dn = config.LDAP_BASE_DN
 
@@ -260,8 +264,8 @@ class LDAPAuthentication(BaseAuthentication):
         results = len(self.conn.entries)
         if results > 1:
             return False, ERROR_SEARCHING_LDAP_DIRECTORY.format(
-                "More than one result found.")
+                gettext("More than one result found."))
         elif results < 1:
             return False, ERROR_SEARCHING_LDAP_DIRECTORY.format(
-                "Could not find the specified user.")
+                gettext("Could not find the specified user."))
         return True, self.conn.entries[0]


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [pgAdmin4][Patch] - RM 6274 - LDAP auth module is not translatable
@ 2021-04-08 12:46  Akshay Joshi <[email protected]>
  parent: Khushboo Vashi <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Akshay Joshi @ 2021-04-08 12:46 UTC (permalink / raw)
  To: Khushboo Vashi <[email protected]>; +Cc: pgadmin-hackers

Thanks, patch applied.

On Thu, Apr 8, 2021 at 5:07 PM Khushboo Vashi <
[email protected]> wrote:

> Hi,
>
> Please find the attached patch to fix RM #6274 - LDAP auth module is not
> translatable.
>
> Thanks,
> Khushboo
>
>

-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Principal Software Architect*
*EDB Postgres <http://edbpostgres.com>*

*Mobile: +91 976-788-8246*


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2021-04-08 12:46 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 11:37 [pgAdmin4][Patch] - RM 6274 - LDAP auth module is not translatable Khushboo Vashi <[email protected]>
2021-04-08 12:46 ` Akshay Joshi <[email protected]>

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