Skip to content

Commit

Permalink
Fixes: netbox-community#17566 - Fix issue Job.get_absolute_url() to…
Browse files Browse the repository at this point in the history
… prevent exception being thrown if no object_type is set (netbox-community#17661)

* Fixes: netbox-community#17566 - Fix issue `Job.get_absolute_url()` to prevent exception being thrown if no object_type is set

* Add back whitespace after statements

* Remove whitespace.  Change to if statement
  • Loading branch information
DanSheps authored and jeremystretch committed Oct 11, 2024
1 parent a5a71db commit 782374f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions netbox/core/models/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ def __str__(self):

def get_absolute_url(self):
# TODO: Employ dynamic registration
if self.object_type.model == 'reportmodule':
return reverse(f'extras:report_result', kwargs={'job_pk': self.pk})
if self.object_type.model == 'scriptmodule':
return reverse(f'extras:script_result', kwargs={'job_pk': self.pk})
if self.object_type:
if self.object_type.model == 'reportmodule':
return reverse(f'extras:report_result', kwargs={'job_pk': self.pk})
elif self.object_type.model == 'scriptmodule':
return reverse(f'extras:script_result', kwargs={'job_pk': self.pk})
return reverse('core:job', args=[self.pk])

def get_status_color(self):
Expand Down

0 comments on commit 782374f

Please sign in to comment.