Various misc fixes:

- Using the 'gettext' as oppose to '_', which is not defined
- Define missing variables
- Fixed escape character in string with double quote
- Removed some dead code in a test case
- Removed unnecessary self assignment

Includes some fixes for Accessibility improvements
- Use semantic markup to mark emphasized or special text
- Added hidden legend in <fieldset> for better screen reader support
This commit is contained in:
Ashesh Vashi 2020-04-08 14:14:25 +05:30
parent 8fe687eb55
commit d9f6baac72
15 changed files with 28 additions and 59 deletions

View File

@ -1506,7 +1506,7 @@ class ServerNode(PGChildNodeView):
conn = manager.connection()
if not conn.connected():
return gone(
errormsg=_('Please connect the server.')
errormsg=gettext('Please connect the server.')
)
if not server.password or not manager.password:

View File

@ -259,6 +259,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
Returns:
"""
res = []
SQL = render_template(
"/".join([self.template_path, 'properties.sql']),
scid=scid, pkgid=pkgid
@ -778,7 +779,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
if sql is None:
return None
start = 0
start_position = re.search("\s+[is|as]+\s+", sql, flags=re.I)
start_position = re.search("\\s+[is|as]+\\s+", sql, flags=re.I)
if start_position:
start = start_position.start() + 4

View File

@ -588,7 +588,7 @@ class ResourceGroupView(NodeView):
if len(res['rows']) == 0:
return gone(
_("The specified resource group could not be found.")
gettext("The specified resource group could not be found.")
)
old_data = res['rows'][0]
for arg in required_args:
@ -655,7 +655,7 @@ class ResourceGroupView(NodeView):
return internal_server_error(errormsg=res)
if len(res['rows']) == 0:
return gone(
_("The specified resource group could not be found.")
gettext("The specified resource group could not be found.")
)
# Making copy of output for future use

View File

@ -60,13 +60,12 @@ def test_getrole(tester):
server_ids = all_id["sid"]
role_ids_dict = all_id["lrid"][0]
server_group = config_data['server_group']
role_response_data = []
for server_id in server_ids:
role_id = role_ids_dict[int(server_id)]
role_response_data.append(
verify_role(tester, server_group, server_id, role_id))
verify_role(server_id, role_id))
return role_response_data
@ -122,34 +121,6 @@ def create_role(server, role_name):
print(exception, file=sys.stderr)
def write_role_id(response_data):
"""
:param response_data:
:return:
"""
lr_id = response_data['node']['_id']
server_id = response_data['node']['_pid']
pickle_id_dict = utils.get_pickle_id_dict()
# TODO: modify logic to write in file / file exists or create new check
# old file
if os.path.isfile(pickle_path):
existing_server_id = open(pickle_path, 'rb')
tol_server_id = pickle.load(existing_server_id)
pickle_id_dict = tol_server_id
if 'lrid' in pickle_id_dict:
if pickle_id_dict['lrid']:
# Add the db_id as value in dict
pickle_id_dict["lrid"][0].update({server_id: lr_id})
else:
# Create new dict with server_id and db_id
pickle_id_dict["lrid"].append({server_id: lr_id})
db_output = open(pickle_path, 'wb')
pickle.dump(pickle_id_dict, db_output)
db_output.close()
def delete_role(connection, role_names):
"""
This function use to delete the existing roles in the servers

View File

@ -485,7 +485,7 @@ class TablespaceView(PGChildNodeView):
if len(res['rows']) == 0:
return gone(
_("Could not find the tablespace on the server.")
gettext("Could not find the tablespace on the server.")
)
# Making copy of output for further processing
@ -550,7 +550,7 @@ class TablespaceView(PGChildNodeView):
if len(res['rows']) == 0:
return gone(
_("Could not find the tablespace on the server.")
gettext("Could not find the tablespace on the server.")
)
# Making copy of output for future use
old_data = dict(res['rows'][0])

View File

@ -365,7 +365,6 @@ class Filemanager(object):
if 'supported_types' in params else []
if fm_type == 'select_file':
capabilities = ['select_file', 'rename', 'upload', 'create']
supp_types = supp_types
files_only = True
folders_only = False
title = "Select File"
@ -376,14 +375,12 @@ class Filemanager(object):
title = "Select Folder"
elif fm_type == 'create_file':
capabilities = ['select_file', 'rename', 'create']
supp_types = supp_types
files_only = True
folders_only = False
title = "Create File"
elif fm_type == 'storage_dialog':
capabilities = ['select_folder', 'select_file', 'download',
'rename', 'delete', 'upload', 'create']
supp_types = supp_types
files_only = True
folders_only = False
title = "Storage Manager"

View File

@ -86,7 +86,7 @@ def get_setting(setting, default=''):
@blueprint.route("/")
@login_required
def index():
return bad_request(errormsg=_("This URL cannot be called directly."))
return bad_request(errormsg=gettext("This URL cannot be called directly."))
@blueprint.route("/settings.js")

View File

@ -6,13 +6,14 @@
<div class="row align-items-center h-100">
<div class="col-md-4"></div>
<div class="col-md-4">
<div class="panel-header h4"><i class="app-icon pg-icon-blue"></i> {{ _('%(appname)s', appname=config.APP_NAME) }}</div>
<div class="panel-header h4"><i class="app-icon pg-icon-blue" aria-hidden="true"></i> {{ _('%(appname)s', appname=config.APP_NAME) }}</div>
<div class="panel-body">
<div class="d-block text-color pb-3 h5">{{ _('Password Change') }}</div>
{% if config.SERVER_MODE %}
<form action="{{ url_for('browser.change_password') }}" method="POST" name="change_password_form">
{{ change_password_form.hidden_tag() }}
<fieldset>
<legend class="skip-navigation">{{ _('Change Password Form') }}</legend>
{{ render_field_with_errors(change_password_form.password, "password") }}
{{ render_field_with_errors(change_password_form.new_password, "password") }}
{{ render_field_with_errors(change_password_form.new_password_confirm, "password") }}

View File

@ -11,6 +11,7 @@
<form action="{{ url_for('browser.forgot_password') }}" method="POST" name="forgot_password_form">
{{ forgot_password_form.hidden_tag() }}
<fieldset>
<legend class="skip-navigation">{{ _('Forget Password Form') }}</legend>
{{ render_field_with_errors(forgot_password_form.email, "text") }}
<input class="btn btn-primary btn-block btn-login" type="submit" value="{{ _('Recover Password') }}"
title="{{ _('Recover Password') }}">

View File

@ -11,7 +11,7 @@
<div class="row h-100 align-items-center justify-content-center">
<div class="col-md-6">{% block panel_image %}{% endblock %}</div>
<div class="col-md-3">
<div class="panel-header text-color h4"><i class="app-icon pg-icon"></i> {{ _('%(appname)s', appname=config.APP_NAME) }}</div>
<div class="panel-header text-color h4"><i class="app-icon pg-icon" aria-hidden="true"></i> {{ _('%(appname)s', appname=config.APP_NAME) }}</div>
<div class="panel-body">
<div class="d-block text-color pb-3 h5">{% block panel_title %}{% endblock %}</div>
{% block panel_body %}

View File

@ -6,6 +6,7 @@
name="reset_password_form">
{{ reset_password_form.hidden_tag() }}
<fieldset>
<legend class="skip-navigation">{{ _('Reset Password Form') }}</legend>
{{ render_field_with_errors(reset_password_form.password, "password") }}
{{ render_field_with_errors(reset_password_form.password_confirm, "password") }}
<input class="btn btn-lg btn-success btn-block" type="submit" value="{{ _('Reset Password') }}"

View File

@ -58,7 +58,7 @@ try {
autofocus="autofocus"
aria-label="{{ gettext('Step into') }}"
disabled>
<i class="fa fa-indent sql-icon-lg"></i>
<i class="fa fa-indent sql-icon-lg" aria-hidden="true"></i>
</button>
<button type="button" class="btn btn-sm btn-secondary btn-step-over" id="btn-step-over"
title=""
@ -66,7 +66,7 @@ try {
tabindex="0"
aria-label="{{ gettext('Step over') }}"
disabled>
<i class="fa fa-outdent sql-icon-lg"></i>
<i class="fa fa-outdent sql-icon-lg" aria-hidden="true"></i>
</button>
<button type="button" class="btn btn-sm btn-secondary btn-continue" id="btn-continue"
title=""
@ -74,7 +74,7 @@ try {
tabindex="0"
aria-label="{{ gettext('Continue/Start') }}"
disabled>
<i class="fa fa-play-circle sql-icon-lg"></i>
<i class="fa fa-play-circle sql-icon-lg" aria-hidden="true"></i>
</button>
</div>
<div class="btn-group" role="group" aria-label="">
@ -84,7 +84,7 @@ try {
tabindex="0"
aria-label="{{ gettext('Toggle breakpoint') }}"
disabled>
<i class="fa fa-circle sql-icon-lg"></i>
<i class="fa fa-circle sql-icon-lg" aria-hidden="true"></i>
</button>
<button type="button" class="btn btn-sm btn-secondary btn-clear-breakpoint" id="btn-clear-breakpoint"
title=""
@ -92,7 +92,7 @@ try {
tabindex="0"
aria-label="{{ gettext('Clear all breakpoints') }}"
disabled>
<i class="fa fa-ban sql-icon-lg"></i>
<i class="fa fa-ban sql-icon-lg" aria-hidden="true"></i>
</button>
</div>
<div class="btn-group" role="group" aria-label="">
@ -102,7 +102,7 @@ try {
tabindex="0"
aria-label="{{ gettext('Stop') }}"
disabled>
<i class="fa fa-stop-circle sql-icon-lg"></i>
<i class="fa fa-stop-circle sql-icon-lg" aria-hidden="true"></i>
</button>
</div>
</div>

View File

@ -8,9 +8,6 @@
##########################################################################
"""A blueprint module implementing the schema_diff frame."""
MODULE_NAME = 'schema_diff'
import simplejson as json
import pickle
import random
@ -28,6 +25,8 @@ from pgadmin.tools.schema_diff.model import SchemaDiffModel
from config import PG_DEFAULT_DRIVER
from pgadmin.utils.driver import get_driver
MODULE_NAME = 'schema_diff'
class SchemaDiffModule(PgAdminModule):
"""
@ -567,15 +566,16 @@ def check_version_compatibility(sid, tid):
tar_server = Server.query.filter_by(id=tid).first()
tar_manager = driver.connection_manager(tar_server.id)
target_conn = src_manager.connection()
if not (src_conn.connected() and target.connected()):
return False, gettext('Server(s) disconnected.')
if src_manager.server_type != tar_manager.server_type:
return False, gettext('Schema diff does not support the comparison '
'between Postgres Server and EDB Postgres '
'Advanced Server.')
if not (src_conn.connected() or src_conn.connected()):
return False, gettext('Server(s) disconnected.')
def get_round_val(x):
if x < 10000:
return x if x % 100 == 0 else x + 100 - x % 100

View File

@ -56,7 +56,7 @@ blueprint = SearchObjectsModule(
@blueprint.route("/", endpoint='index')
@login_required
def index():
return bad_request(errormsg=_("This URL cannot be called directly."))
return bad_request(errormsg=gettext("This URL cannot be called directly."))
@blueprint.route("types/<int:sid>/<int:did>", endpoint='types')

View File

@ -1296,10 +1296,7 @@ def save_file():
else:
output_file.write(file_content)
except IOError as e:
if e.strerror == 'Permission denied':
err_msg = "Error: {0}".format(e.strerror)
else:
err_msg = "Error: {0}".format(e.strerror)
err_msg = "Error: {0}".format(e.strerror)
return internal_server_error(errormsg=err_msg)
except Exception as e:
err_msg = "Error: {0}".format(e.strerror)