Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #492: Table column ordering #4555

Merged
merged 21 commits into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0ee1112
Initial support for table column reordering
jeremystretch Apr 27, 2020
e8d4935
Create form for setting table preferences
jeremystretch Apr 28, 2020
3442ec7
Enable setting/clearing of table column prefs
jeremystretch Apr 28, 2020
f51e751
Enable reordering table columns
jeremystretch Apr 28, 2020
96eafe6
Document table columns preference
jeremystretch Apr 28, 2020
725e3cd
Extend circuits tables to include all relevant model fields
jeremystretch Apr 28, 2020
8ec2e3c
Introduce default_columns Meta parameter to reduce boilerplate
jeremystretch Apr 28, 2020
55b40d9
Extend DCIM tables (WIP)
jeremystretch Apr 28, 2020
ed21ff5
Merge branch 'develop' into 492-table-column-ordering
jeremystretch Apr 29, 2020
8868760
Always include the 'actions' column, if present
jeremystretch Apr 29, 2020
e3cfc9a
#492: Extend DCIM tables
jeremystretch Apr 29, 2020
7ad27a2
#492: Extend extras tables
jeremystretch Apr 29, 2020
6e9e6af
#492: Extend IPAM tables
jeremystretch Apr 29, 2020
cd0ee4c
#492: Extend secrets tables
jeremystretch Apr 29, 2020
33c44c2
#492: Extend tenancy tables
jeremystretch Apr 29, 2020
c096232
#492: Extend virtualization tables
jeremystretch Apr 29, 2020
3b6d9dc
Add button to select all columns
jeremystretch Apr 29, 2020
f8060ce
Ignore clearing of invalid user config keys
jeremystretch Apr 29, 2020
b0478a7
Enable dynamic queryset field prefetching based on table columns
jeremystretch May 4, 2020
51ccbdf
Remove descriptions from interface connections list
jeremystretch May 4, 2020
7c4d634
Fix group column on RackTable
jeremystretch May 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/development/user-preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ The `users.UserConfig` model holds individual preferences for each user in the f
| ---- | ----------- |
| extras.configcontext.format | Preferred format when rendering config context data (JSON or YAML) |
| pagination.per_page | The number of items to display per page of a paginated table |
| tables.${table_name}.columns | The ordered list of columns to display when viewing the table |
22 changes: 12 additions & 10 deletions netbox/circuits/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@
class ProviderTable(BaseTable):
pk = ToggleColumn()
name = tables.LinkColumn()
circuit_count = tables.Column(
accessor=Accessor('count_circuits'),
verbose_name='Circuits'
)

class Meta(BaseTable.Meta):
model = Provider
fields = ('pk', 'name', 'asn', 'account',)


class ProviderDetailTable(ProviderTable):
circuit_count = tables.Column(accessor=Accessor('count_circuits'), verbose_name='Circuits')

class Meta(ProviderTable.Meta):
model = Provider
fields = ('pk', 'name', 'asn', 'account', 'circuit_count')
fields = ('pk', 'name', 'asn', 'account', 'portal_url', 'noc_contact', 'admin_contact', 'circuit_count')
default_columns = ('pk', 'name', 'asn', 'account', 'circuit_count')


#
Expand All @@ -58,6 +55,7 @@ class CircuitTypeTable(BaseTable):
class Meta(BaseTable.Meta):
model = CircuitType
fields = ('pk', 'name', 'circuit_count', 'description', 'slug', 'actions')
default_columns = ('pk', 'name', 'circuit_count', 'description', 'slug', 'actions')


#
Expand All @@ -79,4 +77,8 @@ class CircuitTable(BaseTable):

class Meta(BaseTable.Meta):
model = Circuit
fields = ('pk', 'cid', 'status', 'type', 'provider', 'tenant', 'a_side', 'z_side', 'description')
fields = (
'pk', 'cid', 'provider', 'type', 'status', 'tenant', 'a_side', 'z_side', 'install_date', 'commit_rate',
'description',
)
default_columns = ('pk', 'cid', 'provider', 'type', 'status', 'tenant', 'a_side', 'z_side', 'description')
6 changes: 3 additions & 3 deletions netbox/circuits/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ProviderListView(PermissionRequiredMixin, ObjectListView):
queryset = Provider.objects.annotate(count_circuits=Count('circuits'))
filterset = filters.ProviderFilterSet
filterset_form = forms.ProviderFilterForm
table = tables.ProviderDetailTable
table = tables.ProviderTable


class ProviderView(PermissionRequiredMixin, View):
Expand Down Expand Up @@ -87,7 +87,7 @@ class ProviderBulkImportView(PermissionRequiredMixin, BulkImportView):

class ProviderBulkEditView(PermissionRequiredMixin, BulkEditView):
permission_required = 'circuits.change_provider'
queryset = Provider.objects.all()
queryset = Provider.objects.annotate(count_circuits=Count('circuits'))
filterset = filters.ProviderFilterSet
table = tables.ProviderTable
form = forms.ProviderBulkEditForm
Expand All @@ -96,7 +96,7 @@ class ProviderBulkEditView(PermissionRequiredMixin, BulkEditView):

class ProviderBulkDeleteView(PermissionRequiredMixin, BulkDeleteView):
permission_required = 'circuits.delete_provider'
queryset = Provider.objects.all()
queryset = Provider.objects.annotate(count_circuits=Count('circuits'))
filterset = filters.ProviderFilterSet
table = tables.ProviderTable
default_return_url = 'circuits:provider_list'
Expand Down
Loading