Files
mayan-edms/mayan/apps/document_comments/apps.py
Roberto Rosario 0699ad0556 Add support for new document page structure
Documents now have their own dedicated DocumentPage
submodel. The old DocumentPage is now called DocumentVersionPage.
This allows mappings between document pages and document version
pages, allowing renumbering, appending pages.
DocumentPages have a content_object to map them to any other
object. For now they only map to DocumentVersionPages.
New option added to the version upload form to append the
pages of the new version.
A new view was added to just append new pages with wraps the
new document version upload form and hides the append pages
checkbox set to True.
Add a new action, reset_pages to reset the pages of the
document to those of the latest version.

Missing: appending tests, checks for proper content_object in OCR and
document parsing.

Author: Roberto Rosario <roberto.rosario@mayan-edms.com>
Date:   Thu Oct 11 12:00:25 2019 -0400
2019-10-10 11:55:42 -04:00

122 lines
3.9 KiB
Python

from __future__ import absolute_import, unicode_literals
from django.apps import apps
from django.utils.translation import ugettext_lazy as _
from mayan.apps.acls.classes import ModelPermission
from mayan.apps.common.apps import MayanAppConfig
from mayan.apps.common.menus import (
menu_facet, menu_list_facet, menu_object, menu_secondary
)
from mayan.apps.documents.search import (
document_page_search, document_search, document_version_page_search
)
from mayan.apps.events.classes import ModelEventType
from mayan.apps.events.links import (
link_events_for_object, link_object_event_types_user_subcriptions_list
)
from mayan.apps.events.permissions import permission_events_view
from mayan.apps.navigation.classes import SourceColumn
from .events import (
event_document_comment_created, event_document_comment_deleted,
event_document_comment_edited
)
from .links import (
link_comment_add, link_comment_delete, link_comment_edit,
link_comments_for_document
)
from .permissions import (
permission_document_comment_create, permission_document_comment_delete,
permission_document_comment_edit, permission_document_comment_view
)
class DocumentCommentsApp(MayanAppConfig):
app_namespace = 'comments'
app_url = 'comments'
has_rest_api = True
has_tests = True
name = 'mayan.apps.document_comments'
verbose_name = _('Document comments')
def ready(self):
super(DocumentCommentsApp, self).ready()
from actstream import registry
Document = apps.get_model(
app_label='documents', model_name='Document'
)
Comment = self.get_model(model_name='Comment')
ModelEventType.register(
model=Comment, event_types=(
event_document_comment_edited,
)
)
ModelEventType.register(
model=Document, event_types=(
event_document_comment_created, event_document_comment_deleted,
event_document_comment_edited
)
)
ModelPermission.register(
model=Comment, permissions=(permission_events_view,)
)
ModelPermission.register_inheritance(
model=Comment, related='document',
)
ModelPermission.register(
model=Document, permissions=(
permission_document_comment_create,
permission_document_comment_delete,
permission_document_comment_edit,
permission_document_comment_view
)
)
SourceColumn(attribute='submit_date', source=Comment)
SourceColumn(attribute='get_user_label', source=Comment)
SourceColumn(attribute='comment', source=Comment)
document_page_search.add_model_field(
field='document__comments__comment',
label=_('Comments')
)
document_search.add_model_field(
field='comments__comment',
label=_('Comments')
)
document_version_page_search.add_model_field(
field='document_version__document__comments__comment',
label=_('Comments')
)
menu_facet.bind_links(
links=(link_comments_for_document,), sources=(Document,)
)
menu_list_facet.bind_links(
links=(
link_events_for_object,
link_object_event_types_user_subcriptions_list
), sources=(Comment,)
)
menu_secondary.bind_links(
links=(link_comment_add,),
sources=(
'comments:comments_for_document', 'comments:comment_add',
'comments:comment_delete', 'comments:comment_details',
'comments:comment_edit', 'comments:comment_multiple_delete'
)
)
menu_object.bind_links(
links=(link_comment_delete, link_comment_edit), sources=(Comment,)
)
registry.register(Comment)