Fixed code smell 'Define a constant instead of duplicating this literal' reported by SonarQube.

This commit is contained in:
Akshay Joshi
2020-08-20 20:26:51 +05:30
parent 7f3e8596e3
commit fbbbc36221
35 changed files with 149 additions and 246 deletions

View File

@@ -15,6 +15,7 @@ from flask_babelex import gettext
from flask_security import current_user, login_required from flask_security import current_user, login_required
from pgadmin.utils import PgAdminModule from pgadmin.utils import PgAdminModule
from pgadmin.utils.menu import MenuItem from pgadmin.utils.menu import MenuItem
from pgadmin.utils.constants import MIMETYPE_APP_JS
import config import config
MODULE_NAME = 'about' MODULE_NAME = 'about'
@@ -82,5 +83,5 @@ def script():
return Response( return Response(
response=render_template("about/about.js", _=gettext), response=render_template("about/about.js", _=gettext),
status=200, status=200,
mimetype="application/javascript" mimetype=MIMETYPE_APP_JS
) )

View File

@@ -172,6 +172,8 @@ class LanguageView(PGChildNodeView, SchemaDiffObjectCompare):
language node. language node.
""" """
_NOT_FOUND_LANG_INFORMATION = \
gettext("Could not find the language information.")
node_type = blueprint.node_type node_type = blueprint.node_type
parent_ids = [ parent_ids = [
@@ -366,9 +368,7 @@ class LanguageView(PGChildNodeView, SchemaDiffObjectCompare):
return False, internal_server_error(errormsg=res) return False, internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return False, gone( return False, gone(self._NOT_FOUND_LANG_INFORMATION)
gettext("Could not find the language information.")
)
res['rows'][0]['is_sys_obj'] = ( res['rows'][0]['is_sys_obj'] = (
res['rows'][0]['oid'] <= self.datlastsysoid) res['rows'][0]['oid'] <= self.datlastsysoid)
@@ -652,9 +652,7 @@ class LanguageView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self._NOT_FOUND_LANG_INFORMATION)
gettext("Could not find the language information.")
)
LanguageView._parse_privileges(data) LanguageView._parse_privileges(data)
@@ -740,9 +738,7 @@ class LanguageView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self._NOT_FOUND_LANG_INFORMATION)
gettext("Could not find the language information.")
)
# Making copy of output for future use # Making copy of output for future use
old_data = dict(res['rows'][0]) old_data = dict(res['rows'][0])

View File

@@ -148,6 +148,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
node_type = blueprint.node_type node_type = blueprint.node_type
node_label = "Collation"
parent_ids = [ parent_ids = [
{'type': 'int', 'id': 'gid'}, {'type': 'int', 'id': 'gid'},
@@ -306,7 +307,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
status=200 status=200
) )
return gone(gettext("Could not find the specified collation.")) return gone(self.not_found_error_msg())
@check_precondition @check_precondition
def properties(self, gid, sid, did, scid, coid): def properties(self, gid, sid, did, scid, coid):
@@ -352,8 +353,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
return False, internal_server_error(errormsg=res) return False, internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return False, gone(gettext("Could not find the collation " return False, gone(self.not_found_error_msg())
"object in the database."))
res['rows'][0]['is_sys_obj'] = ( res['rows'][0]['is_sys_obj'] = (
res['rows'][0]['oid'] <= self.datlastsysoid) res['rows'][0]['oid'] <= self.datlastsysoid)
@@ -536,9 +536,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone(gettext( return gone(self.not_found_error_msg())
"Could not find the collation object in the database."
))
data = res['rows'][0] data = res['rows'][0]
@@ -660,10 +658,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext(
"Could not find the collation object in the database.")
)
old_data = res['rows'][0] old_data = res['rows'][0]
SQL = render_template( SQL = render_template(
@@ -712,9 +707,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("Could not find the collation object in the database.")
)
data = res['rows'][0] data = res['rows'][0]

View File

@@ -142,6 +142,7 @@ class DomainView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
""" """
node_type = blueprint.node_type node_type = blueprint.node_type
node_label = "Domain"
parent_ids = [ parent_ids = [
{'type': 'int', 'id': 'gid'}, {'type': 'int', 'id': 'gid'},
@@ -384,7 +385,7 @@ class DomainView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
status=200 status=200
) )
return gone(gettext("Could not find the specified domain.")) return gone(self.not_found_error_msg())
@check_precondition @check_precondition
def properties(self, gid, sid, did, scid, doid): def properties(self, gid, sid, did, scid, doid):
@@ -647,9 +648,7 @@ AND relkind != 'c'))"""
errormsg=gettext( errormsg=gettext(
'Error: Object not found.' 'Error: Object not found.'
), ),
info=gettext( info=self.not_found_error_msg()
'The specified domain could not be found.\n'
)
) )
name = res['rows'][0]['name'] name = res['rows'][0]['name']
@@ -734,9 +733,7 @@ AND relkind != 'c'))"""
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("Could not find the specified domain.")
)
data = res['rows'][0] data = res['rows'][0]
@@ -832,9 +829,7 @@ AND relkind != 'c'))"""
if not status: if not status:
return False, internal_server_error(errormsg=res) return False, internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("Could not find the specified domain.")
)
old_data = res['rows'][0] old_data = res['rows'][0]

View File

@@ -153,6 +153,7 @@ class DomainConstraintView(PGChildNodeView):
- Returns the dependencies for the Domain Constraint object. - Returns the dependencies for the Domain Constraint object.
""" """
node_type = blueprint.node_type node_type = blueprint.node_type
node_label = "Domain Constraint"
parent_ids = [ parent_ids = [
{'type': 'int', 'id': 'gid'}, {'type': 'int', 'id': 'gid'},
@@ -374,9 +375,7 @@ class DomainConstraintView(PGChildNodeView):
status=200 status=200
) )
return gone( return gone(self.not_found_error_msg())
gettext("Could not find the specified domain constraint.")
)
@check_precondition @check_precondition
def properties(self, gid, sid, did, scid, doid, coid): def properties(self, gid, sid, did, scid, doid, coid):
@@ -400,10 +399,7 @@ class DomainConstraintView(PGChildNodeView):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone(gettext( return gone(self.not_found_error_msg())
"Could not find the specified domain constraint."
)
)
data = res['rows'][0] data = res['rows'][0]
data['is_sys_obj'] = ( data['is_sys_obj'] = (
@@ -505,10 +501,7 @@ class DomainConstraintView(PGChildNodeView):
errormsg=gettext( errormsg=gettext(
'Error: Object not found.' 'Error: Object not found.'
), ),
info=gettext( info=self.not_found_error_msg()
'The specified domain constraint '
'could not be found.\n'
)
) )
data = res['rows'][0] data = res['rows'][0]
@@ -609,10 +602,7 @@ class DomainConstraintView(PGChildNodeView):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone(gettext( return gone(self.not_found_error_msg())
"Could not find the specified domain constraint."
)
)
data = res['rows'][0] data = res['rows'][0]
@@ -681,10 +671,7 @@ class DomainConstraintView(PGChildNodeView):
if not status: if not status:
return False, internal_server_error(errormsg=res) return False, internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return False, gone(gettext( return False, gone(self.not_found_error_msg())
"Could not find the specified domain constraint."
)
)
old_data = res['rows'][0] old_data = res['rows'][0]
@@ -723,8 +710,7 @@ class DomainConstraintView(PGChildNodeView):
if not status: if not status:
return False, internal_server_error(errormsg=res) return False, internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
raise ObjectGone( raise ObjectGone(self.not_found_error_msg('Domain'))
gettext("The specified domain could not be found."))
return res['rows'][0]['schema'], res['rows'][0]['domain'] return res['rows'][0]['schema'], res['rows'][0]['domain']

View File

@@ -178,6 +178,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
""" """
node_type = blueprint.node_type node_type = blueprint.node_type
node_label = "Foreign Table"
parent_ids = [ parent_ids = [
{'type': 'int', 'id': 'gid'}, {'type': 'int', 'id': 'gid'},
@@ -442,9 +443,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
status=200 status=200
) )
return gone(gettext( return gone(self.not_found_error_msg())
'Could not find the specified foreign table.'
))
@check_precondition @check_precondition
def properties(self, gid, sid, did, scid, foid): def properties(self, gid, sid, did, scid, foid):
@@ -462,8 +461,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
if not status: if not status:
return data return data
if not data: if not data:
return gone( return gone(self.not_found_error_msg())
gettext("The specified foreign table could not be found."))
return ajax_response( return ajax_response(
response=data, response=data,
@@ -745,9 +743,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
errormsg=gettext( errormsg=gettext(
'Error: Object not found.' 'Error: Object not found.'
), ),
info=gettext( info=self.not_found_error_msg()
'The specified foreign table could not be found.\n'
)
) )
name = res['rows'][0]['name'] name = res['rows'][0]['name']
@@ -841,8 +837,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
if not status: if not status:
return data return data
if not data: if not data:
return gone( return gone(self.not_found_error_msg())
gettext("The specified foreign table could not be found."))
col_data = [] col_data = []
for c in data['columns']: for c in data['columns']:
@@ -1024,8 +1019,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
if not status: if not status:
return old_data return old_data
elif not old_data: elif not old_data:
return gone( return gone(self.not_found_error_msg())
gettext("The specified foreign table could not be found."))
if is_schema_diff: if is_schema_diff:
data['is_schema_diff'] = True data['is_schema_diff'] = True
@@ -1336,8 +1330,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
if not status: if not status:
return data return data
if not data: if not data:
return gone( return gone(self.not_found_error_msg())
gettext("The specified foreign table could not be found."))
columns = [] columns = []
for c in data['columns']: for c in data['columns']:
@@ -1374,8 +1367,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
if not status: if not status:
return data return data
if not data: if not data:
return gone( return gone(self.not_found_error_msg())
gettext("The specified foreign table could not be found."))
columns = [] columns = []
values = [] values = []
@@ -1417,8 +1409,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
if not status: if not status:
return data return data
if not data: if not data:
return gone( return gone(self.not_found_error_msg())
gettext("The specified foreign table could not be found."))
columns = [] columns = []
@@ -1464,8 +1455,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
if not status: if not status:
return data return data
if not data: if not data:
return gone( return gone(self.not_found_error_msg())
gettext("The specified foreign table could not be found."))
sql = u"DELETE FROM {0}\n\tWHERE <condition>;".format( sql = u"DELETE FROM {0}\n\tWHERE <condition>;".format(
self.qtIdent(self.conn, data['basensp'], data['name']) self.qtIdent(self.conn, data['basensp'], data['name'])

View File

@@ -157,6 +157,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
node_type = blueprint.node_type node_type = blueprint.node_type
node_label = "FTS Template"
parent_ids = [ parent_ids = [
{'type': 'int', 'id': 'gid'}, {'type': 'int', 'id': 'gid'},
@@ -281,9 +282,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
), ),
status=200 status=200
) )
return gone( return gone(self.not_found_error_msg())
gettext("Could not find the requested FTS template.")
)
@check_precondition @check_precondition
def properties(self, gid, sid, did, scid, tid): def properties(self, gid, sid, did, scid, tid):
@@ -323,9 +322,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
return False, internal_server_error(errormsg=res) return False, internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return False, gone( return False, gone(self.not_found_error_msg())
gettext("Could not find the requested FTS template.")
)
res['rows'][0]['is_sys_obj'] = ( res['rows'][0]['is_sys_obj'] = (
res['rows'][0]['oid'] <= self.datlastsysoid) res['rows'][0]['oid'] <= self.datlastsysoid)
return True, res['rows'][0] return True, res['rows'][0]
@@ -486,9 +483,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
errormsg=gettext( errormsg=gettext(
'Error: Object not found.' 'Error: Object not found.'
), ),
info=gettext( info=self.not_found_error_msg()
'The specified FTS template could not be found.\n'
)
) )
# Drop fts template # Drop fts template
@@ -621,9 +616,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
elif len(res['rows']) == 0: elif len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("Could not find the requested FTS template.")
)
old_data = res['rows'][0] old_data = res['rows'][0]
if 'schema' not in data: if 'schema' not in data:

View File

@@ -82,6 +82,7 @@ blueprint = PackageModule(__name__)
class PackageView(PGChildNodeView, SchemaDiffObjectCompare): class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
node_type = blueprint.node_type node_type = blueprint.node_type
node_label = "Package"
parent_ids = [ parent_ids = [
{'type': 'int', 'id': 'gid'}, {'type': 'int', 'id': 'gid'},
@@ -213,7 +214,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
if pkgid is not None: if pkgid is not None:
if len(rset['rows']) == 0: if len(rset['rows']) == 0:
return gone( return gone(
errormsg=_("Could not find the package.") errormsg=self.not_found_error_msg()
) )
row = rset['rows'][0] row = rset['rows'][0]
@@ -267,7 +268,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
if len(rset['rows']) == 0: if len(rset['rows']) == 0:
return gone( return gone(
errormsg=_("Could not find the package in the database.") errormsg=self.not_found_error_msg()
) )
for row in rset['rows']: for row in rset['rows']:
@@ -325,7 +326,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
if len(res['rows']) == 0: if len(res['rows']) == 0:
return False, gone( return False, gone(
errormsg=_("Could not find the package in the database.") errormsg=self.not_found_error_msg()
) )
res['rows'][0]['pkgheadsrc'] = self.get_inner( res['rows'][0]['pkgheadsrc'] = self.get_inner(
@@ -459,9 +460,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
errormsg=_( errormsg=_(
'Error: Object not found.' 'Error: Object not found.'
), ),
info=_( info=self.not_found_error_msg()
'The specified package could not be found.\n'
)
) )
res['rows'][0]['schema'] = self.schema res['rows'][0]['schema'] = self.schema
@@ -635,7 +634,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
elif len(res['rows']) == 0: elif len(res['rows']) == 0:
return gone( return gone(
errormsg=_("Could not find the package in the database.") errormsg=self.not_found_error_msg()
) )
res['rows'][0]['pkgheadsrc'] = self.get_inner( res['rows'][0]['pkgheadsrc'] = self.get_inner(
@@ -700,7 +699,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(
errormsg=_("Could not find the package in the database.") errormsg=self.not_found_error_msg()
) )
res['rows'][0]['pkgheadsrc'] = self.get_inner( res['rows'][0]['pkgheadsrc'] = self.get_inner(

View File

@@ -90,6 +90,7 @@ blueprint = SequenceModule(__name__)
class SequenceView(PGChildNodeView, SchemaDiffObjectCompare): class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
node_type = blueprint.node_type node_type = blueprint.node_type
node_label = "Sequence"
parent_ids = [ parent_ids = [
{'type': 'int', 'id': 'gid'}, {'type': 'int', 'id': 'gid'},
@@ -208,7 +209,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
if seid is not None: if seid is not None:
if len(rset['rows']) == 0: if len(rset['rows']) == 0:
return gone(errormsg=_("Could not find the sequence.")) return gone(errormsg=self.not_found_error_msg())
row = rset['rows'][0] row = rset['rows'][0]
return make_json_response( return make_json_response(
data=self.blueprint.generate_browser_node( data=self.blueprint.generate_browser_node(
@@ -303,8 +304,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
if not status: if not status:
return False, internal_server_error(errormsg=res) return False, internal_server_error(errormsg=res)
elif len(res['rows']) == 0: elif len(res['rows']) == 0:
return False, gone( return False, gone(self.not_found_error_msg())
_("Could not find the sequence in the database."))
res['rows'][0]['is_sys_obj'] = ( res['rows'][0]['is_sys_obj'] = (
res['rows'][0]['oid'] <= self.datlastsysoid) res['rows'][0]['oid'] <= self.datlastsysoid)
@@ -487,9 +487,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
errormsg=_( errormsg=_(
'Error: Object not found.' 'Error: Object not found.'
), ),
info=_( info=self.not_found_error_msg()
'The specified sequence could not be found.\n'
)
) )
sql = render_template( sql = render_template(
@@ -638,7 +636,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
elif len(res['rows']) == 0: elif len(res['rows']) == 0:
return gone(_("Could not find the sequence in the database.")) return gone(self.not_found_error_msg())
# Making copy of output for further processing # Making copy of output for further processing
old_data = dict(res['rows'][0]) old_data = dict(res['rows'][0])
@@ -711,7 +709,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone(_("Could not find the sequence in the database.")) return gone(self.not_found_error_msg())
for row in res['rows']: for row in res['rows']:
sql = render_template( sql = render_template(

View File

@@ -147,6 +147,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
node_type = blueprint.node_type node_type = blueprint.node_type
node_label = "Synonym"
parent_ids = [ parent_ids = [
{'type': 'int', 'id': 'gid'}, {'type': 'int', 'id': 'gid'},
@@ -304,9 +305,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
if len(rset['rows']) == 0: if len(rset['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("""Could not find the Synonym node.""")
)
for row in rset['rows']: for row in rset['rows']:
return make_json_response( return make_json_response(
@@ -416,9 +415,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
return False, internal_server_error(errormsg=res) return False, internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return False, gone( return False, gone(self.not_found_error_msg())
gettext('The specified synonym could not be found.')
)
res['rows'][0]['is_sys_obj'] = ( res['rows'][0]['is_sys_obj'] = (
res['rows'][0]['oid'] <= self.datlastsysoid) res['rows'][0]['oid'] <= self.datlastsysoid)
@@ -523,9 +520,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
if len(res['rows']) > 0: if len(res['rows']) > 0:
data = res['rows'][0] data = res['rows'][0]
else: else:
return gone( return gone(self.not_found_error_msg())
gettext('The specified synonym could not be found.')
)
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
self._DELETE_SQL]), self._DELETE_SQL]),
@@ -628,9 +623,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("Could not find the synonym on the server.")
)
old_data = res['rows'][0] old_data = res['rows'][0]
name = old_data['name'] name = old_data['name']
# If target schema/object is not present then take it from # If target schema/object is not present then take it from
@@ -684,9 +677,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
if len(res['rows']) > 0: if len(res['rows']) > 0:
data = res['rows'][0] data = res['rows'][0]
else: else:
return gone( return gone(self.not_found_error_msg())
gettext('The specified synonym could not be found.')
)
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
self._CREATE_SQL]), self._CREATE_SQL]),

View File

@@ -158,6 +158,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
""" """
node_type = blueprint.node_type node_type = blueprint.node_type
node_label = "Column"
parent_ids = [ parent_ids = [
{'type': 'int', 'id': 'gid'}, {'type': 'int', 'id': 'gid'},
@@ -280,7 +281,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
if clid is not None: if clid is not None:
if len(rset['rows']) == 0: if len(rset['rows']) == 0:
return gone( return gone(
errormsg=gettext("Could not find the column.") errormsg=self.not_found_error_msg()
) )
row = rset['rows'][0] row = rset['rows'][0]
return make_json_response( return make_json_response(
@@ -339,7 +340,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone(gettext("""Could not find the column in the table.""")) return gone(self.not_found_error_msg())
# Making copy of output for future use # Making copy of output for future use
data = dict(res['rows'][0]) data = dict(res['rows'][0])
@@ -470,9 +471,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
errormsg=gettext( errormsg=gettext(
'Error: Object not found.' 'Error: Object not found.'
), ),
info=gettext( info=self.not_found_error_msg()
'The specified column could not be found.\n'
)
) )
data = dict(res['rows'][0]) data = dict(res['rows'][0])
@@ -679,9 +678,8 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
elif len(res['rows']) == 0: elif len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("Could not find the column on the server.")
)
old_data = dict(res['rows'][0]) old_data = dict(res['rows'][0])
is_view_only = True if 'is_view_only' in old_data and old_data[ is_view_only = True if 'is_view_only' in old_data and old_data[
@@ -732,9 +730,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("Could not find the column on the server.")
)
data = dict(res['rows'][0]) data = dict(res['rows'][0])
# We do not want to display length as -1 in create query # We do not want to display length as -1 in create query
@@ -884,9 +880,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("Could not find the column on the server.")
)
data = dict(res['rows'][0]) data = dict(res['rows'][0])
column = data['name'] column = data['name']

View File

@@ -218,6 +218,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
node_type = blueprint.node_type node_type = blueprint.node_type
node_label = "Compound Trigger"
parent_ids = [ parent_ids = [
{'type': 'int', 'id': 'gid'}, {'type': 'int', 'id': 'gid'},
@@ -351,9 +352,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
if len(rset['rows']) == 0: if len(rset['rows']) == 0:
return gone(gettext( return gone(self.not_found_error_msg())
"""Could not find the compound trigger in the table.""")
)
res = self.blueprint.generate_browser_node( res = self.blueprint.generate_browser_node(
rset['rows'][0]['oid'], rset['rows'][0]['oid'],
@@ -434,8 +433,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=data) return internal_server_error(errormsg=data)
if 'rows' in data and len(data['rows']) == 0: if 'rows' in data and len(data['rows']) == 0:
return gone(gettext( return gone(self.not_found_error_msg())
"""Could not find the compound trigger in the table."""))
return ajax_response( return ajax_response(
response=data, response=data,
@@ -589,10 +587,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
errormsg=gettext( errormsg=gettext(
'Error: Object not found.' 'Error: Object not found.'
), ),
info=gettext( info=self.not_found_error_msg()
'The specified compound trigger could not be '
'found.\n'
)
) )
data = dict(res['rows'][0]) data = dict(res['rows'][0])
@@ -670,8 +665,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone(gettext( return gone(self.not_found_error_msg())
"""Could not find the compound trigger in the table."""))
# Making copy of output for future use # Making copy of output for future use
data = dict(res['rows'][0]) data = dict(res['rows'][0])
@@ -790,9 +784,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone(gettext( return gone(self.not_found_error_msg())
"""Could not find the compound trigger in the table.""")
)
o_data = dict(res['rows'][0]) o_data = dict(res['rows'][0])
@@ -912,8 +904,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
elif len(res['rows']) == 0: elif len(res['rows']) == 0:
return gone(gettext("Could not find the compound " return gone(self.not_found_error_msg())
"trigger in the table."))
data = dict(res['rows'][0]) data = dict(res['rows'][0])
# Adding parent into data dict, # Adding parent into data dict,

View File

@@ -193,6 +193,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
node_type = blueprint.node_type node_type = blueprint.node_type
node_label = "Index"
parent_ids = [ parent_ids = [
{'type': 'int', 'id': 'gid'}, {'type': 'int', 'id': 'gid'},
@@ -425,7 +426,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
if len(rset['rows']) == 0: if len(rset['rows']) == 0:
return gone(gettext("""Could not find the index in the table.""")) return gone(self.not_found_error_msg())
res = self.blueprint.generate_browser_node( res = self.blueprint.generate_browser_node(
rset['rows'][0]['oid'], rset['rows'][0]['oid'],
@@ -521,8 +522,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
return False, internal_server_error(errormsg=res) return False, internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return False, gone( return False, gone(self.not_found_error_msg())
gettext("""Could not find the index in the table."""))
# Making copy of output for future use # Making copy of output for future use
data = dict(res['rows'][0]) data = dict(res['rows'][0])
@@ -705,9 +705,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
errormsg=gettext( errormsg=gettext(
'Error: Object not found.' 'Error: Object not found.'
), ),
info=gettext( info=self.not_found_error_msg()
'The specified index could not be found.\n'
)
) )
data = dict(res['rows'][0]) data = dict(res['rows'][0])
@@ -969,9 +967,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("""Could not find the index in the table.""")
)
data = dict(res['rows'][0]) data = dict(res['rows'][0])
index = data['name'] index = data['name']

View File

@@ -209,7 +209,7 @@
"mock_data": {}, "mock_data": {},
"expected_data": { "expected_data": {
"status_code": 410, "status_code": 410,
"error_msg": "Could not find the index in the table.", "error_msg": "could not find the specified index.",
"test_result_data": {} "test_result_data": {}
}, },
"is_list": false "is_list": false
@@ -528,7 +528,7 @@
"mock_data": {}, "mock_data": {},
"expected_data": { "expected_data": {
"status_code": 410, "status_code": 410,
"error_msg": "Could not find the index in the table.", "error_msg": "could not find the specified index.",
"test_result_data": { "test_result_data": {
} }
}, },

View File

@@ -197,6 +197,7 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
""" """
node_type = blueprint.node_type node_type = blueprint.node_type
node_label = "Partition"
parent_ids = [ parent_ids = [
{'type': 'int', 'id': 'gid'}, {'type': 'int', 'id': 'gid'},
@@ -321,9 +322,7 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
if ptid is not None: if ptid is not None:
if len(rset['rows']) == 0: if len(rset['rows']) == 0:
return gone(gettext( return gone(self.not_found_error_msg())
"The specified partitioned table could not be found."
))
return make_json_response( return make_json_response(
data=browser_node(rset['rows'][0]), status=200 data=browser_node(rset['rows'][0]), status=200
@@ -359,8 +358,7 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
status, res = self._fetch_properties(did, scid, tid, ptid) status, res = self._fetch_properties(did, scid, tid, ptid)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone(gettext( return gone(self.not_found_error_msg())
"The specified partitioned table could not be found."))
return super(PartitionsView, self).properties( return super(PartitionsView, self).properties(
gid, sid, did, scid, ptid, res=res) gid, sid, did, scid, ptid, res=res)
@@ -471,8 +469,7 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
status, res = self._fetch_properties(did, scid, tid, ptid) status, res = self._fetch_properties(did, scid, tid, ptid)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone(gettext( return gone(self.not_found_error_msg())
"The specified partitioned table could not be found."))
data = res['rows'][0] data = res['rows'][0]

View File

@@ -148,6 +148,7 @@ class RowSecurityView(PGChildNodeView):
""" """
node_type = blueprint.node_type node_type = blueprint.node_type
node_label = "RLS Policy"
parent_ids = [ parent_ids = [
{'type': 'int', 'id': 'gid'}, {'type': 'int', 'id': 'gid'},
@@ -249,7 +250,7 @@ class RowSecurityView(PGChildNodeView):
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
if len(rset['rows']) == 0: if len(rset['rows']) == 0:
return gone(gettext("""Could not find the policy in the table.""")) return gone(self.not_found_error_msg())
res = self.blueprint.generate_browser_node( res = self.blueprint.generate_browser_node(
rset['rows'][0]['oid'], rset['rows'][0]['oid'],
@@ -321,8 +322,7 @@ class RowSecurityView(PGChildNodeView):
return False, internal_server_error(errormsg=res) return False, internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return False, gone( return False, gone(self.not_found_error_msg())
gettext("""Could not find the policy in the table."""))
data = dict(res['rows'][0]) data = dict(res['rows'][0])
@@ -483,9 +483,7 @@ class RowSecurityView(PGChildNodeView):
errormsg=gettext( errormsg=gettext(
'Error: Object not found.' 'Error: Object not found.'
), ),
info=gettext( info=self.not_found_error_msg()
'The specified policy object could not be found.\n'
)
) )
# drop policy # drop policy

View File

@@ -149,6 +149,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
* operations - function routes mappings defined. * operations - function routes mappings defined.
""" """
node_type = blueprint.node_type node_type = blueprint.node_type
node_label = "Rule"
parent_ids = [ parent_ids = [
{'type': 'int', 'id': 'gid'}, {'type': 'int', 'id': 'gid'},
@@ -242,7 +243,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
if len(rset['rows']) == 0: if len(rset['rows']) == 0:
return gone(gettext("""Could not find the rule in the table.""")) return gone(self.not_found_error_msg())
res = self.blueprint.generate_browser_node( res = self.blueprint.generate_browser_node(
rset['rows'][0]['oid'], rset['rows'][0]['oid'],
@@ -313,8 +314,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
return False, internal_server_error(errormsg=res) return False, internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return False, gone( return False, gone(self.not_found_error_msg())
gettext("""Could not find the rule in the table."""))
return True, parse_rule_definition(res) return True, parse_rule_definition(res)
@@ -424,9 +424,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
errormsg=gettext( errormsg=gettext(
'Error: Object not found.' 'Error: Object not found.'
), ),
info=gettext( info=self.not_found_error_msg()
'The specified rule could not be found.\n'
)
) )
# drop rule # drop rule
@@ -481,7 +479,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone(gettext("""Could not find the rule in the table.""")) return gone(self.not_found_error_msg())
res_data = parse_rule_definition(res) res_data = parse_rule_definition(res)
SQL = render_template("/".join( SQL = render_template("/".join(
@@ -502,9 +500,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("""Could not find the rule in the table.""")
)
res_data = parse_rule_definition(res) res_data = parse_rule_definition(res)
old_data = res_data old_data = res_data
@@ -544,9 +540,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("""Could not find the rule in the table.""")
)
res_data = parse_rule_definition(res) res_data = parse_rule_definition(res)
if data: if data:

View File

@@ -215,6 +215,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
node_type = blueprint.node_type node_type = blueprint.node_type
node_label = "Trigger"
parent_ids = [ parent_ids = [
{'type': 'int', 'id': 'gid'}, {'type': 'int', 'id': 'gid'},
@@ -387,9 +388,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
if len(rset['rows']) == 0: if len(rset['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("""Could not find the trigger in the table.""")
)
res = self.blueprint.generate_browser_node( res = self.blueprint.generate_browser_node(
rset['rows'][0]['oid'], rset['rows'][0]['oid'],
@@ -487,8 +486,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
return False, internal_server_error(errormsg=res) return False, internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return False, gone( return False, gone(self.not_found_error_msg())
gettext("""Could not find the trigger in the table."""))
# Making copy of output for future use # Making copy of output for future use
data = dict(res['rows'][0]) data = dict(res['rows'][0])
@@ -545,7 +543,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
data['schema'] = self.schema data['schema'] = self.schema
data['table'] = self.table data['table'] = self.table
if len(data['table']) == 0: if len(data['table']) == 0:
return gone(gettext("The specified object could not be found.")) return gone(self.not_found_error_msg())
try: try:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
@@ -622,9 +620,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
errormsg=gettext( errormsg=gettext(
'Error: Object not found.' 'Error: Object not found.'
), ),
info=gettext( info=self.not_found_error_msg()
'The specified trigger could not be found.\n'
)
) )
data = dict(res['rows'][0]) data = dict(res['rows'][0])
@@ -704,8 +700,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("""Could not find the trigger in the table."""))
# Making copy of output for future use # Making copy of output for future use
data = dict(res['rows'][0]) data = dict(res['rows'][0])
@@ -863,9 +858,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("""Could not find the trigger in the table.""")
)
o_data = dict(res['rows'][0]) o_data = dict(res['rows'][0])

View File

@@ -416,7 +416,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
if len(rset['rows']) == 0: if len(rset['rows']) == 0:
return gone(gettext("""Could not find the view.""")) return gone(self.not_found_error_msg())
res = self.blueprint.generate_browser_node( res = self.blueprint.generate_browser_node(
rset['rows'][0]['oid'], rset['rows'][0]['oid'],
@@ -489,7 +489,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
return False, internal_server_error(errormsg=res) return False, internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return False, gone(gettext("""Could not find the view.""")) return False, gone(self.not_found_error_msg())
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, self._SQL_PREFIX + self._ACL_SQL]), vid=vid) [self.template_path, self._SQL_PREFIX + self._ACL_SQL]), vid=vid)
@@ -669,9 +669,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
errormsg=gettext( errormsg=gettext(
'Error: Object not found.' 'Error: Object not found.'
), ),
info=gettext( info=self.not_found_error_msg()
'The specified view could not be found.\n'
)
) )
# drop view # drop view
@@ -790,9 +788,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
if not status: if not status:
return None, internal_server_error(errormsg=res) return None, internal_server_error(errormsg=res)
elif len(res['rows']) == 0: elif len(res['rows']) == 0:
return None, gone( return None, gone(self.not_found_error_msg())
gettext("Could not find the view on the server.")
)
old_data = res['rows'][0] old_data = res['rows'][0]
ViewNode._get_info_from_data(data, res) ViewNode._get_info_from_data(data, res)
@@ -1389,9 +1385,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("Could not find the view on the server.")
)
result = res['rows'][0] result = res['rows'][0]
@@ -1548,9 +1542,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("Could not find the view on the server.")
)
data_view = res['rows'][0] data_view = res['rows'][0]
SQL = render_template( SQL = render_template(
@@ -1609,9 +1601,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("Could not find the view on the server.")
)
data_view = res['rows'][0] data_view = res['rows'][0]
@@ -2072,8 +2062,7 @@ class MViewNode(ViewNode, VacuumSettings):
return False, internal_server_error(errormsg=res) return False, internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return False, gone( return False, gone(self.not_found_error_msg())
gettext("""Could not find the materialized view."""))
# Set value based on # Set value based on
# x: No set, t: true, f: false # x: No set, t: true, f: false
@@ -2178,9 +2167,7 @@ class MViewNode(ViewNode, VacuumSettings):
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
if len(res['rows']) == 0: if len(res['rows']) == 0:
return gone( return gone(self.not_found_error_msg())
gettext("""Could not find the materialized view.""")
)
# Refresh view # Refresh view
SQL = render_template( SQL = render_template(

View File

@@ -20,7 +20,7 @@ from pgadmin.utils.ajax import precondition_required
from pgadmin.utils.driver import get_driver from pgadmin.utils.driver import get_driver
from pgadmin.utils.menu import Panel from pgadmin.utils.menu import Panel
from pgadmin.utils.preferences import Preferences from pgadmin.utils.preferences import Preferences
from pgadmin.utils.constants import PREF_LABEL_DISPLAY from pgadmin.utils.constants import PREF_LABEL_DISPLAY, MIMETYPE_APP_JS
from config import PG_DEFAULT_DRIVER from config import PG_DEFAULT_DRIVER
@@ -247,7 +247,7 @@ def script():
_=gettext _=gettext
), ),
status=200, status=200,
mimetype="application/javascript" mimetype=MIMETYPE_APP_JS
) )

View File

@@ -16,6 +16,7 @@ from pgadmin.utils import PgAdminModule
from pgadmin.utils.csrf import pgCSRFProtect from pgadmin.utils.csrf import pgCSRFProtect
from pgadmin.utils.session import cleanup_session_files from pgadmin.utils.session import cleanup_session_files
from pgadmin.misc.themes import get_all_themes from pgadmin.misc.themes import get_all_themes
from pgadmin.utils.constants import MIMETYPE_APP_JS
import config import config
from werkzeug.exceptions import InternalServerError from werkzeug.exceptions import InternalServerError
@@ -146,7 +147,7 @@ def explain_js():
_=gettext _=gettext
), ),
status=200, status=200,
mimetype="application/javascript" mimetype=MIMETYPE_APP_JS
) )

View File

@@ -29,7 +29,7 @@ from pgadmin.utils import PgAdminModule
from pgadmin.utils import get_storage_directory from pgadmin.utils import get_storage_directory
from pgadmin.utils.ajax import make_json_response from pgadmin.utils.ajax import make_json_response
from pgadmin.utils.preferences import Preferences from pgadmin.utils.preferences import Preferences
from pgadmin.utils.constants import PREF_LABEL_OPTIONS from pgadmin.utils.constants import PREF_LABEL_OPTIONS, MIMETYPE_APP_JS
# Checks if platform is Windows # Checks if platform is Windows
if _platform == "win32": if _platform == "win32":
@@ -196,7 +196,7 @@ def utility():
return Response(response=render_template( return Response(response=render_template(
"file_manager/js/utility.js", _=gettext), "file_manager/js/utility.js", _=gettext),
status=200, status=200,
mimetype="application/javascript") mimetype=MIMETYPE_APP_JS)
@blueprint.route("/file_manager.js") @blueprint.route("/file_manager.js")
@@ -206,7 +206,7 @@ def file_manager_js():
return Response(response=render_template( return Response(response=render_template(
"file_manager/js/file_manager.js", _=gettext), "file_manager/js/file_manager.js", _=gettext),
status=200, status=200,
mimetype="application/javascript") mimetype=MIMETYPE_APP_JS)
@blueprint.route("/en.json") @blueprint.route("/en.json")
@@ -225,7 +225,7 @@ def file_manager_config_js():
return Response(response=render_template( return Response(response=render_template(
"file_manager/js/file_manager_config.js", _=gettext), "file_manager/js/file_manager_config.js", _=gettext),
status=200, status=200,
mimetype="application/javascript") mimetype=MIMETYPE_APP_JS)
@blueprint.route("/<int:trans_id>/file_manager_config.json") @blueprint.route("/<int:trans_id>/file_manager_config.json")

View File

@@ -22,6 +22,7 @@ from pgadmin.utils.ajax import success_return, \
make_response as ajax_response, internal_server_error make_response as ajax_response, internal_server_error
from pgadmin.utils.menu import MenuItem from pgadmin.utils.menu import MenuItem
from pgadmin.utils.preferences import Preferences from pgadmin.utils.preferences import Preferences
from pgadmin.utils.constants import MIMETYPE_APP_JS
MODULE_NAME = 'preferences' MODULE_NAME = 'preferences'
@@ -78,7 +79,7 @@ def script():
return Response( return Response(
response=render_template("preferences/preferences.js", _=gettext), response=render_template("preferences/preferences.js", _=gettext),
status=200, status=200,
mimetype="application/javascript" mimetype=MIMETYPE_APP_JS
) )

View File

@@ -22,6 +22,7 @@ from pgadmin.utils.ajax import make_json_response, bad_request,\
from pgadmin.utils.menu import MenuItem from pgadmin.utils.menu import MenuItem
from pgadmin.model import db, Setting from pgadmin.model import db, Setting
from pgadmin.utils.constants import MIMETYPE_APP_JS
MODULE_NAME = 'settings' MODULE_NAME = 'settings'
@@ -95,7 +96,7 @@ def script():
"""Render the required Javascript""" """Render the required Javascript"""
return Response(response=render_template("settings/settings.js"), return Response(response=render_template("settings/settings.js"),
status=200, status=200,
mimetype="application/javascript") mimetype=MIMETYPE_APP_JS)
@blueprint.route("/store", methods=['POST'], endpoint='store_bulk') @blueprint.route("/store", methods=['POST'], endpoint='store_bulk')

View File

@@ -15,6 +15,7 @@ from flask_babelex import Domain, gettext
from pgadmin.utils import PgAdminModule from pgadmin.utils import PgAdminModule
from pgadmin.utils.ajax import bad_request from pgadmin.utils.ajax import bad_request
from pgadmin.utils.constants import MIMETYPE_APP_JS
MODULE_NAME = 'tools' MODULE_NAME = 'tools'
@@ -73,5 +74,5 @@ def translations():
return Response( return Response(
response=template, response=template,
status=200, status=200,
mimetype="application/javascript" mimetype=MIMETYPE_APP_JS
) )

View File

@@ -24,6 +24,7 @@ from pgadmin.utils.ajax import make_json_response, bad_request
from config import PG_DEFAULT_DRIVER from config import PG_DEFAULT_DRIVER
from pgadmin.model import Server from pgadmin.model import Server
from pgadmin.misc.bgprocess import escape_dquotes_process_arg from pgadmin.misc.bgprocess import escape_dquotes_process_arg
from pgadmin.utils.constants import MIMETYPE_APP_JS
# set template path for sql scripts # set template path for sql scripts
MODULE_NAME = 'backup' MODULE_NAME = 'backup'
@@ -230,7 +231,7 @@ def script():
"backup/js/backup.js", _=_ "backup/js/backup.js", _=_
), ),
status=200, status=200,
mimetype="application/javascript" mimetype=MIMETYPE_APP_JS
) )

View File

@@ -32,6 +32,7 @@ from pgadmin.utils.preferences import Preferences
from pgadmin.settings import get_setting from pgadmin.settings import get_setting
from pgadmin.browser.utils import underscore_unescape from pgadmin.browser.utils import underscore_unescape
from pgadmin.utils.exception import ObjectGone from pgadmin.utils.exception import ObjectGone
from pgadmin.utils.constants import MIMETYPE_APP_JS
MODULE_NAME = 'datagrid' MODULE_NAME = 'datagrid'
@@ -453,7 +454,7 @@ def script():
return Response( return Response(
response=render_template("datagrid/js/datagrid.js", _=gettext), response=render_template("datagrid/js/datagrid.js", _=gettext),
status=200, status=200,
mimetype="application/javascript" mimetype=MIMETYPE_APP_JS
) )

View File

@@ -34,7 +34,7 @@ from pgadmin.tools.debugger.utils.debugger_instance import DebuggerInstance
from pgadmin.browser.server_groups.servers.databases.extensions.utils \ from pgadmin.browser.server_groups.servers.databases.extensions.utils \
import get_extension_details import get_extension_details
from pgadmin.utils.constants import PREF_LABEL_DISPLAY, \ from pgadmin.utils.constants import PREF_LABEL_DISPLAY, \
PREF_LABEL_KEYBOARD_SHORTCUTS PREF_LABEL_KEYBOARD_SHORTCUTS, MIMETYPE_APP_JS
MODULE_NAME = 'debugger' MODULE_NAME = 'debugger'
@@ -280,7 +280,7 @@ def script():
return Response( return Response(
response=render_template("debugger/js/debugger.js", _=gettext), response=render_template("debugger/js/debugger.js", _=gettext),
status=200, status=200,
mimetype="application/javascript" mimetype=MIMETYPE_APP_JS
) )
@@ -291,7 +291,7 @@ def script_debugger_js():
return Response( return Response(
response=render_template("debugger/js/debugger_ui.js", _=gettext), response=render_template("debugger/js/debugger_ui.js", _=gettext),
status=200, status=200,
mimetype="application/javascript" mimetype=MIMETYPE_APP_JS
) )
@@ -305,7 +305,7 @@ def script_debugger_direct_js():
return Response( return Response(
response=render_template("debugger/js/direct.js", _=gettext), response=render_template("debugger/js/direct.js", _=gettext),
status=200, status=200,
mimetype="application/javascript" mimetype=MIMETYPE_APP_JS
) )

View File

@@ -26,6 +26,7 @@ from config import PG_DEFAULT_DRIVER
from pgadmin.utils.ajax import precondition_required from pgadmin.utils.ajax import precondition_required
from functools import wraps from functools import wraps
from pgadmin.utils.preferences import Preferences from pgadmin.utils.preferences import Preferences
from pgadmin.utils.constants import MIMETYPE_APP_JS
# set template path for sql scripts # set template path for sql scripts
MODULE_NAME = 'grant_wizard' MODULE_NAME = 'grant_wizard'
@@ -156,7 +157,7 @@ def script():
return Response(response=render_template( return Response(response=render_template(
"grant_wizard/js/grant_wizard.js", _=gettext), "grant_wizard/js/grant_wizard.js", _=gettext),
status=200, status=200,
mimetype="application/javascript") mimetype=MIMETYPE_APP_JS)
@blueprint.route( @blueprint.route(

View File

@@ -22,6 +22,7 @@ from pgadmin.utils.ajax import make_json_response, bad_request
from config import PG_DEFAULT_DRIVER from config import PG_DEFAULT_DRIVER
from pgadmin.model import Server from pgadmin.model import Server
from pgadmin.utils.constants import MIMETYPE_APP_JS
MODULE_NAME = 'import_export' MODULE_NAME = 'import_export'
@@ -169,7 +170,7 @@ def script():
return Response( return Response(
response=render_template("import_export/js/import_export.js", _=_), response=render_template("import_export/js/import_export.js", _=_),
status=200, status=200,
mimetype="application/javascript" mimetype=MIMETYPE_APP_JS
) )

View File

@@ -21,6 +21,7 @@ from pgadmin.utils.driver import get_driver
from config import PG_DEFAULT_DRIVER from config import PG_DEFAULT_DRIVER
from pgadmin.model import Server from pgadmin.model import Server
from pgadmin.utils.constants import MIMETYPE_APP_JS
MODULE_NAME = 'maintenance' MODULE_NAME = 'maintenance'
@@ -164,7 +165,7 @@ def script():
return Response( return Response(
response=render_template("maintenance/js/maintenance.js", _=_), response=render_template("maintenance/js/maintenance.js", _=_),
status=200, status=200,
mimetype="application/javascript" mimetype=MIMETYPE_APP_JS
) )

View File

@@ -23,6 +23,7 @@ from pgadmin.utils.ajax import make_json_response, bad_request
from config import PG_DEFAULT_DRIVER from config import PG_DEFAULT_DRIVER
from pgadmin.model import Server from pgadmin.model import Server
from pgadmin.utils.constants import MIMETYPE_APP_JS
# set template path for sql scripts # set template path for sql scripts
MODULE_NAME = 'restore' MODULE_NAME = 'restore'
@@ -151,7 +152,7 @@ def script():
"restore/js/restore.js", _=_ "restore/js/restore.js", _=_
), ),
status=200, status=200,
mimetype="application/javascript" mimetype=MIMETYPE_APP_JS
) )

View File

@@ -26,7 +26,7 @@ from pgadmin.tools.schema_diff.model import SchemaDiffModel
from config import PG_DEFAULT_DRIVER from config import PG_DEFAULT_DRIVER
from pgadmin.utils.driver import get_driver from pgadmin.utils.driver import get_driver
from pgadmin.utils.preferences import Preferences from pgadmin.utils.preferences import Preferences
from pgadmin.utils.constants import PREF_LABEL_DISPLAY from pgadmin.utils.constants import PREF_LABEL_DISPLAY, MIMETYPE_APP_JS
MODULE_NAME = 'schema_diff' MODULE_NAME = 'schema_diff'
@@ -140,7 +140,7 @@ def script():
return Response( return Response(
response=render_template("schema_diff/js/schema_diff.js", _=gettext), response=render_template("schema_diff/js/schema_diff.js", _=gettext),
status=200, status=200,
mimetype="application/javascript" mimetype=MIMETYPE_APP_JS
) )

View File

@@ -44,6 +44,7 @@ from pgadmin.tools.sqleditor.utils.query_tool_fs_utils import \
read_file_generator read_file_generator
from pgadmin.tools.sqleditor.utils.filter_dialog import FilterDialog from pgadmin.tools.sqleditor.utils.filter_dialog import FilterDialog
from pgadmin.tools.sqleditor.utils.query_history import QueryHistory from pgadmin.tools.sqleditor.utils.query_history import QueryHistory
from pgadmin.utils.constants import MIMETYPE_APP_JS
MODULE_NAME = 'sqleditor' MODULE_NAME = 'sqleditor'
@@ -1172,7 +1173,7 @@ def script():
_=gettext _=gettext
), ),
status=200, status=200,
mimetype="application/javascript" mimetype=MIMETYPE_APP_JS
) )

View File

@@ -24,7 +24,7 @@ from pgadmin.utils import PgAdminModule
from pgadmin.utils.ajax import make_response as ajax_response, \ from pgadmin.utils.ajax import make_response as ajax_response, \
make_json_response, bad_request, internal_server_error make_json_response, bad_request, internal_server_error
from pgadmin.utils.csrf import pgCSRFProtect from pgadmin.utils.csrf import pgCSRFProtect
from pgadmin.utils.constants import MIMETYPE_APP_JS
from pgadmin.model import db, Role, User, UserPreference, Server, \ from pgadmin.model import db, Role, User, UserPreference, Server, \
ServerGroup, Process, Setting ServerGroup, Process, Setting
@@ -150,7 +150,7 @@ def script():
user_id=current_user.id user_id=current_user.id
), ),
status=200, status=200,
mimetype="application/javascript" mimetype=MIMETYPE_APP_JS
) )
@@ -178,7 +178,7 @@ def current_user_info():
auth_sources=config.AUTHENTICATION_SOURCES, auth_sources=config.AUTHENTICATION_SOURCES,
), ),
status=200, status=200,
mimetype="application/javascript" mimetype=MIMETYPE_APP_JS
) )