Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
arthur-zzz
noc
Commits
a0b89d69
Verified
Commit
a0b89d69
authored
Nov 22, 2017
by
Dmitry Volodin
Browse files
Fix circular references
parent
f27a5435
Changes
1
Hide whitespace changes
Inline
Side-by-side
vc/models/vcdomain.py
View file @
a0b89d69
...
...
@@ -2,15 +2,17 @@
# ---------------------------------------------------------------------
# VCDomain model
# ---------------------------------------------------------------------
# Copyright (C) 2007-201
2
The NOC Project
# Copyright (C) 2007-201
7
The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Django modules
# Python modules
from
__future__
import
absolute_import
# Third-party modules
from
django.db
import
models
# NOC modules
from
vctype
import
VCType
from
vcfilter
import
VCFilter
from
.
vctype
import
VCType
from
.
vcfilter
import
VCFilter
from
noc.main.models.style
import
Style
from
noc.core.model.decorator
import
on_save
,
on_delete
from
noc.core.model.decorator
import
on_delete_check
...
...
@@ -52,10 +54,12 @@ class VCDomain(models.Model):
return
self
.
name
def
on_save
(
self
):
from
noc.sa.models.selectorcache
import
SelectorCache
# Rebuild selector cache
SelectorCache
.
refresh
()
def
on_delete
(
self
):
from
noc.sa.models.selectorcache
import
SelectorCache
# Rebuild selector cache
SelectorCache
.
refresh
()
...
...
@@ -88,15 +92,10 @@ class VCDomain(models.Model):
if
x
>
y
or
y
<
l_min
or
x
>
l_max
:
continue
# Skip chunk outside of type's range
for
l
in
range
(
max
(
l_min
,
x
),
min
(
l_max
,
y
)
+
1
):
if
not
VC
.
objects
.
filter
(
vc_domain
=
self
,
l1
=
l
).
exists
():
if
not
self
.
vc_set
.
filter
(
l1
=
l
).
exists
():
return
l
# Return first free found
return
None
# Nothing found
@
classmethod
def
get_default
(
cls
):
return
VCDomain
.
objects
.
get
(
name
=
"default"
)
# Avoid circular references
from
vc
import
VC
from
noc.sa.models.selectorcache
import
SelectorCache
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment