mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-26 18:38:38 -06:00
Misc cleanup
This commit is contained in:
parent
eede8f110d
commit
c9b1d60a16
@ -601,6 +601,10 @@ class TableConfig(ChangeLoggedModel):
|
||||
|
||||
@property
|
||||
def ordering_items(self):
|
||||
"""
|
||||
Return a list of two-tuples indicating the column(s) by which the table is to be ordered and a boolean for each
|
||||
column indicating whether its ordering is ascending.
|
||||
"""
|
||||
items = []
|
||||
for col in self.ordering or []:
|
||||
if col.startswith('-'):
|
||||
|
@ -25,13 +25,12 @@ class SharedObjectViewMixin:
|
||||
Return only shared objects, or those owned by the current user, unless this is a superuser.
|
||||
"""
|
||||
queryset = super().get_queryset(request)
|
||||
user = request.user
|
||||
if user.is_superuser:
|
||||
if request.user.is_superuser:
|
||||
return queryset
|
||||
if user.is_anonymous:
|
||||
if request.user.is_anonymous:
|
||||
return queryset.filter(shared=True)
|
||||
return queryset.filter(
|
||||
Q(shared=True) | Q(user=user)
|
||||
Q(shared=True) | Q(user=request.user)
|
||||
)
|
||||
|
||||
|
||||
|
@ -140,7 +140,7 @@ class ObjectListView(BaseMultiObjectView, ActionsMixin, TableMixin):
|
||||
tableconfig = get_object_or_404(TableConfig, pk=tableconfig_id)
|
||||
if request.user.is_authenticated:
|
||||
table = self.table.__name__
|
||||
request.user.config.set(f'tables.{table}.columns', tableconfig.columns, commit=True)
|
||||
request.user.config.set(f'tables.{table}.columns', tableconfig.columns)
|
||||
request.user.config.set(f'tables.{table}.ordering', tableconfig.ordering, commit=True)
|
||||
return redirect(request.path)
|
||||
|
||||
@ -181,7 +181,7 @@ class ObjectListView(BaseMultiObjectView, ActionsMixin, TableMixin):
|
||||
|
||||
# Retrieve available configurations for the table
|
||||
table_configs = TableConfig.objects.filter(
|
||||
Q(shared=True) | Q(user=request.user),
|
||||
Q(shared=True) | Q(user=request.user if request.user.is_authenticated else None),
|
||||
object_type=object_type,
|
||||
table=table.name,
|
||||
enabled=True,
|
||||
|
Loading…
Reference in New Issue
Block a user