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
|
* [#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
|
* [#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
|
* [#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
|
### Other Changes
|
||||||
|
|
||||||
|
@ -6,14 +6,6 @@ from utilities.tables import (
|
|||||||
)
|
)
|
||||||
from .models import ConfigContext, JournalEntry, ObjectChange, Tag, TaggedItem
|
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 = """
|
CONFIGCONTEXT_ACTIONS = """
|
||||||
{% if perms.extras.change_configcontext %}
|
{% 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>
|
<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):
|
class TaggedItemTable(BaseTable):
|
||||||
content_object = tables.TemplateColumn(
|
content_type = ContentTypeColumn(
|
||||||
template_code=TAGGED_ITEM,
|
verbose_name='Type'
|
||||||
|
)
|
||||||
|
content_object = tables.Column(
|
||||||
|
linkify=True,
|
||||||
orderable=False,
|
orderable=False,
|
||||||
verbose_name='Object'
|
verbose_name='Object'
|
||||||
)
|
)
|
||||||
content_type = tables.Column(
|
|
||||||
verbose_name='Type'
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta(BaseTable.Meta):
|
class Meta(BaseTable.Meta):
|
||||||
model = TaggedItem
|
model = TaggedItem
|
||||||
fields = ('content_object', 'content_type')
|
fields = ('content_type', 'content_object')
|
||||||
|
|
||||||
|
|
||||||
class ConfigContextTable(BaseTable):
|
class ConfigContextTable(BaseTable):
|
||||||
|
@ -39,8 +39,14 @@ class TagView(generic.ObjectView):
|
|||||||
|
|
||||||
def get_extra_context(self, request, instance):
|
def get_extra_context(self, request, instance):
|
||||||
tagged_items = TaggedItem.objects.filter(tag=instance)
|
tagged_items = TaggedItem.objects.filter(tag=instance)
|
||||||
|
taggeditem_table = tables.TaggedItemTable(
|
||||||
|
data=tagged_items,
|
||||||
|
orderable=False
|
||||||
|
)
|
||||||
|
paginate_table(taggeditem_table, request)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
'taggeditem_table': taggeditem_table,
|
||||||
'tagged_item_count': tagged_items.count(),
|
'tagged_item_count': tagged_items.count(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>Tagged Items</td>
|
<td>Tagged Items</td>
|
||||||
<td>
|
<td>
|
||||||
{{ tagged_item_count }}
|
{{ taggeditem_table.rows|length }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -45,7 +45,14 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Reference in New Issue
Block a user