Silence 90% of remaining Django 1.8 model warnings.
This commit is contained in:
@@ -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>'
|
||||
|
||||
Reference in New Issue
Block a user