Abstract the way tag documents are retrieved
This commit is contained in:
@@ -61,7 +61,11 @@ class_permissions(Tag, [
|
||||
PERMISSION_TAG_VIEW,
|
||||
])
|
||||
|
||||
def tag_documents(self):
|
||||
return Document.objects.filter(tags__in=[self])
|
||||
|
||||
Document.add_to_class('tags', TaggableManager())
|
||||
Tag.add_to_class('documents', property(tag_documents))
|
||||
|
||||
endpoint = APIEndPoint('tags')
|
||||
endpoint.register_urls(api_urls)
|
||||
|
||||
@@ -236,7 +236,7 @@ def tag_tagged_item_list(request, tag_id):
|
||||
|
||||
return document_list(
|
||||
request,
|
||||
object_list=Document.objects.filter(tags__in=[tag]),
|
||||
object_list=tag.documents.all(),
|
||||
title=_('documents with the tag "%s"') % tag,
|
||||
extra_context={
|
||||
'object': tag,
|
||||
|
||||
Reference in New Issue
Block a user