Move comments and tags manager statements to their respective apps
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.conf import settings
|
||||
from django.contrib.comments.models import Comment
|
||||
from django.contrib.contenttypes import generic
|
||||
|
||||
from navigation.api import register_links, \
|
||||
register_model_list_columns
|
||||
@@ -47,3 +48,12 @@ register_links(['comments_for_object', 'comment_add', 'comment_delete', 'comment
|
||||
register_links(Comment, [comment_delete])
|
||||
|
||||
register_links(Document, [comments_for_object], menu_name='form_header')
|
||||
|
||||
Document.add_to_class(
|
||||
'comments',
|
||||
generic.GenericRelation(
|
||||
Comment,
|
||||
content_type_field='content_type',
|
||||
object_id_field='object_pk'
|
||||
)
|
||||
)
|
||||
|
||||
@@ -15,11 +15,8 @@ from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.contenttypes import generic
|
||||
from django.contrib.comments.models import Comment
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
from taggit.managers import TaggableManager
|
||||
from dynamic_search.api import register
|
||||
from converter.api import get_page_count
|
||||
from converter.api import get_available_transformations_choices
|
||||
@@ -86,14 +83,6 @@ class Document(models.Model):
|
||||
description = models.TextField(blank=True, null=True, verbose_name=_(u'description'))
|
||||
date_added = models.DateTimeField(verbose_name=_(u'added'), db_index=True, editable=False)
|
||||
|
||||
tags = TaggableManager()
|
||||
|
||||
comments = generic.GenericRelation(
|
||||
Comment,
|
||||
content_type_field='content_type',
|
||||
object_id_field='object_pk'
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def clear_image_cache():
|
||||
for the_file in os.listdir(CACHE_PATH):
|
||||
|
||||
@@ -7,6 +7,7 @@ from common.utils import encapsulate
|
||||
from documents.models import Document
|
||||
|
||||
from taggit.models import Tag
|
||||
from taggit.managers import TaggableManager
|
||||
|
||||
from tags.widgets import tag_color_block
|
||||
|
||||
@@ -61,3 +62,5 @@ register_links(Document, [tag_document_list], menu_name='form_header')
|
||||
register_links(['document_tags', 'tag_add_attach', 'tag_remove', 'tag_multiple_remove'], [tag_add_attach], menu_name='sidebar')
|
||||
|
||||
register_multi_item_links(['document_tags'], [tag_document_remove_multiple])
|
||||
|
||||
Document.add_to_class('tags', TaggableManager())
|
||||
|
||||
Reference in New Issue
Block a user