mirror of
https://github.com/veops/cmdb.git
synced 2025-08-09 12:53:11 +08:00
upgrade flask to 2.3.2 and replace g.user with current_user
This commit is contained in:
@@ -3,13 +3,13 @@
|
||||
import requests
|
||||
from flask import abort
|
||||
from flask import current_app
|
||||
from flask import g
|
||||
from flask import session
|
||||
from flask_login import current_user
|
||||
|
||||
from api.extensions import db
|
||||
from api.lib.cmdb.cache import AttributeCache
|
||||
from api.lib.cmdb.const import CITypeOperateType
|
||||
from api.lib.cmdb.const import ResourceTypeEnum, RoleEnum, PermEnum
|
||||
from api.lib.cmdb.const import PermEnum, ResourceTypeEnum, RoleEnum
|
||||
from api.lib.cmdb.const import ValueTypeEnum
|
||||
from api.lib.cmdb.history import CITypeHistoryManager
|
||||
from api.lib.cmdb.resp_format import ErrFormat
|
||||
@@ -177,7 +177,7 @@ class AttributeManager(object):
|
||||
name=name,
|
||||
alias=alias,
|
||||
is_choice=is_choice,
|
||||
uid=g.user.uid,
|
||||
uid=current_user.uid,
|
||||
**kwargs)
|
||||
|
||||
if choice_value:
|
||||
@@ -240,7 +240,7 @@ class AttributeManager(object):
|
||||
def _can_edit_attribute(attr):
|
||||
from api.lib.cmdb.ci_type import CITypeManager
|
||||
|
||||
if attr.uid == g.user.uid:
|
||||
if attr.uid == current_user.uid:
|
||||
return True
|
||||
|
||||
for i in CITypeAttribute.get_by(attr_id=attr.id, to_dict=False):
|
||||
@@ -319,7 +319,7 @@ class AttributeManager(object):
|
||||
if CIType.get_by(unique_id=attr.id, first=True, to_dict=False) is not None:
|
||||
return abort(400, ErrFormat.attribute_is_unique_id)
|
||||
|
||||
if attr.uid and attr.uid != g.user.uid:
|
||||
if attr.uid and attr.uid != current_user.uid:
|
||||
return abort(403, ErrFormat.cannot_delete_attribute)
|
||||
|
||||
if attr.is_choice:
|
||||
|
@@ -5,7 +5,7 @@ import os
|
||||
|
||||
from flask import abort
|
||||
from flask import current_app
|
||||
from flask import g
|
||||
from flask_login import current_user
|
||||
from sqlalchemy import func
|
||||
|
||||
from api.extensions import db
|
||||
@@ -156,7 +156,7 @@ class AutoDiscoveryCITypeCRUD(DBMixin):
|
||||
continue
|
||||
|
||||
if isinstance(rule.get("extra_option"), dict) and rule['extra_option'].get('secret'):
|
||||
if not (g.user.username == "cmdb_agent" or g.user.uid == rule['uid']):
|
||||
if not (current_user.username == "cmdb_agent" or current_user.uid == rule['uid']):
|
||||
rule['extra_option'].pop('secret', None)
|
||||
else:
|
||||
rule['extra_option']['secret'] = AESCrypto.decrypt(rule['extra_option']['secret'])
|
||||
@@ -213,7 +213,7 @@ class AutoDiscoveryCITypeCRUD(DBMixin):
|
||||
agent_id = agent_id.strip()
|
||||
q = "op_duty:{0},-rd_duty:{0},oneagent_id:{1}"
|
||||
|
||||
s = search(q.format(g.user.username, agent_id.strip()))
|
||||
s = search(q.format(current_user.username, agent_id.strip()))
|
||||
try:
|
||||
response, _, _, _, _, _ = s.search()
|
||||
if response:
|
||||
@@ -222,7 +222,7 @@ class AutoDiscoveryCITypeCRUD(DBMixin):
|
||||
current_app.logger.warning(e)
|
||||
return abort(400, str(e))
|
||||
|
||||
s = search(q.format(g.user.nickname, agent_id.strip()))
|
||||
s = search(q.format(current_user.nickname, agent_id.strip()))
|
||||
try:
|
||||
response, _, _, _, _, _ = s.search()
|
||||
if response:
|
||||
@@ -240,9 +240,9 @@ class AutoDiscoveryCITypeCRUD(DBMixin):
|
||||
try:
|
||||
response, _, _, _, _, _ = s.search()
|
||||
for i in response:
|
||||
if g.user.username not in (i.get('rd_duty') or []) and g.user.username not in \
|
||||
(i.get('op_duty') or []) and g.user.nickname not in (i.get('rd_duty') or []) and \
|
||||
g.user.nickname not in (i.get('op_duty') or []):
|
||||
if current_user.username not in (i.get('rd_duty') or []) and current_user.username not in \
|
||||
(i.get('op_duty') or []) and current_user.nickname not in (i.get('rd_duty') or []) and \
|
||||
current_user.nickname not in (i.get('op_duty') or []):
|
||||
return abort(403, ErrFormat.adt_target_expr_no_permission.format(
|
||||
i.get("{}_name".format(i.get('ci_type')))))
|
||||
except SearchError as e:
|
||||
@@ -270,7 +270,7 @@ class AutoDiscoveryCITypeCRUD(DBMixin):
|
||||
if isinstance(kwargs.get('extra_option'), dict) and kwargs['extra_option'].get('secret'):
|
||||
kwargs['extra_option']['secret'] = AESCrypto.encrypt(kwargs['extra_option']['secret'])
|
||||
|
||||
kwargs['uid'] = g.user.uid
|
||||
kwargs['uid'] = current_user.uid
|
||||
|
||||
return kwargs
|
||||
|
||||
@@ -281,7 +281,7 @@ class AutoDiscoveryCITypeCRUD(DBMixin):
|
||||
self.__valid_exec_target(kwargs.get('agent_id'), kwargs.get('query_expr'))
|
||||
|
||||
if isinstance(kwargs.get('extra_option'), dict) and kwargs['extra_option'].get('secret'):
|
||||
if g.user.uid != existed.uid:
|
||||
if current_user.uid != existed.uid:
|
||||
return abort(403, ErrFormat.adt_secret_no_permission)
|
||||
|
||||
return existed
|
||||
@@ -477,7 +477,7 @@ class AutoDiscoveryCICRUD(DBMixin):
|
||||
pass
|
||||
|
||||
adc.update(is_accept=True,
|
||||
accept_by=nickname or g.user.nickname,
|
||||
accept_by=nickname or current_user.nickname,
|
||||
accept_time=datetime.datetime.now(),
|
||||
ci_id=ci_id)
|
||||
|
||||
|
@@ -7,7 +7,7 @@ import json
|
||||
|
||||
from flask import abort
|
||||
from flask import current_app
|
||||
from flask import g
|
||||
from flask_login import current_user
|
||||
from werkzeug.exceptions import BadRequest
|
||||
|
||||
from api.extensions import db
|
||||
@@ -24,8 +24,8 @@ from api.lib.cmdb.const import CMDB_QUEUE
|
||||
from api.lib.cmdb.const import ConstraintEnum
|
||||
from api.lib.cmdb.const import ExistPolicy
|
||||
from api.lib.cmdb.const import OperateType
|
||||
from api.lib.cmdb.const import PermEnum, ResourceTypeEnum
|
||||
from api.lib.cmdb.const import REDIS_PREFIX_CI
|
||||
from api.lib.cmdb.const import ResourceTypeEnum, PermEnum
|
||||
from api.lib.cmdb.const import RetKey
|
||||
from api.lib.cmdb.history import AttributeHistoryManger
|
||||
from api.lib.cmdb.history import CIRelationHistoryManager
|
||||
@@ -38,8 +38,8 @@ from api.lib.decorator import kwargs_required
|
||||
from api.lib.perm.acl.acl import ACLManager
|
||||
from api.lib.perm.acl.acl import is_app_admin
|
||||
from api.lib.perm.acl.acl import validate_permission
|
||||
from api.lib.utils import Lock
|
||||
from api.lib.utils import handle_arg_list
|
||||
from api.lib.utils import Lock
|
||||
from api.models.cmdb import CI
|
||||
from api.models.cmdb import CIRelation
|
||||
from api.models.cmdb import CITypeAttribute
|
||||
@@ -316,7 +316,7 @@ class CIManager(object):
|
||||
ci_attr2type_attr = {type_attr.attr_id: type_attr for type_attr, _ in attrs}
|
||||
|
||||
ci = None
|
||||
need_lock = g.user.username not in ("worker", "cmdb_agent", "agent")
|
||||
need_lock = current_user.username not in ("worker", "cmdb_agent", "agent")
|
||||
with Lock(ci_type_name, need_lock=need_lock):
|
||||
existed = cls.ci_is_exist(unique_key, unique_value, ci_type.id)
|
||||
if existed is not None:
|
||||
@@ -411,7 +411,7 @@ class CIManager(object):
|
||||
|
||||
limit_attrs = self._valid_ci_for_no_read(ci) if not _is_admin else {}
|
||||
|
||||
need_lock = g.user.username not in ("worker", "cmdb_agent", "agent")
|
||||
need_lock = current_user.username not in ("worker", "cmdb_agent", "agent")
|
||||
with Lock(ci.ci_type.name, need_lock=need_lock):
|
||||
self._valid_unique_constraint(ci.type_id, ci_dict, ci_id)
|
||||
|
||||
|
@@ -5,7 +5,7 @@ import datetime
|
||||
|
||||
from flask import abort
|
||||
from flask import current_app
|
||||
from flask import g
|
||||
from flask_login import current_user
|
||||
|
||||
from api.extensions import db
|
||||
from api.lib.cmdb.attribute import AttributeManager
|
||||
@@ -118,7 +118,7 @@ class CITypeManager(object):
|
||||
cls._validate_unique(alias=kwargs['alias'])
|
||||
|
||||
kwargs["unique_id"] = unique_key.id
|
||||
kwargs['uid'] = g.user.uid
|
||||
kwargs['uid'] = current_user.uid
|
||||
ci_type = CIType.create(**kwargs)
|
||||
|
||||
CITypeAttributeManager.add(ci_type.id, [unique_key.id], is_required=True)
|
||||
@@ -132,7 +132,7 @@ class CITypeManager(object):
|
||||
ResourceTypeEnum.CI,
|
||||
permissions=[PermEnum.READ])
|
||||
ACLManager().grant_resource_to_role(ci_type.name,
|
||||
g.user.username,
|
||||
current_user.username,
|
||||
ResourceTypeEnum.CI)
|
||||
|
||||
CITypeHistoryManager.add(CITypeOperateType.ADD, ci_type.id, change=ci_type.to_dict())
|
||||
@@ -185,7 +185,7 @@ class CITypeManager(object):
|
||||
def delete(cls, type_id):
|
||||
ci_type = cls.check_is_existed(type_id)
|
||||
|
||||
if ci_type.uid and ci_type.uid != g.user.uid:
|
||||
if ci_type.uid and ci_type.uid != current_user.uid:
|
||||
return abort(403, ErrFormat.only_owner_can_delete)
|
||||
|
||||
if CI.get_by(type_id=type_id, first=True, to_dict=False) is not None:
|
||||
@@ -582,7 +582,7 @@ class CITypeRelationManager(object):
|
||||
ResourceTypeEnum.CI_TYPE_RELATION,
|
||||
permissions=[PermEnum.READ])
|
||||
ACLManager().grant_resource_to_role(resource_name,
|
||||
g.user.username,
|
||||
current_user.username,
|
||||
ResourceTypeEnum.CI_TYPE_RELATION)
|
||||
|
||||
CITypeHistoryManager.add(CITypeOperateType.ADD_RELATION, p.id,
|
||||
@@ -816,7 +816,7 @@ class CITypeTemplateManager(object):
|
||||
ResourceTypeEnum.CI,
|
||||
permissions=[PermEnum.READ])
|
||||
ACLManager().grant_resource_to_role(type_name,
|
||||
g.user.username,
|
||||
current_user.username,
|
||||
ResourceTypeEnum.CI)
|
||||
|
||||
else:
|
||||
@@ -954,7 +954,7 @@ class CITypeTemplateManager(object):
|
||||
rule.pop("created_at", None)
|
||||
rule.pop("updated_at", None)
|
||||
|
||||
rule['uid'] = g.user.uid
|
||||
rule['uid'] = current_user.uid
|
||||
try:
|
||||
AutoDiscoveryCITypeCRUD.add(**rule)
|
||||
except:
|
||||
|
@@ -4,7 +4,7 @@
|
||||
import json
|
||||
|
||||
from flask import abort
|
||||
from flask import g
|
||||
from flask_login import current_user
|
||||
|
||||
from api.extensions import db
|
||||
from api.lib.cmdb.cache import AttributeCache
|
||||
@@ -201,7 +201,7 @@ class AttributeHistoryManger(object):
|
||||
@staticmethod
|
||||
def add(record_id, ci_id, history_list, type_id=None, flush=False, commit=True):
|
||||
if record_id is None:
|
||||
record = OperationRecord.create(uid=g.user.uid, type_id=type_id)
|
||||
record = OperationRecord.create(uid=current_user.uid, type_id=type_id)
|
||||
record_id = record.id
|
||||
|
||||
for attr_id, operate_type, old, new in history_list or []:
|
||||
@@ -220,7 +220,7 @@ class AttributeHistoryManger(object):
|
||||
class CIRelationHistoryManager(object):
|
||||
@staticmethod
|
||||
def add(rel_obj, operate_type=OperateType.ADD):
|
||||
record = OperationRecord.create(uid=g.user.uid)
|
||||
record = OperationRecord.create(uid=current_user.uid)
|
||||
|
||||
CIRelationHistory.create(relation_id=rel_obj.id,
|
||||
record_id=record.id,
|
||||
@@ -279,7 +279,7 @@ class CITypeHistoryManager(object):
|
||||
for _type_id in type_ids:
|
||||
payload = dict(operate_type=operate_type,
|
||||
type_id=_type_id,
|
||||
uid=g.user.uid,
|
||||
uid=current_user.uid,
|
||||
attr_id=attr_id,
|
||||
trigger_id=trigger_id,
|
||||
unique_constraint_id=unique_constraint_id,
|
||||
|
@@ -4,8 +4,8 @@ import functools
|
||||
|
||||
from flask import abort
|
||||
from flask import current_app
|
||||
from flask import g
|
||||
from flask import request
|
||||
from flask_login import current_user
|
||||
|
||||
from api.lib.cmdb.const import ResourceTypeEnum
|
||||
from api.lib.cmdb.resp_format import ErrFormat
|
||||
@@ -74,7 +74,7 @@ class CIFilterPermsCRUD(DBMixin):
|
||||
|
||||
@classmethod
|
||||
def get_attr_filter(cls, type_id):
|
||||
if is_app_admin('cmdb') or g.user.username in ('worker', 'cmdb_agent'):
|
||||
if is_app_admin('cmdb') or current_user.username in ('worker', 'cmdb_agent'):
|
||||
return []
|
||||
|
||||
res2 = ACLManager('cmdb').get_resources(ResourceTypeEnum.CI_FILTER)
|
||||
@@ -160,7 +160,7 @@ def has_perm_for_ci(arg_name, resource_type, perm, callback=None, app=None):
|
||||
resource = callback(resource)
|
||||
|
||||
if current_app.config.get("USE_ACL") and resource:
|
||||
if g.user.username == "worker" or g.user.username == "cmdb_agent":
|
||||
if current_user.username == "worker" or current_user.username == "cmdb_agent":
|
||||
request.values['__is_admin'] = True
|
||||
return func(*args, **kwargs)
|
||||
|
||||
|
@@ -7,7 +7,7 @@ import six
|
||||
import toposort
|
||||
from flask import abort
|
||||
from flask import current_app
|
||||
from flask import g
|
||||
from flask_login import current_user
|
||||
|
||||
from api.extensions import db
|
||||
from api.lib.cmdb.attribute import AttributeManager
|
||||
@@ -36,10 +36,10 @@ class PreferenceManager(object):
|
||||
@staticmethod
|
||||
def get_types(instance=False, tree=False):
|
||||
types = db.session.query(PreferenceShowAttributes.type_id).filter(
|
||||
PreferenceShowAttributes.uid == g.user.uid).filter(
|
||||
PreferenceShowAttributes.uid == current_user.uid).filter(
|
||||
PreferenceShowAttributes.deleted.is_(False)).group_by(PreferenceShowAttributes.type_id).all() \
|
||||
if instance else []
|
||||
tree_types = PreferenceTreeView.get_by(uid=g.user.uid, to_dict=False) if tree else []
|
||||
tree_types = PreferenceTreeView.get_by(uid=current_user.uid, to_dict=False) if tree else []
|
||||
type_ids = list(set([i.type_id for i in types + tree_types]))
|
||||
return [CITypeCache.get(type_id).to_dict() for type_id in type_ids]
|
||||
|
||||
@@ -62,7 +62,7 @@ class PreferenceManager(object):
|
||||
PreferenceShowAttributes.deleted.is_(False)).group_by(
|
||||
PreferenceShowAttributes.uid, PreferenceShowAttributes.type_id)
|
||||
for i in types:
|
||||
if i.uid == g.user.uid:
|
||||
if i.uid == current_user.uid:
|
||||
result['self']['instance'].append(i.type_id)
|
||||
if str(i.created_at) > str(result['self']['type_id2subs_time'].get(i.type_id, "")):
|
||||
result['self']['type_id2subs_time'][i.type_id] = i.created_at
|
||||
@@ -72,7 +72,7 @@ class PreferenceManager(object):
|
||||
if tree:
|
||||
types = PreferenceTreeView.get_by(to_dict=False)
|
||||
for i in types:
|
||||
if i.uid == g.user.uid:
|
||||
if i.uid == current_user.uid:
|
||||
result['self']['tree'].append(i.type_id)
|
||||
if str(i.created_at) > str(result['self']['type_id2subs_time'].get(i.type_id, "")):
|
||||
result['self']['type_id2subs_time'][i.type_id] = i.created_at
|
||||
@@ -91,7 +91,7 @@ class PreferenceManager(object):
|
||||
|
||||
attrs = db.session.query(PreferenceShowAttributes, CITypeAttribute.order).join(
|
||||
CITypeAttribute, CITypeAttribute.attr_id == PreferenceShowAttributes.attr_id).filter(
|
||||
PreferenceShowAttributes.uid == g.user.uid).filter(
|
||||
PreferenceShowAttributes.uid == current_user.uid).filter(
|
||||
PreferenceShowAttributes.type_id == type_id).filter(
|
||||
PreferenceShowAttributes.deleted.is_(False)).filter(CITypeAttribute.deleted.is_(False)).filter(
|
||||
CITypeAttribute.type_id == type_id).all()
|
||||
@@ -120,7 +120,7 @@ class PreferenceManager(object):
|
||||
|
||||
@classmethod
|
||||
def create_or_update_show_attributes(cls, type_id, attr_order):
|
||||
existed_all = PreferenceShowAttributes.get_by(type_id=type_id, uid=g.user.uid, to_dict=False)
|
||||
existed_all = PreferenceShowAttributes.get_by(type_id=type_id, uid=current_user.uid, to_dict=False)
|
||||
for x, order in attr_order:
|
||||
if isinstance(x, list):
|
||||
_attr, is_fixed = x
|
||||
@@ -128,13 +128,13 @@ class PreferenceManager(object):
|
||||
_attr, is_fixed = x, False
|
||||
attr = AttributeCache.get(_attr) or abort(404, ErrFormat.attribute_not_found.format("id={}".format(_attr)))
|
||||
existed = PreferenceShowAttributes.get_by(type_id=type_id,
|
||||
uid=g.user.uid,
|
||||
uid=current_user.uid,
|
||||
attr_id=attr.id,
|
||||
first=True,
|
||||
to_dict=False)
|
||||
if existed is None:
|
||||
PreferenceShowAttributes.create(type_id=type_id,
|
||||
uid=g.user.uid,
|
||||
uid=current_user.uid,
|
||||
attr_id=attr.id,
|
||||
order=order,
|
||||
is_fixed=is_fixed)
|
||||
@@ -148,7 +148,7 @@ class PreferenceManager(object):
|
||||
|
||||
@staticmethod
|
||||
def get_tree_view():
|
||||
res = PreferenceTreeView.get_by(uid=g.user.uid, to_dict=True)
|
||||
res = PreferenceTreeView.get_by(uid=current_user.uid, to_dict=True)
|
||||
for item in res:
|
||||
if item["levels"]:
|
||||
ci_type = CITypeCache.get(item['type_id']).to_dict()
|
||||
@@ -176,14 +176,14 @@ class PreferenceManager(object):
|
||||
if i == attr.id or i == attr.name or i == attr.alias:
|
||||
levels[idx] = attr.id
|
||||
|
||||
existed = PreferenceTreeView.get_by(uid=g.user.uid, type_id=type_id, to_dict=False, first=True)
|
||||
existed = PreferenceTreeView.get_by(uid=current_user.uid, type_id=type_id, to_dict=False, first=True)
|
||||
if existed is not None:
|
||||
if not levels:
|
||||
existed.soft_delete()
|
||||
return existed
|
||||
return existed.update(levels=levels)
|
||||
elif levels:
|
||||
return PreferenceTreeView.create(levels=levels, type_id=type_id, uid=g.user.uid)
|
||||
return PreferenceTreeView.create(levels=levels, type_id=type_id, uid=current_user.uid)
|
||||
|
||||
@staticmethod
|
||||
def get_relation_view():
|
||||
@@ -254,7 +254,7 @@ class PreferenceManager(object):
|
||||
existed = PreferenceRelationView.get_by(name=name, to_dict=False, first=True)
|
||||
current_app.logger.debug(existed)
|
||||
if existed is None:
|
||||
PreferenceRelationView.create(name=name, cr_ids=cr_ids, uid=g.user.uid, is_public=is_public)
|
||||
PreferenceRelationView.create(name=name, cr_ids=cr_ids, uid=current_user.uid, is_public=is_public)
|
||||
|
||||
if current_app.config.get("USE_ACL"):
|
||||
ACLManager().add_resource(name, ResourceTypeEnum.RELATION_VIEW)
|
||||
@@ -278,7 +278,7 @@ class PreferenceManager(object):
|
||||
@staticmethod
|
||||
def get_search_option(**kwargs):
|
||||
query = PreferenceSearchOption.get_by(only_query=True)
|
||||
query = query.filter(PreferenceSearchOption.uid == g.user.uid)
|
||||
query = query.filter(PreferenceSearchOption.uid == current_user.uid)
|
||||
|
||||
for k in kwargs:
|
||||
if hasattr(PreferenceSearchOption, k) and kwargs[k]:
|
||||
@@ -288,9 +288,9 @@ class PreferenceManager(object):
|
||||
|
||||
@staticmethod
|
||||
def add_search_option(**kwargs):
|
||||
kwargs['uid'] = g.user.uid
|
||||
kwargs['uid'] = current_user.uid
|
||||
|
||||
existed = PreferenceSearchOption.get_by(uid=g.user.uid,
|
||||
existed = PreferenceSearchOption.get_by(uid=current_user.uid,
|
||||
name=kwargs.get('name'),
|
||||
prv_id=kwargs.get('prv_id'),
|
||||
ptv_id=kwargs.get('ptv_id'),
|
||||
@@ -306,10 +306,10 @@ class PreferenceManager(object):
|
||||
|
||||
existed = PreferenceSearchOption.get_by_id(_id) or abort(404, ErrFormat.preference_search_option_not_found)
|
||||
|
||||
if g.user.uid != existed.uid:
|
||||
if current_user.uid != existed.uid:
|
||||
return abort(400, ErrFormat.no_permission2)
|
||||
|
||||
other = PreferenceSearchOption.get_by(uid=g.user.uid,
|
||||
other = PreferenceSearchOption.get_by(uid=current_user.uid,
|
||||
name=kwargs.get('name'),
|
||||
prv_id=kwargs.get('prv_id'),
|
||||
ptv_id=kwargs.get('ptv_id'),
|
||||
@@ -324,7 +324,7 @@ class PreferenceManager(object):
|
||||
def delete_search_option(_id):
|
||||
existed = PreferenceSearchOption.get_by_id(_id) or abort(404, ErrFormat.preference_search_option_not_found)
|
||||
|
||||
if g.user.uid != existed.uid:
|
||||
if current_user.uid != existed.uid:
|
||||
return abort(400, ErrFormat.no_permission2)
|
||||
|
||||
existed.soft_delete()
|
||||
|
@@ -7,8 +7,9 @@ import copy
|
||||
import time
|
||||
|
||||
from flask import current_app
|
||||
from flask import g
|
||||
from flask_login import current_user
|
||||
from jinja2 import Template
|
||||
|
||||
from api.extensions import db
|
||||
from api.lib.cmdb.cache import AttributeCache
|
||||
from api.lib.cmdb.cache import CITypeCache
|
||||
@@ -105,7 +106,7 @@ class Search(object):
|
||||
ci_filter = self.type2filter_perms[ci_type.id].get('ci_filter')
|
||||
if ci_filter:
|
||||
sub = []
|
||||
ci_filter = Template(ci_filter).render(user=g.user)
|
||||
ci_filter = Template(ci_filter).render(user=current_user)
|
||||
for i in ci_filter.split(','):
|
||||
if i.startswith("~") and not sub:
|
||||
queries.append(i)
|
||||
@@ -355,7 +356,7 @@ class Search(object):
|
||||
else:
|
||||
result.append(q)
|
||||
|
||||
_is_app_admin = is_app_admin('cmdb') or g.user.username == "worker"
|
||||
_is_app_admin = is_app_admin('cmdb') or current_user.username == "worker"
|
||||
if result and not has_type and not _is_app_admin:
|
||||
type_q = self.__get_types_has_read()
|
||||
if id_query:
|
||||
|
Reference in New Issue
Block a user