mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #6038: Include tagged objects list on tag view
This commit is contained in:
@ -99,6 +99,7 @@ A new Cloud model has been introduced to represent the boundary of a network tha
|
||||
* [#5971](https://github.com/netbox-community/netbox/issues/5971) - Add dedicated views for organizational models
|
||||
* [#5972](https://github.com/netbox-community/netbox/issues/5972) - Enable bulk editing for organizational models
|
||||
* [#5975](https://github.com/netbox-community/netbox/issues/5975) - Allow partial (decimal) vCPU allocations for virtual machines
|
||||
* [#6038](https://github.com/netbox-community/netbox/issues/6038) - Include tagged objects list on tag view
|
||||
|
||||
### Other Changes
|
||||
|
||||
|
@ -6,14 +6,6 @@ from utilities.tables import (
|
||||
)
|
||||
from .models import ConfigContext, JournalEntry, ObjectChange, Tag, TaggedItem
|
||||
|
||||
TAGGED_ITEM = """
|
||||
{% if value.get_absolute_url %}
|
||||
<a href="{{ value.get_absolute_url }}">{{ value }}</a>
|
||||
{% else %}
|
||||
{{ value }}
|
||||
{% endif %}
|
||||
"""
|
||||
|
||||
CONFIGCONTEXT_ACTIONS = """
|
||||
{% if perms.extras.change_configcontext %}
|
||||
<a href="{% url 'extras:configcontext_edit' pk=record.pk %}" class="btn btn-xs btn-warning"><i class="mdi mdi-pencil" aria-hidden="true"></i></a>
|
||||
@ -50,18 +42,18 @@ class TagTable(BaseTable):
|
||||
|
||||
|
||||
class TaggedItemTable(BaseTable):
|
||||
content_object = tables.TemplateColumn(
|
||||
template_code=TAGGED_ITEM,
|
||||
content_type = ContentTypeColumn(
|
||||
verbose_name='Type'
|
||||
)
|
||||
content_object = tables.Column(
|
||||
linkify=True,
|
||||
orderable=False,
|
||||
verbose_name='Object'
|
||||
)
|
||||
content_type = tables.Column(
|
||||
verbose_name='Type'
|
||||
)
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = TaggedItem
|
||||
fields = ('content_object', 'content_type')
|
||||
fields = ('content_type', 'content_object')
|
||||
|
||||
|
||||
class ConfigContextTable(BaseTable):
|
||||
|
@ -39,8 +39,14 @@ class TagView(generic.ObjectView):
|
||||
|
||||
def get_extra_context(self, request, instance):
|
||||
tagged_items = TaggedItem.objects.filter(tag=instance)
|
||||
taggeditem_table = tables.TaggedItemTable(
|
||||
data=tagged_items,
|
||||
orderable=False
|
||||
)
|
||||
paginate_table(taggeditem_table, request)
|
||||
|
||||
return {
|
||||
'taggeditem_table': taggeditem_table,
|
||||
'tagged_item_count': tagged_items.count(),
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
<tr>
|
||||
<td>Tagged Items</td>
|
||||
<td>
|
||||
{{ tagged_item_count }}
|
||||
{{ taggeditem_table.rows|length }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -45,7 +45,14 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{% plugin_full_width_page object %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<strong>Device Types</strong>
|
||||
</div>
|
||||
{% include 'inc/table.html' with table=taggeditem_table %}
|
||||
</div>
|
||||
{% include 'inc/paginator.html' with paginator=taggeditem_table.paginator page=taggeditem_table.page %}
|
||||
{% plugin_full_width_page object %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user