Move the application of user preferences in BaseTable to its configure() method #6446

Closed
opened 2025-12-29 19:40:49 +01:00 by adam · 3 comments
Owner

Originally created by @jeremystretch on GitHub (May 4, 2022).

Proposed Changes

NetBox's BaseTable class accepts a user instance as an optional argument for instantiation. If provided, the table will be configured per the user's preferences (if any). The class also provides a configure() method, which handles pagination and ordering per the request.

As the configure() method already has access to the current request, it makes sense to handle the application of user preferences here as well. The column selection logic can be moved from __init__() to configure().

Justification

This would obviate the need to pass the user to the table during instantiation, reducing boilerplate and avoiding errant omissions (see #9260).

Originally created by @jeremystretch on GitHub (May 4, 2022). ### Proposed Changes NetBox's `BaseTable` class accepts a user instance as an optional argument for instantiation. If provided, the table will be configured per the user's preferences (if any). The class also provides a `configure()` method, which handles pagination and ordering per the request. As the `configure()` method already has access to the current request, it makes sense to handle the application of user preferences here as well. The column selection logic can be moved from `__init__()` to `configure()`. ### Justification This would obviate the need to pass the user to the table during instantiation, reducing boilerplate and avoiding errant omissions (see #9260).
adam added the type: housekeeping label 2025-12-29 19:40:49 +01:00
adam closed this issue 2025-12-29 19:40:49 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jun 23, 2022):

Need to dig further into this; it may require additional juggling of the table instantiation logic.

@jeremystretch commented on GitHub (Jun 23, 2022): Need to dig further into this; it may require additional juggling of the table instantiation logic.
Author
Owner

@github-actions[bot] commented on GitHub (Aug 23, 2022):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Aug 23, 2022): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@jeremystretch commented on GitHub (Sep 13, 2022):

Going to close this out as it would likely be more effort than it's worth. Something we can revisit in the future if needed.

@jeremystretch commented on GitHub (Sep 13, 2022): Going to close this out as it would likely be more effort than it's worth. Something we can revisit in the future if needed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6446