mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-25 01:48:38 -06:00
Removed tags filter field from view
This commit is contained in:
parent
834fd408bd
commit
a8d9fe799b
@ -6,9 +6,9 @@ from django.contrib import messages
|
|||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.db import transaction, IntegrityError
|
from django.db import transaction, IntegrityError
|
||||||
from django.db.models import Count, ProtectedError
|
from django.db.models import ProtectedError
|
||||||
from django.db.models.query import QuerySet
|
from django.db.models.query import QuerySet
|
||||||
from django.forms import CharField, Form, ModelMultipleChoiceField, MultipleChoiceField, MultipleHiddenInput, Textarea
|
from django.forms import CharField, Form, ModelMultipleChoiceField, MultipleHiddenInput, Textarea
|
||||||
from django.http import HttpResponse, HttpResponseServerError
|
from django.http import HttpResponse, HttpResponseServerError
|
||||||
from django.shortcuts import get_object_or_404, redirect, render
|
from django.shortcuts import get_object_or_404, redirect, render
|
||||||
from django.template import loader
|
from django.template import loader
|
||||||
@ -24,7 +24,7 @@ from django_tables2 import RequestConfig
|
|||||||
|
|
||||||
from extras.models import CustomField, CustomFieldValue, ExportTemplate
|
from extras.models import CustomField, CustomFieldValue, ExportTemplate
|
||||||
from extras.querysets import CustomFieldQueryset
|
from extras.querysets import CustomFieldQueryset
|
||||||
from utilities.forms import BootstrapMixin, CSVDataField, StaticSelect2Multiple
|
from utilities.forms import BootstrapMixin, CSVDataField
|
||||||
from utilities.utils import csv_format
|
from utilities.utils import csv_format
|
||||||
from .error_handlers import handle_protectederror
|
from .error_handlers import handle_protectederror
|
||||||
from .forms import ConfirmationForm
|
from .forms import ConfirmationForm
|
||||||
@ -94,7 +94,6 @@ class ObjectListView(View):
|
|||||||
|
|
||||||
model = self.queryset.model
|
model = self.queryset.model
|
||||||
content_type = ContentType.objects.get_for_model(model)
|
content_type = ContentType.objects.get_for_model(model)
|
||||||
filter_form = self.filter_form(request.GET, label_suffix='') if self.filter_form else None
|
|
||||||
|
|
||||||
if self.filter:
|
if self.filter:
|
||||||
self.queryset = self.filter(request.GET, self.queryset).qs
|
self.queryset = self.filter(request.GET, self.queryset).qs
|
||||||
@ -143,18 +142,6 @@ class ObjectListView(View):
|
|||||||
if 'pk' in table.base_columns and (permissions['change'] or permissions['delete']):
|
if 'pk' in table.base_columns and (permissions['change'] or permissions['delete']):
|
||||||
table.columns.show('pk')
|
table.columns.show('pk')
|
||||||
|
|
||||||
# Add the tags filter field to the from if the model has tags
|
|
||||||
if hasattr(model, 'tags') and filter_form:
|
|
||||||
tags = model.tags.annotate(count=Count('extras_taggeditem_items')).order_by('name')
|
|
||||||
choices = [(str(tag.slug), '{} ({})'.format(tag.name, tag.count)) for tag in tags]
|
|
||||||
|
|
||||||
filter_form.fields['tag'] = MultipleChoiceField(
|
|
||||||
label='Tags',
|
|
||||||
choices=choices,
|
|
||||||
required=False,
|
|
||||||
widget=StaticSelect2Multiple(),
|
|
||||||
)
|
|
||||||
|
|
||||||
# Apply the request context
|
# Apply the request context
|
||||||
paginate = {
|
paginate = {
|
||||||
'paginator_class': EnhancedPaginator,
|
'paginator_class': EnhancedPaginator,
|
||||||
@ -166,7 +153,7 @@ class ObjectListView(View):
|
|||||||
'content_type': content_type,
|
'content_type': content_type,
|
||||||
'table': table,
|
'table': table,
|
||||||
'permissions': permissions,
|
'permissions': permissions,
|
||||||
'filter_form': filter_form,
|
'filter_form': self.filter_form(request.GET, label_suffix='') if self.filter_form else None,
|
||||||
}
|
}
|
||||||
context.update(self.extra_context())
|
context.update(self.extra_context())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user