Skip to content

Commit

Permalink
Fixes #12914: Clear stored ordering from user config when cleared by …
Browse files Browse the repository at this point in the history
…request
  • Loading branch information
jeremystretch committed Jun 15, 2023
1 parent 8aeb317 commit 7fc69f3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions netbox/netbox/tables/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,14 @@ def configure(self, request):
if request.user.is_authenticated:
table_name = self.__class__.__name__
if self.prefixed_order_by_field in request.GET:
# If an ordering has been specified as a query parameter, save it as the
# user's preferred ordering for this table.
ordering = request.GET.getlist(self.prefixed_order_by_field)
request.user.config.set(f'tables.{table_name}.ordering', ordering, commit=True)
if request.GET[self.prefixed_order_by_field]:
# If an ordering has been specified as a query parameter, save it as the
# user's preferred ordering for this table.
ordering = request.GET.getlist(self.prefixed_order_by_field)
request.user.config.set(f'tables.{table_name}.ordering', ordering, commit=True)
else:
# If the ordering has been set to none (empty), clear any existing preference.
request.user.config.clear(f'tables.{table_name}.ordering', commit=True)
elif ordering := request.user.config.get(f'tables.{table_name}.ordering'):
# If no ordering has been specified, set the preferred ordering (if any).
self.order_by = ordering
Expand Down

0 comments on commit 7fc69f3

Please sign in to comment.