Add reverse accesor from tag to document, move the search field definition for tag to the tag app
This commit is contained in:
@@ -152,7 +152,6 @@ document_search.add_model_field('metadata__metadata_type__name', label=_(u'Metad
|
||||
document_search.add_model_field('metadata__value', label=_(u'Metadata value'))
|
||||
document_search.add_model_field('versions__pages__content', label=_(u'Content'))
|
||||
document_search.add_model_field('description', label=_(u'Description'))
|
||||
document_search.add_model_field('tags__name', label=_(u'Tags'))
|
||||
document_search.add_related_field('comments', 'Comment', 'comment', 'object_pk', label=_(u'Comments'))
|
||||
|
||||
namespace = StatisticNamespace(name='documents', label=_(u'Documents'))
|
||||
|
||||
@@ -4,6 +4,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from acls.api import class_permissions
|
||||
from common.utils import encapsulate
|
||||
from documents import document_search
|
||||
from documents.models import Document
|
||||
from navigation.api import (register_links, register_model_list_columns,
|
||||
register_multi_item_links, register_top_menu)
|
||||
@@ -21,13 +22,6 @@ from .permissions import (PERMISSION_TAG_ATTACH, PERMISSION_TAG_DELETE,
|
||||
from .urls import api_urls
|
||||
from .widgets import (get_tags_inline_widget_simple, single_tag_widget)
|
||||
|
||||
|
||||
def document_tags(self):
|
||||
return Tag.objects.filter(documents=self)
|
||||
|
||||
|
||||
Document.add_to_class('tags', property(document_tags))
|
||||
|
||||
class_permissions(Document, [
|
||||
PERMISSION_TAG_ATTACH, PERMISSION_TAG_REMOVE,
|
||||
])
|
||||
@@ -67,3 +61,5 @@ register_links(['tags:document_tags', 'tags:tag_remove', 'tag_multiple_remove',
|
||||
register_multi_item_links(['document_tags'], [single_document_multiple_tag_remove])
|
||||
|
||||
register_multi_item_links(['documents:document_find_duplicates', 'folders:folder_view', 'indexes:index_instance_node_view', 'documents:document_type_document_list', 'search:search', 'search:results', 'linking:document_group_view', 'documents:document_list', 'documents:document_list_recent', 'tags:tag_tagged_item_list'], [tag_multiple_attach, multiple_documents_selection_tag_remove])
|
||||
|
||||
document_search.add_model_field('tags__label', label=_(u'Tags'))
|
||||
|
||||
@@ -11,7 +11,7 @@ from .literals import COLOR_CHOICES, COLOR_CODES
|
||||
class Tag(models.Model):
|
||||
label = models.CharField(max_length=128, verbose_name=_(u'Label'), unique=True, db_index=True)
|
||||
color = models.CharField(max_length=3, choices=COLOR_CHOICES, verbose_name=_(u'Color'))
|
||||
documents = models.ManyToManyField(Document)
|
||||
documents = models.ManyToManyField(Document, related_name='tags', verbose_name=_('Documents'))
|
||||
|
||||
class Meta:
|
||||
verbose_name = _(u'Tag')
|
||||
|
||||
Reference in New Issue
Block a user