Просмотр исходного кода

Label the job detail panel attribute "Execution Time"

Renaming the attribute to elapsed_time changed its auto-derived label to
"Elapsed time", disagreeing with the list column, the filter form, the API
field and the model docs. The derived label is also built at runtime before
being passed to gettext, so it would never have been extracted into the
message catalog. An explicit label addresses both.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Jeremy Stretch 2 недель назад
Родитель
Сommit
26b5eb8a83
2 измененных файлов с 9 добавлено и 2 удалено
  1. 4 1
      netbox/core/tests/test_views.py
  2. 5 1
      netbox/core/ui/panels.py

+ 4 - 1
netbox/core/tests/test_views.py

@@ -167,7 +167,10 @@ class JobTestCase(
         completed.save()
         response = self.client.get(completed.get_absolute_url())
         self.assertHttpStatus(response, 200)
-        self.assertIn('1m 30s', str(response.content))
+        content = str(response.content)
+        self.assertIn('1m 30s', content)
+        # The panel must use the same label as the list column, filter form, and API field
+        self.assertIn('Execution Time', content)
 
         running = Job.objects.get(name='Job 2')
         running.started = now - timedelta(hours=2)

+ 5 - 1
netbox/core/ui/panels.py

@@ -62,7 +62,11 @@ class JobSchedulingPanel(panels.ObjectAttributesPanel):
     scheduled = attrs.TemplatedAttr('scheduled', template_name='core/job/attrs/scheduled.html')
     started = attrs.DateTimeAttr('started')
     completed = attrs.DateTimeAttr('completed')
-    elapsed_time = attrs.TemplatedAttr('elapsed_time', template_name='core/job/attrs/elapsed_time.html')
+    elapsed_time = attrs.TemplatedAttr(
+        'elapsed_time',
+        label=_('Execution Time'),
+        template_name='core/job/attrs/elapsed_time.html',
+    )
     queue = attrs.TextAttr('queue_name', label=_('Queue'))