mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-09 23:15:58 -06:00
Added new custom template hasAny to check if the request has one of the
given key in it or not.
This commit is contained in:
parent
65f70b46ce
commit
97cf27c6b0
@ -26,6 +26,23 @@ from config import PG_DEFAULT_DRIVER
|
||||
import six
|
||||
from pgadmin.browser.server_groups.servers.types import ServerType
|
||||
|
||||
def has_any(data, keys):
|
||||
"""
|
||||
Checks any one of the keys present in the data given
|
||||
"""
|
||||
if data is None and type(data) != dict:
|
||||
return False
|
||||
|
||||
if keys is None and type(keys) != list:
|
||||
return False
|
||||
|
||||
for key in keys:
|
||||
if key in data:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
class ServerModule(sg.ServerGroupPluginModule):
|
||||
NODE_TYPE = "server"
|
||||
|
||||
@ -120,6 +137,7 @@ class ServerModule(sg.ServerGroupPluginModule):
|
||||
app.jinja_env.filters['qtLiteral'] = driver.qtLiteral
|
||||
app.jinja_env.filters['qtIdent'] = driver.qtIdent
|
||||
app.jinja_env.filters['qtTypeIdent'] = driver.qtTypeIdent
|
||||
app.jinja_env.filters['hasAny'] = has_any
|
||||
|
||||
super(ServerModule, self).register(app, options, first_registration)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user