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
|
@property
|
||||||
def ordering_items(self):
|
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 = []
|
items = []
|
||||||
for col in self.ordering or []:
|
for col in self.ordering or []:
|
||||||
if col.startswith('-'):
|
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.
|
Return only shared objects, or those owned by the current user, unless this is a superuser.
|
||||||
"""
|
"""
|
||||||
queryset = super().get_queryset(request)
|
queryset = super().get_queryset(request)
|
||||||
user = request.user
|
if request.user.is_superuser:
|
||||||
if user.is_superuser:
|
|
||||||
return queryset
|
return queryset
|
||||||
if user.is_anonymous:
|
if request.user.is_anonymous:
|
||||||
return queryset.filter(shared=True)
|
return queryset.filter(shared=True)
|
||||||
return queryset.filter(
|
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)
|
tableconfig = get_object_or_404(TableConfig, pk=tableconfig_id)
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
table = self.table.__name__
|
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)
|
request.user.config.set(f'tables.{table}.ordering', tableconfig.ordering, commit=True)
|
||||||
return redirect(request.path)
|
return redirect(request.path)
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ class ObjectListView(BaseMultiObjectView, ActionsMixin, TableMixin):
|
|||||||
|
|
||||||
# Retrieve available configurations for the table
|
# Retrieve available configurations for the table
|
||||||
table_configs = TableConfig.objects.filter(
|
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,
|
object_type=object_type,
|
||||||
table=table.name,
|
table=table.name,
|
||||||
enabled=True,
|
enabled=True,
|
||||||
|
Loading…
Reference in New Issue
Block a user