mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed following SoanrQube issues
1) Rename field "node_type" to prevent any misunderstanding/clash with field "NODE_TYPE" defined. 2) Define a constant instead of duplicating this literal. Solution: 1) Rename the field "NODE_TYPE" and "COLLECTION_LABEL" to "_NODE_TYPE" and "_COLLECTION_LABEL" 2) Declare the constant in PGChildNodeView for SQL files.
This commit is contained in:
@@ -29,8 +29,8 @@ from pgadmin.browser.server_groups.servers.pgagent.utils \
|
||||
|
||||
|
||||
class JobModule(CollectionNodeModule):
|
||||
NODE_TYPE = 'pga_job'
|
||||
COLLECTION_LABEL = _("pgAgent Jobs")
|
||||
_NODE_TYPE = 'pga_job'
|
||||
_COLLECTION_LABEL = _("pgAgent Jobs")
|
||||
|
||||
def get_nodes(self, gid, sid):
|
||||
"""
|
||||
@@ -45,7 +45,7 @@ class JobModule(CollectionNodeModule):
|
||||
Load the module script for server, when any of the server-group node is
|
||||
initialized.
|
||||
"""
|
||||
return servers.ServerModule.NODE_TYPE
|
||||
return servers.ServerModule.node_type
|
||||
|
||||
def backend_supported(self, manager, **kwargs):
|
||||
if hasattr(self, 'show_node') and not self.show_node:
|
||||
@@ -180,7 +180,7 @@ SELECT EXISTS(
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, jid=None):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'nodes.sql']),
|
||||
"/".join([self.template_path, self._NODES_SQL]),
|
||||
jid=jid, conn=self.conn
|
||||
)
|
||||
status, rset = self.conn.execute_dict(SQL)
|
||||
@@ -224,7 +224,7 @@ SELECT EXISTS(
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, jid=None):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
||||
jid=jid, conn=self.conn
|
||||
)
|
||||
status, rset = self.conn.execute_dict(SQL)
|
||||
@@ -294,7 +294,7 @@ SELECT EXISTS(
|
||||
|
||||
status, res = self.conn.execute_scalar(
|
||||
render_template(
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
"/".join([self.template_path, self._CREATE_SQL]),
|
||||
data=data, conn=self.conn, fetch_id=True,
|
||||
has_connstr=self.manager.db_info['pgAgent']['has_connstr']
|
||||
)
|
||||
@@ -307,7 +307,7 @@ SELECT EXISTS(
|
||||
# We need oid of newly created database
|
||||
status, res = self.conn.execute_dict(
|
||||
render_template(
|
||||
"/".join([self.template_path, 'nodes.sql']),
|
||||
"/".join([self.template_path, self._NODES_SQL]),
|
||||
jid=res, conn=self.conn
|
||||
)
|
||||
)
|
||||
@@ -341,7 +341,7 @@ SELECT EXISTS(
|
||||
|
||||
status, res = self.conn.execute_void(
|
||||
render_template(
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
"/".join([self.template_path, self._UPDATE_SQL]),
|
||||
data=data, conn=self.conn, jid=jid,
|
||||
has_connstr=self.manager.db_info['pgAgent']['has_connstr']
|
||||
)
|
||||
@@ -353,7 +353,7 @@ SELECT EXISTS(
|
||||
# We need oid of newly created database
|
||||
status, res = self.conn.execute_dict(
|
||||
render_template(
|
||||
"/".join([self.template_path, 'nodes.sql']),
|
||||
"/".join([self.template_path, self._NODES_SQL]),
|
||||
jid=jid, conn=self.conn
|
||||
)
|
||||
)
|
||||
@@ -387,7 +387,7 @@ SELECT EXISTS(
|
||||
for jid in data['ids']:
|
||||
status, res = self.conn.execute_void(
|
||||
render_template(
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
"/".join([self.template_path, self._DELETE_SQL]),
|
||||
jid=jid, conn=self.conn
|
||||
)
|
||||
)
|
||||
@@ -417,7 +417,7 @@ SELECT EXISTS(
|
||||
data=render_template(
|
||||
"/".join([
|
||||
self.template_path,
|
||||
'create.sql' if jid is None else 'update.sql'
|
||||
self._CREATE_SQL if jid is None else self._UPDATE_SQL
|
||||
]),
|
||||
jid=jid, data=data, conn=self.conn, fetch_id=False,
|
||||
has_connstr=self.manager.db_info['pgAgent']['has_connstr']
|
||||
@@ -460,7 +460,7 @@ SELECT EXISTS(
|
||||
This function will generate sql for sql panel
|
||||
"""
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
||||
jid=jid, conn=self.conn, last_system_oid=0
|
||||
)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
@@ -517,7 +517,7 @@ SELECT EXISTS(
|
||||
|
||||
return ajax_response(
|
||||
response=render_template(
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
"/".join([self.template_path, self._CREATE_SQL]),
|
||||
jid=jid, data=row, conn=self.conn, fetch_id=False,
|
||||
has_connstr=self.manager.db_info['pgAgent']['has_connstr']
|
||||
)
|
||||
|
||||
@@ -40,8 +40,8 @@ class JobScheduleModule(CollectionNodeModule):
|
||||
- Method is overridden from its base class to make the node as leaf node.
|
||||
"""
|
||||
|
||||
NODE_TYPE = 'pga_schedule'
|
||||
COLLECTION_LABEL = gettext("Schedules")
|
||||
_NODE_TYPE = 'pga_schedule'
|
||||
_COLLECTION_LABEL = gettext("Schedules")
|
||||
|
||||
def get_nodes(self, gid, sid, jid):
|
||||
"""
|
||||
@@ -214,7 +214,7 @@ class JobScheduleView(PGChildNodeView):
|
||||
jid: Job ID
|
||||
"""
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
||||
jid=jid
|
||||
)
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
@@ -240,7 +240,7 @@ class JobScheduleView(PGChildNodeView):
|
||||
"""
|
||||
res = []
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'nodes.sql']),
|
||||
"/".join([self.template_path, self._NODES_SQL]),
|
||||
jscid=jscid,
|
||||
jid=jid
|
||||
)
|
||||
@@ -297,7 +297,7 @@ class JobScheduleView(PGChildNodeView):
|
||||
jscid: JobSchedule ID
|
||||
"""
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
||||
jscid=jscid, jid=jid
|
||||
)
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
@@ -340,7 +340,7 @@ class JobScheduleView(PGChildNodeView):
|
||||
format_schedule_data(data)
|
||||
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
"/".join([self.template_path, self._CREATE_SQL]),
|
||||
jid=jid,
|
||||
data=data,
|
||||
fetch_id=True
|
||||
@@ -358,7 +358,7 @@ class JobScheduleView(PGChildNodeView):
|
||||
|
||||
self.conn.execute_void('END')
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
||||
jscid=res,
|
||||
jid=jid
|
||||
)
|
||||
@@ -410,7 +410,7 @@ class JobScheduleView(PGChildNodeView):
|
||||
format_schedule_data(data)
|
||||
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
"/".join([self.template_path, self._UPDATE_SQL]),
|
||||
jid=jid,
|
||||
jscid=jscid,
|
||||
data=data
|
||||
@@ -422,7 +422,7 @@ class JobScheduleView(PGChildNodeView):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
||||
jscid=jscid,
|
||||
jid=jid
|
||||
)
|
||||
@@ -462,7 +462,7 @@ class JobScheduleView(PGChildNodeView):
|
||||
for jscid in data['ids']:
|
||||
status, res = self.conn.execute_void(
|
||||
render_template(
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
"/".join([self.template_path, self._DELETE_SQL]),
|
||||
jid=jid, jscid=jscid, conn=self.conn
|
||||
)
|
||||
)
|
||||
@@ -495,14 +495,14 @@ class JobScheduleView(PGChildNodeView):
|
||||
|
||||
if jscid is None:
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
"/".join([self.template_path, self._CREATE_SQL]),
|
||||
jid=jid,
|
||||
data=data,
|
||||
fetch_id=False
|
||||
)
|
||||
else:
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
"/".join([self.template_path, self._UPDATE_SQL]),
|
||||
jid=jid,
|
||||
jscid=jscid,
|
||||
data=data
|
||||
|
||||
@@ -39,8 +39,8 @@ class JobStepModule(CollectionNodeModule):
|
||||
- Method is overridden from its base class to make the node as leaf node.
|
||||
"""
|
||||
|
||||
NODE_TYPE = 'pga_jobstep'
|
||||
COLLECTION_LABEL = gettext("Steps")
|
||||
_NODE_TYPE = 'pga_jobstep'
|
||||
_COLLECTION_LABEL = gettext("Steps")
|
||||
|
||||
def get_nodes(self, gid, sid, jid):
|
||||
"""
|
||||
@@ -226,7 +226,7 @@ SELECT EXISTS(
|
||||
jid: Job ID
|
||||
"""
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
||||
jid=jid,
|
||||
has_connstr=self.manager.db_info['pgAgent']['has_connstr']
|
||||
)
|
||||
@@ -254,7 +254,7 @@ SELECT EXISTS(
|
||||
"""
|
||||
res = []
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'nodes.sql']),
|
||||
"/".join([self.template_path, self._NODES_SQL]),
|
||||
jstid=jstid,
|
||||
jid=jid
|
||||
)
|
||||
@@ -311,7 +311,7 @@ SELECT EXISTS(
|
||||
jstid: JobStep ID
|
||||
"""
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
||||
jstid=jstid,
|
||||
jid=jid,
|
||||
has_connstr=self.manager.db_info['pgAgent']['has_connstr']
|
||||
@@ -352,7 +352,7 @@ SELECT EXISTS(
|
||||
data = json.loads(request.data.decode())
|
||||
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
"/".join([self.template_path, self._CREATE_SQL]),
|
||||
jid=jid,
|
||||
data=data,
|
||||
has_connstr=self.manager.db_info['pgAgent']['has_connstr']
|
||||
@@ -364,7 +364,7 @@ SELECT EXISTS(
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'nodes.sql']),
|
||||
"/".join([self.template_path, self._NODES_SQL]),
|
||||
jstid=res,
|
||||
jid=jid
|
||||
)
|
||||
@@ -411,7 +411,7 @@ SELECT EXISTS(
|
||||
('jstdbname' in data or 'jstconnstr' in data)
|
||||
):
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
||||
jstid=jstid,
|
||||
jid=jid,
|
||||
has_connstr=self.manager.db_info['pgAgent']['has_connstr']
|
||||
@@ -438,7 +438,7 @@ SELECT EXISTS(
|
||||
data['jstconnstr'] = row['jstconnstr']
|
||||
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
"/".join([self.template_path, self._UPDATE_SQL]),
|
||||
jid=jid,
|
||||
jstid=jstid,
|
||||
data=data,
|
||||
@@ -451,7 +451,7 @@ SELECT EXISTS(
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'nodes.sql']),
|
||||
"/".join([self.template_path, self._NODES_SQL]),
|
||||
jstid=jstid,
|
||||
jid=jid
|
||||
)
|
||||
@@ -491,7 +491,7 @@ SELECT EXISTS(
|
||||
for jstid in data['ids']:
|
||||
status, res = self.conn.execute_void(
|
||||
render_template(
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
"/".join([self.template_path, self._DELETE_SQL]),
|
||||
jid=jid, jstid=jstid, conn=self.conn
|
||||
)
|
||||
)
|
||||
@@ -524,7 +524,7 @@ SELECT EXISTS(
|
||||
|
||||
if jstid is None:
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
"/".join([self.template_path, self._CREATE_SQL]),
|
||||
jid=jid,
|
||||
data=data,
|
||||
has_connstr=self.manager.db_info['pgAgent']['has_connstr']
|
||||
@@ -536,7 +536,7 @@ SELECT EXISTS(
|
||||
('jstdbname' in data or 'jstconnstr' in data)
|
||||
):
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
"/".join([self.template_path, self._PROPERTIES_SQL]),
|
||||
jstid=jstid,
|
||||
jid=jid,
|
||||
has_connstr=self.manager.db_info['pgAgent']['has_connstr']
|
||||
@@ -563,7 +563,7 @@ SELECT EXISTS(
|
||||
data['jstconnstr'] = row['jstconnstr']
|
||||
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
"/".join([self.template_path, self._UPDATE_SQL]),
|
||||
jid=jid,
|
||||
jstid=jstid,
|
||||
data=data,
|
||||
|
||||
Reference in New Issue
Block a user