mirror of https://github.com/veops/cmdb.git
feat(api): Remove many-to-many restrictions (#401)
This commit is contained in:
parent
26c3404f28
commit
7474a92377
|
@ -1,6 +1,7 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
import toposort
|
import toposort
|
||||||
from flask import abort
|
from flask import abort
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
@ -656,15 +657,15 @@ class CITypeRelationManager(object):
|
||||||
current_app.logger.warning(str(e))
|
current_app.logger.warning(str(e))
|
||||||
return abort(400, ErrFormat.circular_dependency_error)
|
return abort(400, ErrFormat.circular_dependency_error)
|
||||||
|
|
||||||
if constraint == ConstraintEnum.Many2Many:
|
# if constraint == ConstraintEnum.Many2Many:
|
||||||
other_c = CITypeRelation.get_by(parent_id=p.id, constraint=ConstraintEnum.Many2Many,
|
# other_c = CITypeRelation.get_by(parent_id=p.id, constraint=ConstraintEnum.Many2Many,
|
||||||
to_dict=False, first=True)
|
# to_dict=False, first=True)
|
||||||
other_p = CITypeRelation.get_by(child_id=c.id, constraint=ConstraintEnum.Many2Many,
|
# other_p = CITypeRelation.get_by(child_id=c.id, constraint=ConstraintEnum.Many2Many,
|
||||||
to_dict=False, first=True)
|
# to_dict=False, first=True)
|
||||||
if other_c and other_c.child_id != c.id:
|
# if other_c and other_c.child_id != c.id:
|
||||||
return abort(400, ErrFormat.m2m_relation_constraint.format(p.name, other_c.child.name))
|
# return abort(400, ErrFormat.m2m_relation_constraint.format(p.name, other_c.child.name))
|
||||||
if other_p and other_p.parent_id != p.id:
|
# if other_p and other_p.parent_id != p.id:
|
||||||
return abort(400, ErrFormat.m2m_relation_constraint.format(other_p.parent.name, c.name))
|
# return abort(400, ErrFormat.m2m_relation_constraint.format(other_p.parent.name, c.name))
|
||||||
|
|
||||||
existed = cls._get(p.id, c.id)
|
existed = cls._get(p.id, c.id)
|
||||||
if existed is not None:
|
if existed is not None:
|
||||||
|
|
Loading…
Reference in New Issue