Skip to content

Commit 34d37db

Browse files
committed
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 5865734 commit 34d37db

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)