mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-13 08:44:51 -06:00
Fixes #19529: Properly find scripts managed by ScriptFileSystemStorage
ScriptFileSystemStorage was introduced in #18896 and stores a full path in Script.file_path. This fix handles looking for scripts by relative path as well as full path.
This commit is contained in:
parent
b3d318cbe1
commit
bb73faba62
@ -9,6 +9,7 @@ from django import forms
|
||||
from django.conf import settings
|
||||
from django.core.files.storage import storages
|
||||
from django.core.validators import RegexValidator
|
||||
from django.db.models import Q
|
||||
from django.utils import timezone
|
||||
from django.utils.functional import classproperty
|
||||
from django.utils.translation import gettext as _
|
||||
@ -646,6 +647,10 @@ def is_variable(obj):
|
||||
|
||||
|
||||
def get_module_and_script(module_name, script_name):
|
||||
module = ScriptModule.objects.get(file_path=f'{module_name}.py')
|
||||
path = f'{module_name}.py'
|
||||
module = ScriptModule.objects.get(
|
||||
Q(file_path=path) |
|
||||
Q(file_path=os.path.join(settings.SCRIPTS_ROOT, path))
|
||||
)
|
||||
script = module.scripts.get(name=script_name)
|
||||
return module, script
|
||||
|
Loading…
Reference in New Issue
Block a user