Skip to content

Commit 20a0580

Browse files
PhillSimondsmzbroch
authored andcommitted
Render right_page onboarding template correctly
Currently, the template_content.py DeviceContent class returns `None` if onboarding is not enabled for an OnboardingDevice object. Likewise, if no OnboardingDevice object exists, the template continues trying to access attributes for an OnboardingDevice object. In the first case, template rendering will fail as an empty string is needed in order to insert nothing into the rendered HTML template presented to the user. In the second case, an AttributeError is raised as you can not access attributes of a NoneType object.
1 parent 7260e71 commit 20a0580

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

netbox_onboarding/template_content.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ def right_page(self):
2525
"""Show table on right side of view."""
2626
onboarding = OnboardingDevice.objects.filter(device=self.context["object"]).first()
2727

28+
if not onboarding:
29+
return ""
30+
2831
if not onboarding.enabled:
29-
return None
32+
return ""
3033

3134
status = onboarding.status
3235
last_check_attempt_date = onboarding.last_check_attempt_date

0 commit comments

Comments
 (0)