mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 12:12:53 -06:00
19680 add object_change migrator
This commit is contained in:
parent
24b1cb9297
commit
2a4ba5bd36
@ -38,3 +38,20 @@ class Migration(migrations.Migration):
|
|||||||
operations = [
|
operations = [
|
||||||
migrations.RunPython(code=fix_script_paths, reverse_code=migrations.RunPython.noop),
|
migrations.RunPython(code=fix_script_paths, reverse_code=migrations.RunPython.noop),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def oc_fix_script_paths(objectchange, reverting):
|
||||||
|
script_root_path = normalize(settings.SCRIPTS_ROOT)
|
||||||
|
|
||||||
|
for data in (objectchange.prechange_data, objectchange.postchange_data):
|
||||||
|
if data is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if file_path := data.get('file_path'):
|
||||||
|
if file_path.startswith(script_root_path):
|
||||||
|
data['file_path'] = file_path[len(script_root_path):]
|
||||||
|
|
||||||
|
|
||||||
|
objectchange_migrators = {
|
||||||
|
'extras.scriptmodule': oc_fix_script_paths,
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user