mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed code smell 'Define a constant instead of duplicating this literal' reported by SonarQube.
This commit is contained in:
@@ -172,6 +172,8 @@ class LanguageView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
language node.
|
||||
"""
|
||||
|
||||
_NOT_FOUND_LANG_INFORMATION = \
|
||||
gettext("Could not find the language information.")
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
@@ -366,9 +368,7 @@ class LanguageView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return False, internal_server_error(errormsg=res)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return False, gone(
|
||||
gettext("Could not find the language information.")
|
||||
)
|
||||
return False, gone(self._NOT_FOUND_LANG_INFORMATION)
|
||||
|
||||
res['rows'][0]['is_sys_obj'] = (
|
||||
res['rows'][0]['oid'] <= self.datlastsysoid)
|
||||
@@ -652,9 +652,7 @@ class LanguageView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext("Could not find the language information.")
|
||||
)
|
||||
return gone(self._NOT_FOUND_LANG_INFORMATION)
|
||||
|
||||
LanguageView._parse_privileges(data)
|
||||
|
||||
@@ -740,9 +738,7 @@ class LanguageView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext("Could not find the language information.")
|
||||
)
|
||||
return gone(self._NOT_FOUND_LANG_INFORMATION)
|
||||
|
||||
# Making copy of output for future use
|
||||
old_data = dict(res['rows'][0])
|
||||
|
||||
@@ -148,6 +148,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
"""
|
||||
|
||||
node_type = blueprint.node_type
|
||||
node_label = "Collation"
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
@@ -306,7 +307,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
status=200
|
||||
)
|
||||
|
||||
return gone(gettext("Could not find the specified collation."))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, did, scid, coid):
|
||||
@@ -352,8 +353,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return False, internal_server_error(errormsg=res)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return False, gone(gettext("Could not find the collation "
|
||||
"object in the database."))
|
||||
return False, gone(self.not_found_error_msg())
|
||||
|
||||
res['rows'][0]['is_sys_obj'] = (
|
||||
res['rows'][0]['oid'] <= self.datlastsysoid)
|
||||
@@ -536,9 +536,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return gone(gettext(
|
||||
"Could not find the collation object in the database."
|
||||
))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
data = res['rows'][0]
|
||||
|
||||
@@ -660,10 +658,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext(
|
||||
"Could not find the collation object in the database.")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
old_data = res['rows'][0]
|
||||
SQL = render_template(
|
||||
@@ -712,9 +707,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext("Could not find the collation object in the database.")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
data = res['rows'][0]
|
||||
|
||||
|
||||
@@ -142,6 +142,7 @@ class DomainView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
|
||||
"""
|
||||
|
||||
node_type = blueprint.node_type
|
||||
node_label = "Domain"
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
@@ -384,7 +385,7 @@ class DomainView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
|
||||
status=200
|
||||
)
|
||||
|
||||
return gone(gettext("Could not find the specified domain."))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, did, scid, doid):
|
||||
@@ -647,9 +648,7 @@ AND relkind != 'c'))"""
|
||||
errormsg=gettext(
|
||||
'Error: Object not found.'
|
||||
),
|
||||
info=gettext(
|
||||
'The specified domain could not be found.\n'
|
||||
)
|
||||
info=self.not_found_error_msg()
|
||||
)
|
||||
|
||||
name = res['rows'][0]['name']
|
||||
@@ -734,9 +733,7 @@ AND relkind != 'c'))"""
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext("Could not find the specified domain.")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
data = res['rows'][0]
|
||||
|
||||
@@ -832,9 +829,7 @@ AND relkind != 'c'))"""
|
||||
if not status:
|
||||
return False, internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext("Could not find the specified domain.")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
old_data = res['rows'][0]
|
||||
|
||||
|
||||
@@ -153,6 +153,7 @@ class DomainConstraintView(PGChildNodeView):
|
||||
- Returns the dependencies for the Domain Constraint object.
|
||||
"""
|
||||
node_type = blueprint.node_type
|
||||
node_label = "Domain Constraint"
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
@@ -374,9 +375,7 @@ class DomainConstraintView(PGChildNodeView):
|
||||
status=200
|
||||
)
|
||||
|
||||
return gone(
|
||||
gettext("Could not find the specified domain constraint.")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, did, scid, doid, coid):
|
||||
@@ -400,10 +399,7 @@ class DomainConstraintView(PGChildNodeView):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return gone(gettext(
|
||||
"Could not find the specified domain constraint."
|
||||
)
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
data = res['rows'][0]
|
||||
data['is_sys_obj'] = (
|
||||
@@ -505,10 +501,7 @@ class DomainConstraintView(PGChildNodeView):
|
||||
errormsg=gettext(
|
||||
'Error: Object not found.'
|
||||
),
|
||||
info=gettext(
|
||||
'The specified domain constraint '
|
||||
'could not be found.\n'
|
||||
)
|
||||
info=self.not_found_error_msg()
|
||||
)
|
||||
|
||||
data = res['rows'][0]
|
||||
@@ -609,10 +602,7 @@ class DomainConstraintView(PGChildNodeView):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
return gone(gettext(
|
||||
"Could not find the specified domain constraint."
|
||||
)
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
data = res['rows'][0]
|
||||
|
||||
@@ -681,10 +671,7 @@ class DomainConstraintView(PGChildNodeView):
|
||||
if not status:
|
||||
return False, internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
return False, gone(gettext(
|
||||
"Could not find the specified domain constraint."
|
||||
)
|
||||
)
|
||||
return False, gone(self.not_found_error_msg())
|
||||
|
||||
old_data = res['rows'][0]
|
||||
|
||||
@@ -723,8 +710,7 @@ class DomainConstraintView(PGChildNodeView):
|
||||
if not status:
|
||||
return False, internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
raise ObjectGone(
|
||||
gettext("The specified domain could not be found."))
|
||||
raise ObjectGone(self.not_found_error_msg('Domain'))
|
||||
|
||||
return res['rows'][0]['schema'], res['rows'][0]['domain']
|
||||
|
||||
|
||||
@@ -178,6 +178,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
||||
"""
|
||||
|
||||
node_type = blueprint.node_type
|
||||
node_label = "Foreign Table"
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
@@ -442,9 +443,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
||||
status=200
|
||||
)
|
||||
|
||||
return gone(gettext(
|
||||
'Could not find the specified foreign table.'
|
||||
))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, did, scid, foid):
|
||||
@@ -462,8 +461,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
||||
if not status:
|
||||
return data
|
||||
if not data:
|
||||
return gone(
|
||||
gettext("The specified foreign table could not be found."))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
return ajax_response(
|
||||
response=data,
|
||||
@@ -745,9 +743,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
||||
errormsg=gettext(
|
||||
'Error: Object not found.'
|
||||
),
|
||||
info=gettext(
|
||||
'The specified foreign table could not be found.\n'
|
||||
)
|
||||
info=self.not_found_error_msg()
|
||||
)
|
||||
|
||||
name = res['rows'][0]['name']
|
||||
@@ -841,8 +837,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
||||
if not status:
|
||||
return data
|
||||
if not data:
|
||||
return gone(
|
||||
gettext("The specified foreign table could not be found."))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
col_data = []
|
||||
for c in data['columns']:
|
||||
@@ -1024,8 +1019,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
||||
if not status:
|
||||
return old_data
|
||||
elif not old_data:
|
||||
return gone(
|
||||
gettext("The specified foreign table could not be found."))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
if is_schema_diff:
|
||||
data['is_schema_diff'] = True
|
||||
@@ -1336,8 +1330,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
||||
if not status:
|
||||
return data
|
||||
if not data:
|
||||
return gone(
|
||||
gettext("The specified foreign table could not be found."))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
columns = []
|
||||
for c in data['columns']:
|
||||
@@ -1374,8 +1367,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
||||
if not status:
|
||||
return data
|
||||
if not data:
|
||||
return gone(
|
||||
gettext("The specified foreign table could not be found."))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
columns = []
|
||||
values = []
|
||||
@@ -1417,8 +1409,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
||||
if not status:
|
||||
return data
|
||||
if not data:
|
||||
return gone(
|
||||
gettext("The specified foreign table could not be found."))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
columns = []
|
||||
|
||||
@@ -1464,8 +1455,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
|
||||
if not status:
|
||||
return data
|
||||
if not data:
|
||||
return gone(
|
||||
gettext("The specified foreign table could not be found."))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
sql = u"DELETE FROM {0}\n\tWHERE <condition>;".format(
|
||||
self.qtIdent(self.conn, data['basensp'], data['name'])
|
||||
|
||||
@@ -157,6 +157,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
"""
|
||||
|
||||
node_type = blueprint.node_type
|
||||
node_label = "FTS Template"
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
@@ -281,9 +282,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
),
|
||||
status=200
|
||||
)
|
||||
return gone(
|
||||
gettext("Could not find the requested FTS template.")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, did, scid, tid):
|
||||
@@ -323,9 +322,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return False, internal_server_error(errormsg=res)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return False, gone(
|
||||
gettext("Could not find the requested FTS template.")
|
||||
)
|
||||
return False, gone(self.not_found_error_msg())
|
||||
res['rows'][0]['is_sys_obj'] = (
|
||||
res['rows'][0]['oid'] <= self.datlastsysoid)
|
||||
return True, res['rows'][0]
|
||||
@@ -486,9 +483,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
errormsg=gettext(
|
||||
'Error: Object not found.'
|
||||
),
|
||||
info=gettext(
|
||||
'The specified FTS template could not be found.\n'
|
||||
)
|
||||
info=self.not_found_error_msg()
|
||||
)
|
||||
|
||||
# Drop fts template
|
||||
@@ -621,9 +616,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
elif len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext("Could not find the requested FTS template.")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
old_data = res['rows'][0]
|
||||
if 'schema' not in data:
|
||||
|
||||
@@ -82,6 +82,7 @@ blueprint = PackageModule(__name__)
|
||||
|
||||
class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
node_type = blueprint.node_type
|
||||
node_label = "Package"
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
@@ -213,7 +214,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if pkgid is not None:
|
||||
if len(rset['rows']) == 0:
|
||||
return gone(
|
||||
errormsg=_("Could not find the package.")
|
||||
errormsg=self.not_found_error_msg()
|
||||
)
|
||||
|
||||
row = rset['rows'][0]
|
||||
@@ -267,7 +268,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
|
||||
if len(rset['rows']) == 0:
|
||||
return gone(
|
||||
errormsg=_("Could not find the package in the database.")
|
||||
errormsg=self.not_found_error_msg()
|
||||
)
|
||||
|
||||
for row in rset['rows']:
|
||||
@@ -325,7 +326,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
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(
|
||||
@@ -459,9 +460,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
errormsg=_(
|
||||
'Error: Object not found.'
|
||||
),
|
||||
info=_(
|
||||
'The specified package could not be found.\n'
|
||||
)
|
||||
info=self.not_found_error_msg()
|
||||
)
|
||||
|
||||
res['rows'][0]['schema'] = self.schema
|
||||
@@ -635,7 +634,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return internal_server_error(errormsg=res)
|
||||
elif len(res['rows']) == 0:
|
||||
return gone(
|
||||
errormsg=_("Could not find the package in the database.")
|
||||
errormsg=self.not_found_error_msg()
|
||||
)
|
||||
|
||||
res['rows'][0]['pkgheadsrc'] = self.get_inner(
|
||||
@@ -700,7 +699,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
errormsg=_("Could not find the package in the database.")
|
||||
errormsg=self.not_found_error_msg()
|
||||
)
|
||||
|
||||
res['rows'][0]['pkgheadsrc'] = self.get_inner(
|
||||
|
||||
@@ -90,6 +90,7 @@ blueprint = SequenceModule(__name__)
|
||||
|
||||
class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
node_type = blueprint.node_type
|
||||
node_label = "Sequence"
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
@@ -208,7 +209,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
|
||||
if seid is not None:
|
||||
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]
|
||||
return make_json_response(
|
||||
data=self.blueprint.generate_browser_node(
|
||||
@@ -303,8 +304,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return False, internal_server_error(errormsg=res)
|
||||
elif len(res['rows']) == 0:
|
||||
return False, gone(
|
||||
_("Could not find the sequence in the database."))
|
||||
return False, gone(self.not_found_error_msg())
|
||||
|
||||
res['rows'][0]['is_sys_obj'] = (
|
||||
res['rows'][0]['oid'] <= self.datlastsysoid)
|
||||
@@ -487,9 +487,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
errormsg=_(
|
||||
'Error: Object not found.'
|
||||
),
|
||||
info=_(
|
||||
'The specified sequence could not be found.\n'
|
||||
)
|
||||
info=self.not_found_error_msg()
|
||||
)
|
||||
|
||||
sql = render_template(
|
||||
@@ -638,7 +636,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
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
|
||||
old_data = dict(res['rows'][0])
|
||||
@@ -711,7 +709,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
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']:
|
||||
sql = render_template(
|
||||
|
||||
@@ -147,6 +147,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
"""
|
||||
|
||||
node_type = blueprint.node_type
|
||||
node_label = "Synonym"
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
@@ -304,9 +305,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return internal_server_error(errormsg=rset)
|
||||
|
||||
if len(rset['rows']) == 0:
|
||||
return gone(
|
||||
gettext("""Could not find the Synonym node.""")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
for row in rset['rows']:
|
||||
return make_json_response(
|
||||
@@ -416,9 +415,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return False, internal_server_error(errormsg=res)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return False, gone(
|
||||
gettext('The specified synonym could not be found.')
|
||||
)
|
||||
return False, gone(self.not_found_error_msg())
|
||||
|
||||
res['rows'][0]['is_sys_obj'] = (
|
||||
res['rows'][0]['oid'] <= self.datlastsysoid)
|
||||
@@ -523,9 +520,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if len(res['rows']) > 0:
|
||||
data = res['rows'][0]
|
||||
else:
|
||||
return gone(
|
||||
gettext('The specified synonym could not be found.')
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
SQL = render_template("/".join([self.template_path,
|
||||
self._DELETE_SQL]),
|
||||
@@ -628,9 +623,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext("Could not find the synonym on the server.")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
old_data = res['rows'][0]
|
||||
name = old_data['name']
|
||||
# If target schema/object is not present then take it from
|
||||
@@ -684,9 +677,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if len(res['rows']) > 0:
|
||||
data = res['rows'][0]
|
||||
else:
|
||||
return gone(
|
||||
gettext('The specified synonym could not be found.')
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
SQL = render_template("/".join([self.template_path,
|
||||
self._CREATE_SQL]),
|
||||
|
||||
@@ -158,6 +158,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
"""
|
||||
|
||||
node_type = blueprint.node_type
|
||||
node_label = "Column"
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
@@ -280,7 +281,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
if clid is not None:
|
||||
if len(rset['rows']) == 0:
|
||||
return gone(
|
||||
errormsg=gettext("Could not find the column.")
|
||||
errormsg=self.not_found_error_msg()
|
||||
)
|
||||
row = rset['rows'][0]
|
||||
return make_json_response(
|
||||
@@ -339,7 +340,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
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
|
||||
data = dict(res['rows'][0])
|
||||
@@ -470,9 +471,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
errormsg=gettext(
|
||||
'Error: Object not found.'
|
||||
),
|
||||
info=gettext(
|
||||
'The specified column could not be found.\n'
|
||||
)
|
||||
info=self.not_found_error_msg()
|
||||
)
|
||||
|
||||
data = dict(res['rows'][0])
|
||||
@@ -679,9 +678,8 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
elif len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext("Could not find the column on the server.")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
old_data = dict(res['rows'][0])
|
||||
|
||||
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:
|
||||
return internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext("Could not find the column on the server.")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
data = dict(res['rows'][0])
|
||||
# We do not want to display length as -1 in create query
|
||||
@@ -884,9 +880,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext("Could not find the column on the server.")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
data = dict(res['rows'][0])
|
||||
column = data['name']
|
||||
|
||||
@@ -218,6 +218,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
"""
|
||||
|
||||
node_type = blueprint.node_type
|
||||
node_label = "Compound Trigger"
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
@@ -351,9 +352,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return internal_server_error(errormsg=rset)
|
||||
|
||||
if len(rset['rows']) == 0:
|
||||
return gone(gettext(
|
||||
"""Could not find the compound trigger in the table.""")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
res = self.blueprint.generate_browser_node(
|
||||
rset['rows'][0]['oid'],
|
||||
@@ -434,8 +433,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return internal_server_error(errormsg=data)
|
||||
|
||||
if 'rows' in data and len(data['rows']) == 0:
|
||||
return gone(gettext(
|
||||
"""Could not find the compound trigger in the table."""))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
return ajax_response(
|
||||
response=data,
|
||||
@@ -589,10 +587,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
errormsg=gettext(
|
||||
'Error: Object not found.'
|
||||
),
|
||||
info=gettext(
|
||||
'The specified compound trigger could not be '
|
||||
'found.\n'
|
||||
)
|
||||
info=self.not_found_error_msg()
|
||||
)
|
||||
|
||||
data = dict(res['rows'][0])
|
||||
@@ -670,8 +665,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return gone(gettext(
|
||||
"""Could not find the compound trigger in the table."""))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
# Making copy of output for future use
|
||||
data = dict(res['rows'][0])
|
||||
@@ -790,9 +784,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
return gone(gettext(
|
||||
"""Could not find the compound trigger in the table.""")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
o_data = dict(res['rows'][0])
|
||||
|
||||
@@ -912,8 +904,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
elif len(res['rows']) == 0:
|
||||
return gone(gettext("Could not find the compound "
|
||||
"trigger in the table."))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
data = dict(res['rows'][0])
|
||||
# Adding parent into data dict,
|
||||
|
||||
@@ -193,6 +193,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
"""
|
||||
|
||||
node_type = blueprint.node_type
|
||||
node_label = "Index"
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
@@ -425,7 +426,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return internal_server_error(errormsg=rset)
|
||||
|
||||
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(
|
||||
rset['rows'][0]['oid'],
|
||||
@@ -521,8 +522,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return False, internal_server_error(errormsg=res)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return False, gone(
|
||||
gettext("""Could not find the index in the table."""))
|
||||
return False, gone(self.not_found_error_msg())
|
||||
|
||||
# Making copy of output for future use
|
||||
data = dict(res['rows'][0])
|
||||
@@ -705,9 +705,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
errormsg=gettext(
|
||||
'Error: Object not found.'
|
||||
),
|
||||
info=gettext(
|
||||
'The specified index could not be found.\n'
|
||||
)
|
||||
info=self.not_found_error_msg()
|
||||
)
|
||||
|
||||
data = dict(res['rows'][0])
|
||||
@@ -969,9 +967,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext("""Could not find the index in the table.""")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
data = dict(res['rows'][0])
|
||||
index = data['name']
|
||||
|
||||
@@ -209,7 +209,7 @@
|
||||
"mock_data": {},
|
||||
"expected_data": {
|
||||
"status_code": 410,
|
||||
"error_msg": "Could not find the index in the table.",
|
||||
"error_msg": "could not find the specified index.",
|
||||
"test_result_data": {}
|
||||
},
|
||||
"is_list": false
|
||||
@@ -528,7 +528,7 @@
|
||||
"mock_data": {},
|
||||
"expected_data": {
|
||||
"status_code": 410,
|
||||
"error_msg": "Could not find the index in the table.",
|
||||
"error_msg": "could not find the specified index.",
|
||||
"test_result_data": {
|
||||
}
|
||||
},
|
||||
|
||||
@@ -197,6 +197,7 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
|
||||
"""
|
||||
|
||||
node_type = blueprint.node_type
|
||||
node_label = "Partition"
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
@@ -321,9 +322,7 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
|
||||
|
||||
if ptid is not None:
|
||||
if len(rset['rows']) == 0:
|
||||
return gone(gettext(
|
||||
"The specified partitioned table could not be found."
|
||||
))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
return make_json_response(
|
||||
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)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return gone(gettext(
|
||||
"The specified partitioned table could not be found."))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
return super(PartitionsView, self).properties(
|
||||
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)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return gone(gettext(
|
||||
"The specified partitioned table could not be found."))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
data = res['rows'][0]
|
||||
|
||||
|
||||
@@ -148,6 +148,7 @@ class RowSecurityView(PGChildNodeView):
|
||||
"""
|
||||
|
||||
node_type = blueprint.node_type
|
||||
node_label = "RLS Policy"
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
@@ -249,7 +250,7 @@ class RowSecurityView(PGChildNodeView):
|
||||
return internal_server_error(errormsg=rset)
|
||||
|
||||
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(
|
||||
rset['rows'][0]['oid'],
|
||||
@@ -321,8 +322,7 @@ class RowSecurityView(PGChildNodeView):
|
||||
return False, internal_server_error(errormsg=res)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return False, gone(
|
||||
gettext("""Could not find the policy in the table."""))
|
||||
return False, gone(self.not_found_error_msg())
|
||||
|
||||
data = dict(res['rows'][0])
|
||||
|
||||
@@ -483,9 +483,7 @@ class RowSecurityView(PGChildNodeView):
|
||||
errormsg=gettext(
|
||||
'Error: Object not found.'
|
||||
),
|
||||
info=gettext(
|
||||
'The specified policy object could not be found.\n'
|
||||
)
|
||||
info=self.not_found_error_msg()
|
||||
)
|
||||
|
||||
# drop policy
|
||||
|
||||
@@ -149,6 +149,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
* operations - function routes mappings defined.
|
||||
"""
|
||||
node_type = blueprint.node_type
|
||||
node_label = "Rule"
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
@@ -242,7 +243,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return internal_server_error(errormsg=rset)
|
||||
|
||||
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(
|
||||
rset['rows'][0]['oid'],
|
||||
@@ -313,8 +314,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return False, internal_server_error(errormsg=res)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return False, gone(
|
||||
gettext("""Could not find the rule in the table."""))
|
||||
return False, gone(self.not_found_error_msg())
|
||||
|
||||
return True, parse_rule_definition(res)
|
||||
|
||||
@@ -424,9 +424,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
errormsg=gettext(
|
||||
'Error: Object not found.'
|
||||
),
|
||||
info=gettext(
|
||||
'The specified rule could not be found.\n'
|
||||
)
|
||||
info=self.not_found_error_msg()
|
||||
)
|
||||
|
||||
# drop rule
|
||||
@@ -481,7 +479,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
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)
|
||||
SQL = render_template("/".join(
|
||||
@@ -502,9 +500,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
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)
|
||||
|
||||
old_data = res_data
|
||||
@@ -544,9 +540,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
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)
|
||||
|
||||
if data:
|
||||
|
||||
@@ -215,6 +215,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
"""
|
||||
|
||||
node_type = blueprint.node_type
|
||||
node_label = "Trigger"
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
@@ -387,9 +388,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return internal_server_error(errormsg=rset)
|
||||
|
||||
if len(rset['rows']) == 0:
|
||||
return gone(
|
||||
gettext("""Could not find the trigger in the table.""")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
res = self.blueprint.generate_browser_node(
|
||||
rset['rows'][0]['oid'],
|
||||
@@ -487,8 +486,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return False, internal_server_error(errormsg=res)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return False, gone(
|
||||
gettext("""Could not find the trigger in the table."""))
|
||||
return False, gone(self.not_found_error_msg())
|
||||
|
||||
# Making copy of output for future use
|
||||
data = dict(res['rows'][0])
|
||||
@@ -545,7 +543,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
data['schema'] = self.schema
|
||||
data['table'] = self.table
|
||||
if len(data['table']) == 0:
|
||||
return gone(gettext("The specified object could not be found."))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
try:
|
||||
SQL = render_template("/".join([self.template_path,
|
||||
@@ -622,9 +620,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
errormsg=gettext(
|
||||
'Error: Object not found.'
|
||||
),
|
||||
info=gettext(
|
||||
'The specified trigger could not be found.\n'
|
||||
)
|
||||
info=self.not_found_error_msg()
|
||||
)
|
||||
|
||||
data = dict(res['rows'][0])
|
||||
@@ -704,8 +700,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext("""Could not find the trigger in the table."""))
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
# Making copy of output for future use
|
||||
data = dict(res['rows'][0])
|
||||
@@ -863,9 +858,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext("""Could not find the trigger in the table.""")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
o_data = dict(res['rows'][0])
|
||||
|
||||
|
||||
@@ -416,7 +416,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
|
||||
return internal_server_error(errormsg=rset)
|
||||
|
||||
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(
|
||||
rset['rows'][0]['oid'],
|
||||
@@ -489,7 +489,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
|
||||
return False, internal_server_error(errormsg=res)
|
||||
|
||||
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(
|
||||
[self.template_path, self._SQL_PREFIX + self._ACL_SQL]), vid=vid)
|
||||
@@ -669,9 +669,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
|
||||
errormsg=gettext(
|
||||
'Error: Object not found.'
|
||||
),
|
||||
info=gettext(
|
||||
'The specified view could not be found.\n'
|
||||
)
|
||||
info=self.not_found_error_msg()
|
||||
)
|
||||
|
||||
# drop view
|
||||
@@ -790,9 +788,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return None, internal_server_error(errormsg=res)
|
||||
elif len(res['rows']) == 0:
|
||||
return None, gone(
|
||||
gettext("Could not find the view on the server.")
|
||||
)
|
||||
return None, gone(self.not_found_error_msg())
|
||||
old_data = res['rows'][0]
|
||||
|
||||
ViewNode._get_info_from_data(data, res)
|
||||
@@ -1389,9 +1385,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext("Could not find the view on the server.")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
result = res['rows'][0]
|
||||
|
||||
@@ -1548,9 +1542,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext("Could not find the view on the server.")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
data_view = res['rows'][0]
|
||||
|
||||
SQL = render_template(
|
||||
@@ -1609,9 +1601,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext("Could not find the view on the server.")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
data_view = res['rows'][0]
|
||||
|
||||
@@ -2072,8 +2062,7 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
return False, internal_server_error(errormsg=res)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return False, gone(
|
||||
gettext("""Could not find the materialized view."""))
|
||||
return False, gone(self.not_found_error_msg())
|
||||
|
||||
# Set value based on
|
||||
# x: No set, t: true, f: false
|
||||
@@ -2178,9 +2167,7 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
gettext("""Could not find the materialized view.""")
|
||||
)
|
||||
return gone(self.not_found_error_msg())
|
||||
|
||||
# Refresh view
|
||||
SQL = render_template(
|
||||
|
||||
Reference in New Issue
Block a user