Silence 90% of remaining Django 1.8 model warnings.
This commit is contained in:
@@ -2,7 +2,7 @@ from __future__ import unicode_literals, absolute_import
|
||||
|
||||
import logging
|
||||
|
||||
from permissions.models import StoredPermission
|
||||
from django.apps import apps
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -20,6 +20,10 @@ class ModelPermission(object):
|
||||
|
||||
@classmethod
|
||||
def get_for_instance(cls, instance):
|
||||
StoredPermission = apps.get_model(
|
||||
app_label='permissions', model_name='StoredPermission'
|
||||
)
|
||||
|
||||
try:
|
||||
permissions = cls._registry[type(instance)]
|
||||
except KeyError:
|
||||
|
||||
@@ -4,11 +4,11 @@ from datetime import timedelta
|
||||
|
||||
from kombu import Exchange, Queue
|
||||
|
||||
from django.apps import apps
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from acls import ModelPermission
|
||||
from common import MayanAppConfig, menu_facet, menu_main, menu_sidebar
|
||||
from documents.models import Document
|
||||
from mayan.celery import app
|
||||
from rest_api.classes import APIEndPoint
|
||||
|
||||
@@ -35,6 +35,10 @@ class CheckoutsApp(MayanAppConfig):
|
||||
|
||||
APIEndPoint(app=self, version_string='1')
|
||||
|
||||
Document = apps.get_model(
|
||||
app_label='documents', model_name='Document'
|
||||
)
|
||||
|
||||
DocumentCheckout = self.get_model('DocumentCheckout')
|
||||
|
||||
Document.add_to_class(
|
||||
|
||||
@@ -2,17 +2,22 @@ from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from django.apps import apps
|
||||
|
||||
from lock_manager import Lock, LockError
|
||||
from mayan.celery import app
|
||||
|
||||
from .literals import CHECKOUT_EXPIRATION_LOCK_EXPIRE
|
||||
from .models import DocumentCheckout
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@app.task(ignore_result=True)
|
||||
def task_check_expired_check_outs():
|
||||
DocumentCheckout = apps.get_model(
|
||||
app_label='checkouts', model_name='DocumentCheckout'
|
||||
)
|
||||
|
||||
logger.debug('executing...')
|
||||
lock_id = 'task_expired_check_outs'
|
||||
try:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext
|
||||
@@ -125,7 +126,9 @@ class Filter(object):
|
||||
return unicode(self.label)
|
||||
|
||||
def get_queryset(self, user):
|
||||
from acls.models import AccessControlList
|
||||
AccessControlList = apps.get_model(
|
||||
app_label='acls', model_name='AccessControlList'
|
||||
)
|
||||
|
||||
queryset = self.model.objects.all()
|
||||
for kwargs in self.filter_kwargs:
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
from django.utils import timezone, translation
|
||||
|
||||
from .models import UserLocaleProfile
|
||||
|
||||
|
||||
def user_locale_profile_session_config(sender, request, user, **kwargs):
|
||||
UserLocaleProfile = apps.get_model(
|
||||
app_label='common', model_name='UserLocaleProfile'
|
||||
)
|
||||
|
||||
user_locale_profile, created = UserLocaleProfile.objects.get_or_create(
|
||||
user=user
|
||||
)
|
||||
@@ -34,5 +37,9 @@ def user_locale_profile_session_config(sender, request, user, **kwargs):
|
||||
|
||||
|
||||
def user_locale_profile_create(sender, instance, created, **kwargs):
|
||||
UserLocaleProfile = apps.get_model(
|
||||
app_label='common', model_name='UserLocaleProfile'
|
||||
)
|
||||
|
||||
if created:
|
||||
UserLocaleProfile.objects.create(user=instance)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.core.exceptions import PermissionDenied
|
||||
@@ -7,7 +8,6 @@ from django.core.urlresolvers import reverse
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.utils.translation import ungettext
|
||||
|
||||
from acls.models import AccessControlList
|
||||
from permissions import Permission
|
||||
|
||||
__all__ = (
|
||||
@@ -85,6 +85,10 @@ class ObjectListPermissionFilterMixin(object):
|
||||
object_permission = None
|
||||
|
||||
def get_queryset(self):
|
||||
AccessControlList = apps.get_model(
|
||||
app_label='acls', model_name='AccessControlList'
|
||||
)
|
||||
|
||||
queryset = super(ObjectListPermissionFilterMixin, self).get_queryset()
|
||||
|
||||
if self.object_permission:
|
||||
@@ -113,6 +117,10 @@ class ObjectPermissionCheckMixin(object):
|
||||
return self.get_object()
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
AccessControlList = apps.get_model(
|
||||
app_label='acls', model_name='AccessControlList'
|
||||
)
|
||||
|
||||
if self.object_permission:
|
||||
try:
|
||||
Permission.check_permissions(
|
||||
|
||||
@@ -3,12 +3,12 @@ from __future__ import unicode_literals
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from django.apps import apps
|
||||
from django.utils.timezone import now
|
||||
|
||||
from mayan.celery import app
|
||||
|
||||
from .literals import UPLOAD_EXPIRATION_INTERVAL
|
||||
from .models import SharedUploadedFile
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -17,6 +17,10 @@ logger = logging.getLogger(__name__)
|
||||
def task_delete_stale_uploads():
|
||||
logger.info('Executing')
|
||||
|
||||
SharedUploadedFile = apps.get_model(
|
||||
app_label='common', model_name='SharedUploadedFile'
|
||||
)
|
||||
|
||||
for expired_upload in SharedUploadedFile.objects.filter(datetime__lt=now() - timedelta(seconds=UPLOAD_EXPIRATION_INTERVAL)):
|
||||
expired_upload.delete()
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from acls import ModelPermission
|
||||
from common import MayanAppConfig, menu_facet, menu_object, menu_sidebar
|
||||
from documents.models import Document
|
||||
from navigation import SourceColumn
|
||||
|
||||
from .links import (
|
||||
@@ -25,6 +25,10 @@ class DocumentCommentsApp(MayanAppConfig):
|
||||
def ready(self):
|
||||
super(DocumentCommentsApp, self).ready()
|
||||
|
||||
Document = apps.get_model(
|
||||
app_label='documents', model_name='Document'
|
||||
)
|
||||
|
||||
Comment = self.get_model('Comment')
|
||||
|
||||
ModelPermission.register(
|
||||
|
||||
@@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from kombu import Exchange, Queue
|
||||
|
||||
from django.apps import apps
|
||||
from django.db.models.signals import post_save, post_delete
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
@@ -11,10 +12,8 @@ from common import (
|
||||
)
|
||||
from common.classes import Package
|
||||
from common.widgets import two_state_template
|
||||
from documents.models import Document
|
||||
from documents.signals import post_document_created
|
||||
from mayan.celery import app
|
||||
from metadata.models import DocumentMetadata
|
||||
from navigation import SourceColumn
|
||||
from rest_api.classes import APIEndPoint
|
||||
|
||||
@@ -43,6 +42,14 @@ class DocumentIndexingApp(MayanAppConfig):
|
||||
def ready(self):
|
||||
super(DocumentIndexingApp, self).ready()
|
||||
|
||||
Document = apps.get_model(
|
||||
app_label='documents', model_name='Document'
|
||||
)
|
||||
|
||||
DocumentMetadata = apps.get_model(
|
||||
app_label='metadata', model_name='DocumentMetadata'
|
||||
)
|
||||
|
||||
DocumentIndexInstanceNode = self.get_model('DocumentIndexInstanceNode')
|
||||
Index = self.get_model('Index')
|
||||
IndexInstance = self.get_model('IndexInstance')
|
||||
|
||||
@@ -2,20 +2,23 @@ from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from django.apps import apps
|
||||
from django.db import OperationalError
|
||||
|
||||
from mayan.celery import app
|
||||
from documents.models import Document
|
||||
from lock_manager import Lock, LockError
|
||||
|
||||
from .literals import RETRY_DELAY
|
||||
from .models import IndexInstanceNode
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@app.task(bind=True, default_retry_delay=RETRY_DELAY, max_retries=None, ignore_result=True)
|
||||
def task_delete_empty_index_nodes(self):
|
||||
IndexInstanceNode = apps.get_model(
|
||||
app_label='document_indexing', model_name='IndexInstanceNode'
|
||||
)
|
||||
|
||||
try:
|
||||
rebuild_lock = Lock.acquire_lock(
|
||||
'document_indexing_task_do_rebuild_all_indexes'
|
||||
@@ -32,6 +35,14 @@ def task_delete_empty_index_nodes(self):
|
||||
|
||||
@app.task(bind=True, default_retry_delay=RETRY_DELAY, max_retries=None, ignore_result=True)
|
||||
def task_index_document(self, document_id):
|
||||
Document = apps.get_model(
|
||||
app_label='documents', model_name='Document'
|
||||
)
|
||||
|
||||
IndexInstanceNode = apps.get_model(
|
||||
app_label='document_indexing', model_name='IndexInstanceNode'
|
||||
)
|
||||
|
||||
try:
|
||||
rebuild_lock = Lock.acquire_lock(
|
||||
'document_indexing_task_do_rebuild_all_indexes'
|
||||
@@ -74,6 +85,10 @@ def task_index_document(self, document_id):
|
||||
|
||||
@app.task(bind=True, default_retry_delay=RETRY_DELAY, ignore_result=True)
|
||||
def task_do_rebuild_all_indexes(self):
|
||||
IndexInstanceNode = apps.get_model(
|
||||
app_label='document_indexing', model_name='IndexInstanceNode'
|
||||
)
|
||||
|
||||
if Lock.check_existing(name__startswith='document_indexing_task_update_index_document'):
|
||||
# A document index update is happening, wait
|
||||
raise self.retry()
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
from django.utils.html import mark_safe
|
||||
from django.utils.translation import ugettext
|
||||
|
||||
from .models import IndexInstanceNode
|
||||
|
||||
|
||||
def get_instance_link(index_instance_node, text=None, simple=False):
|
||||
"""
|
||||
@@ -64,6 +63,10 @@ def get_breadcrumbs(index_instance_node, simple=False, single_link=False, includ
|
||||
|
||||
|
||||
def index_instance_item_link(index_instance_item):
|
||||
IndexInstanceNode = apps.get_model(
|
||||
app_label='document_indexing', model_name='IndexInstanceNode'
|
||||
)
|
||||
|
||||
if isinstance(index_instance_item, IndexInstanceNode):
|
||||
if index_instance_item.index_template_node.link_documents:
|
||||
icon_template = '<i class="fa fa-folder"></i>'
|
||||
|
||||
@@ -2,11 +2,11 @@ from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from django.apps import apps
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from acls import ModelPermission
|
||||
from common import MayanAppConfig, menu_facet, menu_sidebar
|
||||
from documents.models import Document, DocumentVersion
|
||||
|
||||
from .hooks import document_pre_open_hook, document_version_post_save_hook
|
||||
from .links import (
|
||||
@@ -31,6 +31,14 @@ class DocumentSignaturesApp(MayanAppConfig):
|
||||
def ready(self):
|
||||
super(DocumentSignaturesApp, self).ready()
|
||||
|
||||
Document = apps.get_model(
|
||||
app_label='documents', model_name='Document'
|
||||
)
|
||||
|
||||
DocumentVersion = apps.get_model(
|
||||
app_label='documents', model_name='DocumentVersion'
|
||||
)
|
||||
|
||||
DocumentVersion.register_post_save_hook(
|
||||
1, document_version_post_save_hook
|
||||
)
|
||||
|
||||
@@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
||||
import io
|
||||
import logging
|
||||
|
||||
from django.apps import apps
|
||||
from django_gpg.exceptions import GPGDecryptionError
|
||||
from django_gpg.runtime import gpg
|
||||
|
||||
@@ -10,7 +11,11 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def document_pre_open_hook(descriptor, instance):
|
||||
from .models import DocumentVersionSignature
|
||||
logger.debug('instance: %s', instance)
|
||||
|
||||
DocumentVersionSignature = apps.get_model(
|
||||
app_label='document_signatures', model_name='DocumentVersionSignature'
|
||||
)
|
||||
|
||||
if DocumentVersionSignature.objects.has_embedded_signature(document_version=instance):
|
||||
# If it has an embedded signature, decrypt
|
||||
@@ -30,7 +35,10 @@ def document_pre_open_hook(descriptor, instance):
|
||||
|
||||
def document_version_post_save_hook(instance):
|
||||
logger.debug('instance: %s', instance)
|
||||
from .models import DocumentVersionSignature
|
||||
|
||||
DocumentVersionSignature = apps.get_model(
|
||||
app_label='document_signatures', model_name='DocumentVersionSignature'
|
||||
)
|
||||
|
||||
try:
|
||||
document_signature = DocumentVersionSignature.objects.get(
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from navigation import Link
|
||||
|
||||
from .models import DocumentVersionSignature
|
||||
from .permissions import (
|
||||
permission_document_verify, permission_signature_delete,
|
||||
permission_signature_download, permission_signature_upload,
|
||||
@@ -12,6 +12,10 @@ from .permissions import (
|
||||
|
||||
|
||||
def can_upload_detached_signature(context):
|
||||
DocumentVersionSignature = apps.get_model(
|
||||
app_label='document_signatures', model_name='DocumentVersionSignature'
|
||||
)
|
||||
|
||||
return not DocumentVersionSignature.objects.has_detached_signature(
|
||||
context['object'].latest_version
|
||||
) and not DocumentVersionSignature.objects.has_embedded_signature(
|
||||
@@ -20,6 +24,10 @@ def can_upload_detached_signature(context):
|
||||
|
||||
|
||||
def can_delete_detached_signature(context):
|
||||
DocumentVersionSignature = apps.get_model(
|
||||
app_label='document_signatures', model_name='DocumentVersionSignature'
|
||||
)
|
||||
|
||||
return DocumentVersionSignature.objects.has_detached_signature(
|
||||
context['object'].latest_version
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
from django.db.models.signals import post_save
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
@@ -8,7 +9,6 @@ from common import (
|
||||
menu_sidebar
|
||||
)
|
||||
from common.widgets import two_state_template
|
||||
from documents.models import Document
|
||||
from navigation import SourceColumn
|
||||
|
||||
from .handlers import launch_workflow
|
||||
@@ -33,6 +33,10 @@ class DocumentStatesApp(MayanAppConfig):
|
||||
def ready(self):
|
||||
super(DocumentStatesApp, self).ready()
|
||||
|
||||
Document = apps.get_model(
|
||||
app_label='documents', model_name='Document'
|
||||
)
|
||||
|
||||
Workflow = self.get_model('Workflow')
|
||||
WorkflowInstance = self.get_model('WorkflowInstance')
|
||||
WorkflowInstanceLogEntry = self.get_model('WorkflowInstanceLogEntry')
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db.models import get_model
|
||||
from django.apps import apps
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
def create_default_document_type(sender, **kwargs):
|
||||
DocumentType = get_model('documents', 'DocumentType')
|
||||
DocumentType = apps.get_model(
|
||||
app_label='documents', model_name='DocumentType'
|
||||
)
|
||||
|
||||
if not DocumentType.objects.count():
|
||||
DocumentType.objects.create(label=_('Default'))
|
||||
|
||||
@@ -2,34 +2,44 @@ from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from django.apps import apps
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import OperationalError
|
||||
|
||||
from mayan.celery import app
|
||||
|
||||
from common.models import SharedUploadedFile
|
||||
|
||||
from .literals import (
|
||||
UPDATE_PAGE_COUNT_RETRY_DELAY, UPLOAD_NEW_VERSION_RETRY_DELAY,
|
||||
NEW_DOCUMENT_RETRY_DELAY
|
||||
)
|
||||
from .models import Document, DocumentPage, DocumentType, DocumentVersion
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@app.task(ignore_result=True)
|
||||
def task_check_delete_periods():
|
||||
DocumentType = apps.get_model(
|
||||
app_label='documents', model_name='DocumentType'
|
||||
)
|
||||
|
||||
DocumentType.objects.check_delete_periods()
|
||||
|
||||
|
||||
@app.task(ignore_result=True)
|
||||
def task_check_trash_periods():
|
||||
DocumentType = apps.get_model(
|
||||
app_label='documents', model_name='DocumentType'
|
||||
)
|
||||
|
||||
DocumentType.objects.check_trash_periods()
|
||||
|
||||
|
||||
@app.task(ignore_result=True)
|
||||
def task_clear_image_cache():
|
||||
Document = apps.get_model(
|
||||
app_label='documents', model_name='Document'
|
||||
)
|
||||
|
||||
logger.info('Starting document cache invalidation')
|
||||
Document.objects.invalidate_cache()
|
||||
logger.info('Finished document cache invalidation')
|
||||
@@ -37,6 +47,10 @@ def task_clear_image_cache():
|
||||
|
||||
@app.task(ignore_result=True)
|
||||
def task_delete_stubs():
|
||||
Document = apps.get_model(
|
||||
app_label='documents', model_name='Document'
|
||||
)
|
||||
|
||||
logger.info('Executing')
|
||||
Document.objects.delete_stubs()
|
||||
logger.info('Finshed')
|
||||
@@ -44,12 +58,20 @@ def task_delete_stubs():
|
||||
|
||||
@app.task(compression='zlib')
|
||||
def task_get_document_page_image(document_page_id, *args, **kwargs):
|
||||
DocumentPage = apps.get_model(
|
||||
app_label='documents', model_name='DocumentPage'
|
||||
)
|
||||
|
||||
document_page = DocumentPage.objects.get(pk=document_page_id)
|
||||
return document_page.get_image(*args, **kwargs)
|
||||
|
||||
|
||||
@app.task(bind=True, default_retry_delay=UPDATE_PAGE_COUNT_RETRY_DELAY, ignore_result=True)
|
||||
def task_update_page_count(self, version_id):
|
||||
DocumentVersion = apps.get_model(
|
||||
app_label='documents', model_name='DocumentVersion'
|
||||
)
|
||||
|
||||
document_version = DocumentVersion.objects.get(pk=version_id)
|
||||
try:
|
||||
document_version.update_page_count()
|
||||
@@ -64,6 +86,14 @@ def task_update_page_count(self, version_id):
|
||||
|
||||
@app.task(bind=True, default_retry_delay=NEW_DOCUMENT_RETRY_DELAY, ignore_result=True)
|
||||
def task_upload_new_document(self, document_type_id, shared_uploaded_file_id, description=None, label=None, language=None, user_id=None):
|
||||
SharedUploadedFile = apps.get_model(
|
||||
app_label='common', model_name='SharedUploadedFile'
|
||||
)
|
||||
|
||||
DocumentType = apps.get_model(
|
||||
app_label='documents', model_name='DocumentType'
|
||||
)
|
||||
|
||||
try:
|
||||
document_type = DocumentType.objects.get(pk=document_type_id)
|
||||
shared_file = SharedUploadedFile.objects.get(
|
||||
@@ -106,6 +136,14 @@ def task_upload_new_document(self, document_type_id, shared_uploaded_file_id, de
|
||||
|
||||
@app.task(bind=True, default_retry_delay=UPLOAD_NEW_VERSION_RETRY_DELAY, ignore_result=True)
|
||||
def task_upload_new_version(self, document_id, shared_uploaded_file_id, user_id, comment=None):
|
||||
SharedUploadedFile = apps.get_model(
|
||||
app_label='common', model_name='SharedUploadedFile'
|
||||
)
|
||||
|
||||
Document = apps.get_model(
|
||||
app_label='documents', model_name='Document'
|
||||
)
|
||||
|
||||
try:
|
||||
document = Document.objects.get(pk=document_id)
|
||||
shared_file = SharedUploadedFile.objects.get(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from acls import ModelPermission
|
||||
@@ -9,7 +10,6 @@ from common import (
|
||||
MayanAppConfig, menu_facet, menu_main, menu_object, menu_secondary,
|
||||
menu_sidebar, menu_multi_item
|
||||
)
|
||||
from documents.models import Document
|
||||
from navigation import SourceColumn
|
||||
from rest_api.classes import APIEndPoint
|
||||
|
||||
@@ -35,6 +35,10 @@ class FoldersApp(MayanAppConfig):
|
||||
def ready(self):
|
||||
super(FoldersApp, self).ready()
|
||||
|
||||
Document = apps.get_model(
|
||||
app_label='documents', model_name='Document'
|
||||
)
|
||||
|
||||
DocumentFolder = self.get_model('DocumentFolder')
|
||||
Folder = self.get_model('Folder')
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from acls import ModelPermission
|
||||
@@ -10,7 +11,6 @@ from common import (
|
||||
menu_sidebar
|
||||
)
|
||||
from common.widgets import two_state_template
|
||||
from documents.models import Document
|
||||
from navigation import SourceColumn
|
||||
|
||||
from .links import (
|
||||
@@ -34,6 +34,10 @@ class LinkingApp(MayanAppConfig):
|
||||
def ready(self):
|
||||
super(LinkingApp, self).ready()
|
||||
|
||||
Document = apps.get_model(
|
||||
app_label='documents', model_name='Document'
|
||||
)
|
||||
|
||||
ResolvedSmartLink = self.get_model('ResolvedSmartLink')
|
||||
SmartLink = self.get_model('SmartLink')
|
||||
SmartLinkCondition = self.get_model('SmartLinkCondition')
|
||||
|
||||
@@ -2,11 +2,11 @@ from __future__ import unicode_literals
|
||||
|
||||
from kombu import Exchange, Queue
|
||||
|
||||
from django.apps import apps
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from acls import ModelPermission
|
||||
from common import MayanAppConfig, menu_object, menu_tools
|
||||
from documents.models import Document
|
||||
from mayan.celery import app
|
||||
from navigation import SourceColumn
|
||||
|
||||
@@ -26,6 +26,10 @@ class MailerApp(MayanAppConfig):
|
||||
def ready(self):
|
||||
super(MailerApp, self).ready()
|
||||
|
||||
Document = apps.get_model(
|
||||
app_label='documents', model_name='Document'
|
||||
)
|
||||
|
||||
LogEntry = self.get_model('LogEntry')
|
||||
|
||||
SourceColumn(
|
||||
|
||||
@@ -4,6 +4,7 @@ import logging
|
||||
|
||||
from kombu import Exchange, Queue
|
||||
|
||||
from django.apps import apps
|
||||
from django.db.models.signals import post_delete, post_save
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
@@ -14,7 +15,6 @@ from common import (
|
||||
)
|
||||
from common.classes import ModelAttribute, Filter
|
||||
from common.widgets import two_state_template
|
||||
from documents.models import Document, DocumentType
|
||||
from documents.search import document_search
|
||||
from documents.signals import post_document_type_change
|
||||
from documents.permissions import permission_document_view
|
||||
@@ -54,6 +54,14 @@ class MetadataApp(MayanAppConfig):
|
||||
def ready(self):
|
||||
super(MetadataApp, self).ready()
|
||||
|
||||
Document = apps.get_model(
|
||||
app_label='documents', model_name='Document'
|
||||
)
|
||||
|
||||
DocumentType = apps.get_model(
|
||||
app_label='documents', model_name='DocumentType'
|
||||
)
|
||||
|
||||
DocumentMetadata = self.get_model('DocumentMetadata')
|
||||
DocumentTypeMetadataType = self.get_model('DocumentTypeMetadataType')
|
||||
MetadataType = self.get_model('MetadataType')
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
from django.apps import apps
|
||||
|
||||
from django.db.models import get_model
|
||||
import logging
|
||||
|
||||
from .tasks import task_add_required_metadata_type, task_remove_metadata_type
|
||||
|
||||
@@ -38,7 +38,9 @@ def post_post_document_type_change_metadata(sender, instance, **kwargs):
|
||||
for metadata in instance.metadata.all():
|
||||
metadata.delete(enforce_required=False)
|
||||
|
||||
DocumentMetadata = get_model('metadata', 'DocumentMetadata')
|
||||
DocumentMetadata = apps.get_model(
|
||||
app_label='metadata', model_name='DocumentMetadata'
|
||||
)
|
||||
|
||||
# Add new document type metadata types to document
|
||||
for document_type_metadata_type in instance.document_type.metadata.filter(required=True):
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from django.apps import apps
|
||||
|
||||
from mayan.celery import app
|
||||
|
||||
from documents.models import DocumentType
|
||||
|
||||
from .models import DocumentMetadata, MetadataType
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@app.task(ignore_result=True)
|
||||
def task_remove_metadata_type(document_type_id, metadata_type_id):
|
||||
DocumentMetadata = apps.get_model(
|
||||
app_label='metadata', model_name='DocumentMetadata'
|
||||
)
|
||||
|
||||
DocumentMetadata.objects.filter(
|
||||
document__document_type__id=document_type_id,
|
||||
metadata_type__id=metadata_type_id
|
||||
@@ -19,6 +23,14 @@ def task_remove_metadata_type(document_type_id, metadata_type_id):
|
||||
|
||||
@app.task(ignore_result=True)
|
||||
def task_add_required_metadata_type(document_type_id, metadata_type_id):
|
||||
DocumentType = apps.get_model(
|
||||
app_label='documents', model_name='DocumentType'
|
||||
)
|
||||
|
||||
MetadataType = apps.get_model(
|
||||
app_label='metadata', model_name='MetadataType'
|
||||
)
|
||||
|
||||
metadata_type = MetadataType.objects.get(pk=metadata_type_id)
|
||||
|
||||
for document in DocumentType.objects.get(pk=document_type_id).documents.all():
|
||||
|
||||
@@ -5,6 +5,7 @@ import logging
|
||||
import urllib
|
||||
import urlparse
|
||||
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.core.urlresolvers import resolve, reverse
|
||||
@@ -13,7 +14,6 @@ from django.template.defaulttags import URLNode
|
||||
from django.utils.encoding import smart_str, smart_unicode
|
||||
from django.utils.http import urlencode, urlquote
|
||||
|
||||
from acls.models import AccessControlList
|
||||
from common.utils import return_attrib
|
||||
from permissions import Permission
|
||||
|
||||
@@ -218,6 +218,10 @@ class Link(object):
|
||||
self.view = view
|
||||
|
||||
def resolve(self, context, resolved_object=None):
|
||||
AccessControlList = apps.get_model(
|
||||
app_label='acls', model_name='AccessControlList'
|
||||
)
|
||||
|
||||
request = Variable('request').resolve(context)
|
||||
current_path = request.META['PATH_INFO']
|
||||
current_view = resolve(current_path).view_name
|
||||
|
||||
@@ -5,6 +5,7 @@ import logging
|
||||
from kombu import Exchange, Queue
|
||||
import sh
|
||||
|
||||
from django.apps import apps
|
||||
from django.db.models.signals import post_save
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
@@ -14,7 +15,6 @@ from common import (
|
||||
menu_tools
|
||||
)
|
||||
from common.settings import settings_db_sync_task_delay
|
||||
from documents.models import Document, DocumentType, DocumentVersion
|
||||
from documents.search import document_search
|
||||
from documents.signals import post_version_upload
|
||||
from documents.widgets import document_link
|
||||
@@ -60,6 +60,18 @@ class OCRApp(MayanAppConfig):
|
||||
def ready(self):
|
||||
super(OCRApp, self).ready()
|
||||
|
||||
Document = apps.get_model(
|
||||
app_label='documents', model_name='Document'
|
||||
)
|
||||
|
||||
DocumentType = apps.get_model(
|
||||
app_label='documents', model_name='DocumentType'
|
||||
)
|
||||
|
||||
DocumentVersion = apps.get_model(
|
||||
app_label='documents', model_name='DocumentVersion'
|
||||
)
|
||||
|
||||
DocumentVersionOCRError = self.get_model('DocumentVersionOCRError')
|
||||
|
||||
APIEndPoint(app=self, version_string='1')
|
||||
|
||||
@@ -2,11 +2,11 @@ from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from django.apps import apps
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from .exceptions import InvalidNamespace
|
||||
from .models import StoredPermission
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -64,6 +64,10 @@ class Permission(object):
|
||||
|
||||
@classmethod
|
||||
def get_for_holder(cls, holder):
|
||||
StoredPermission = apps.get_model(
|
||||
app_label='permissions', model_name='StoredPermission'
|
||||
)
|
||||
|
||||
return StoredPermission.get_for_holder(holder)
|
||||
|
||||
@classmethod
|
||||
@@ -100,6 +104,10 @@ class Permission(object):
|
||||
|
||||
@property
|
||||
def stored_permission(self):
|
||||
StoredPermission = apps.get_model(
|
||||
app_label='permissions', model_name='StoredPermission'
|
||||
)
|
||||
|
||||
try:
|
||||
return self.__class__._stored_permissions_cache[self.uuid]
|
||||
except KeyError:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from kombu import Exchange, Queue
|
||||
@@ -10,7 +11,6 @@ from common import (
|
||||
)
|
||||
from common.signals import post_initial_setup, post_upgrade
|
||||
from converter.links import link_transformation_list
|
||||
from documents.models import Document
|
||||
from documents.signals import post_version_upload
|
||||
from mayan.celery import app
|
||||
from navigation import SourceColumn
|
||||
@@ -41,6 +41,10 @@ class SourcesApp(MayanAppConfig):
|
||||
def ready(self):
|
||||
super(SourcesApp, self).ready()
|
||||
|
||||
Document = apps.get_model(
|
||||
app_label='documents', model_name='Document'
|
||||
)
|
||||
|
||||
POP3Email = self.get_model('POP3Email')
|
||||
IMAPEmail = self.get_model('IMAPEmail')
|
||||
Source = self.get_model('Source')
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import logging
|
||||
|
||||
from django.apps import apps
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.files import File
|
||||
from django.db import OperationalError
|
||||
@@ -8,17 +9,18 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from mayan.celery import app
|
||||
|
||||
from common.compressed_files import CompressedFile, NotACompressedFile
|
||||
from common.models import SharedUploadedFile
|
||||
from documents.models import DocumentType
|
||||
|
||||
from .literals import DEFAULT_SOURCE_TASK_RETRY_DELAY
|
||||
from .models import Source
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@app.task(ignore_result=True)
|
||||
def task_check_interval_source(source_id):
|
||||
Source = apps.get_model(
|
||||
app_label='sources', model_name='Source'
|
||||
)
|
||||
|
||||
source = Source.objects.get_subclass(pk=source_id)
|
||||
if source.enabled:
|
||||
try:
|
||||
@@ -34,6 +36,18 @@ def task_check_interval_source(source_id):
|
||||
|
||||
@app.task(bind=True, default_retry_delay=DEFAULT_SOURCE_TASK_RETRY_DELAY, ignore_result=True)
|
||||
def task_upload_document(self, source_id, document_type_id, shared_uploaded_file_id, description=None, label=None, language=None, metadata_dict_list=None, user_id=None):
|
||||
SharedUploadedFile = apps.get_model(
|
||||
app_label='common', model_name='SharedUploadedFile'
|
||||
)
|
||||
|
||||
DocumentType = apps.get_model(
|
||||
app_label='documents', model_name='DocumentType'
|
||||
)
|
||||
|
||||
Source = apps.get_model(
|
||||
app_label='sources', model_name='Source'
|
||||
)
|
||||
|
||||
try:
|
||||
document_type = DocumentType.objects.get(pk=document_type_id)
|
||||
source = Source.objects.get_subclass(pk=source_id)
|
||||
@@ -72,6 +86,14 @@ def task_upload_document(self, source_id, document_type_id, shared_uploaded_file
|
||||
|
||||
@app.task(bind=True, default_retry_delay=DEFAULT_SOURCE_TASK_RETRY_DELAY, ignore_result=True)
|
||||
def task_source_handle_upload(self, document_type_id, shared_uploaded_file_id, source_id, description=None, expand=False, label=None, language=None, metadata_dict_list=None, skip_list=None, user_id=None):
|
||||
SharedUploadedFile = apps.get_model(
|
||||
app_label='common', model_name='SharedUploadedFile'
|
||||
)
|
||||
|
||||
DocumentType = apps.get_model(
|
||||
app_label='documents', model_name='DocumentType'
|
||||
)
|
||||
|
||||
try:
|
||||
document_type = DocumentType.objects.get(pk=document_type_id)
|
||||
shared_upload = SharedUploadedFile.objects.get(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from acls import ModelPermission
|
||||
@@ -9,7 +10,6 @@ from common import (
|
||||
MayanAppConfig, menu_facet, menu_secondary, menu_object, menu_main,
|
||||
menu_multi_item, menu_sidebar
|
||||
)
|
||||
from documents.models import Document
|
||||
from documents.search import document_search
|
||||
from navigation import SourceColumn
|
||||
from rest_api.classes import APIEndPoint
|
||||
@@ -35,6 +35,10 @@ class TagsApp(MayanAppConfig):
|
||||
def ready(self):
|
||||
super(TagsApp, self).ready()
|
||||
|
||||
Document = apps.get_model(
|
||||
app_label='documents', model_name='Document'
|
||||
)
|
||||
|
||||
DocumentTag = self.get_model('DocumentTag')
|
||||
Tag = self.get_model('Tag')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user