Skip to content

Commit

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

* Fixes: #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 Oct 7, 2024
1 parent 66d792e commit 4b6e8a9
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 4b6e8a9

Please sign in to comment.