From 09a0e579faa6d549dcf1f82ebbc9454ddc8e1c61 Mon Sep 17 00:00:00 2001 From: Alexander Haase Date: Thu, 21 Nov 2024 14:43:59 +0100 Subject: [PATCH] Fixes: #17923, #17921 - Fix non-null constraint for script execution (#17932) * Fix non-null constraint for script execution With c34a0e2, validation of job object fields is enabled, so ScriptJob must not set required fields to empty strings. This commit reverts b18f193 and (hopefully) fixes this issue not only for UI views, but for all interactions with scripts. Fixes: #17923 * Fix name of recurring jobs For recurring jobs, the name must be passed to the next job object when the job is rescheduled. --- netbox/extras/jobs.py | 4 +--- netbox/extras/views.py | 1 - netbox/netbox/jobs.py | 1 + 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/netbox/extras/jobs.py b/netbox/extras/jobs.py index a913fe456..190166b5b 100644 --- a/netbox/extras/jobs.py +++ b/netbox/extras/jobs.py @@ -22,9 +22,7 @@ class ScriptJob(JobRunner): """ class Meta: - # An explicit job name is not set because it doesn't make sense in this context. Currently, there's no scenario - # where jobs other than this one are used. Therefore, it is hidden, resulting in a cleaner job table overview. - name = '' + name = 'Run Script' def run_script(self, script, request, data, commit): """ diff --git a/netbox/extras/views.py b/netbox/extras/views.py index 0d98b1324..a87758adc 100644 --- a/netbox/extras/views.py +++ b/netbox/extras/views.py @@ -1181,7 +1181,6 @@ class ScriptView(BaseScriptView): request=copy_safe_request(request), job_timeout=script.python_class.job_timeout, commit=form.cleaned_data.pop('_commit'), - name=script.name ) return redirect('extras:script_result', job_pk=job.pk) diff --git a/netbox/netbox/jobs.py b/netbox/netbox/jobs.py index ae8f2f109..8c3e23730 100644 --- a/netbox/netbox/jobs.py +++ b/netbox/netbox/jobs.py @@ -72,6 +72,7 @@ class JobRunner(ABC): kwargs["job_timeout"] = job.object.python_class.job_timeout cls.enqueue( instance=job.object, + name=job.name, user=job.user, schedule_at=new_scheduled_time, interval=job.interval,