Closes #6038: Include tagged objects list on tag view

This commit is contained in:
Jeremy Stretch
2021-03-29 16:53:41 -04:00
parent 966d6c9a16
commit 7ac9eca2d5
4 changed files with 22 additions and 16 deletions

View File

@@ -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):

View File

@@ -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(),
}