mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-13 12:39:52 +02:00
Compare commits
1 Commits
post-raw-s
...
21896-upda
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
592e27e780 |
@@ -20,7 +20,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Create app token
|
||||
uses: actions/create-github-app-token@v1
|
||||
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
|
||||
id: app-token
|
||||
with:
|
||||
app-id: 1076524
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
run: python netbox/manage.py makemessages -l ${{ env.LOCALE }}
|
||||
|
||||
- name: Commit changes
|
||||
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4
|
||||
uses: EndBug/add-and-commit@290ea2c423ad77ca9c62ae0f5b224379612c0321 # v10.0.0
|
||||
with:
|
||||
add: 'netbox/translations/'
|
||||
default_author: github_actions
|
||||
|
||||
@@ -6,7 +6,6 @@ from django.dispatch import receiver
|
||||
|
||||
from dcim.choices import CableEndChoices, LinkStatusChoices
|
||||
from ipam.models import Prefix
|
||||
from netbox.signals import post_raw_create
|
||||
from virtualization.models import Cluster, VMInterface
|
||||
from wireless.models import WirelessLAN
|
||||
|
||||
@@ -167,27 +166,6 @@ def retrace_cable_paths(instance, **kwargs):
|
||||
cablepath.retrace()
|
||||
|
||||
|
||||
@receiver(post_raw_create, sender=Cable)
|
||||
def retrace_cable_paths_after_raw_create(sender, pks, **kwargs):
|
||||
"""
|
||||
When Cables are created via a raw save, the normal Cable.save() path is bypassed,
|
||||
so trace_paths is never sent. Retrace paths for all newly created cables.
|
||||
|
||||
Callers must only send this signal after all CableTerminations for the given cables
|
||||
have been applied. If a cable has no terminations, update_connected_endpoints will
|
||||
find empty termination lists and skip path creation — so this is safe to call even
|
||||
if terminations are absent, but path tracing will have no effect.
|
||||
|
||||
Note: raw=False (the default) is intentional here — we explicitly want
|
||||
update_connected_endpoints to run, unlike during fixture loading (raw=True).
|
||||
"""
|
||||
logger = logging.getLogger('netbox.dcim.cable')
|
||||
for cable in Cable.objects.filter(pk__in=pks):
|
||||
cable._terminations_modified = True
|
||||
trace_paths.send(Cable, instance=cable, created=True)
|
||||
logger.debug(f"Retraced cable paths for Cable {cable.pk}")
|
||||
|
||||
|
||||
@receiver((post_delete, post_save), sender=PortMapping)
|
||||
def update_passthrough_port_paths(instance, **kwargs):
|
||||
"""
|
||||
|
||||
@@ -2,10 +2,3 @@ from django.dispatch import Signal
|
||||
|
||||
# Signals that a model has completed its clean() method
|
||||
post_clean = Signal()
|
||||
|
||||
# Sent after objects of a given model are created via raw save.
|
||||
# Expected call signature: post_raw_create.send(sender=MyModel, pks=[...])
|
||||
# Provides: pks (list) - PKs of the newly created objects.
|
||||
# Callers must ensure all related objects (e.g. M2M, dependent rows) are in place
|
||||
# before sending, as receivers may query related data to perform post-create work.
|
||||
post_raw_create = Signal()
|
||||
|
||||
Reference in New Issue
Block a user