Update some direct model importing to use Django's apps.get_model instead.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.apps import apps
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from navigation import Link
|
||||
@@ -10,6 +10,8 @@ from .permissions import permission_acl_view, permission_acl_edit
|
||||
|
||||
def get_kwargs_factory(variable_name):
|
||||
def get_kwargs(context):
|
||||
ContentType = apps.get_model(app_label='django', model_name='ContentType')
|
||||
|
||||
content_type = ContentType.objects.get_for_model(
|
||||
context[variable_name]
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.apps import apps
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from navigation import Link
|
||||
@@ -13,6 +13,8 @@ from .permissions import (
|
||||
|
||||
def get_kwargs_factory(variable_name):
|
||||
def get_kwargs(context):
|
||||
ContentType = apps.get_model(app_label='django', model_name='ContentType')
|
||||
|
||||
content_type = ContentType.objects.get_for_model(
|
||||
context[variable_name]
|
||||
)
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db.models import get_model
|
||||
from django.apps import apps
|
||||
|
||||
|
||||
def launch_workflow(sender, instance, created, **kwargs):
|
||||
Workflow = get_model('document_states', 'Workflow')
|
||||
Workflow = apps.get_model(
|
||||
app_label='document_states', model_name='Workflow'
|
||||
)
|
||||
|
||||
if created:
|
||||
Workflow.objects.launch_for(instance)
|
||||
|
||||
@@ -6,8 +6,6 @@ from kombu import Exchange, Queue
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from actstream import registry
|
||||
|
||||
from acls import ModelPermission
|
||||
from acls.links import link_acl_list
|
||||
from acls.permissions import permission_acl_edit, permission_acl_view
|
||||
@@ -85,6 +83,7 @@ class DocumentsApp(MayanAppConfig):
|
||||
|
||||
def ready(self):
|
||||
super(DocumentsApp, self).ready()
|
||||
from actstream import registry
|
||||
|
||||
APIEndPoint(app=self, version_string='1')
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ from django.db.models import Q
|
||||
from django.utils.module_loading import import_string
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from acls.models import AccessControlList
|
||||
from permissions import Permission
|
||||
|
||||
from .settings import setting_limit
|
||||
@@ -125,6 +124,10 @@ class SearchModel(object):
|
||||
]
|
||||
|
||||
def search(self, query_string, user, global_and_search=False):
|
||||
AccessControlList = apps.get_model(
|
||||
app_label='acls', model_name='AccessControlList'
|
||||
)
|
||||
|
||||
elapsed_time = 0
|
||||
start_time = datetime.datetime.now()
|
||||
result_set = set()
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from actstream.models import Action
|
||||
|
||||
from common import MayanAppConfig, menu_tools
|
||||
from common.classes import Package
|
||||
|
||||
@@ -20,6 +19,7 @@ class EventsApp(MayanAppConfig):
|
||||
|
||||
def ready(self):
|
||||
super(EventsApp, self).ready()
|
||||
Action = apps.get_model(app_label='actstream', model_name='Action')
|
||||
|
||||
Package(label='django-activity-stream', license_text='''
|
||||
Copyright (c) 2010-2015, Justin Quick
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.apps import apps
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from navigation import Link
|
||||
@@ -10,6 +10,10 @@ from .permissions import permission_events_view
|
||||
|
||||
def get_kwargs_factory(variable_name):
|
||||
def get_kwargs(context):
|
||||
ContentType = apps.get_model(
|
||||
app_label='django', model_name='ContentType'
|
||||
)
|
||||
|
||||
content_type = ContentType.objects.get_for_model(
|
||||
context[variable_name]
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@ from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from django.db.models import get_model
|
||||
from django.apps import apps
|
||||
|
||||
from .settings import setting_auto_ocr
|
||||
|
||||
@@ -17,7 +17,9 @@ def post_version_upload_ocr(sender, instance, **kwargs):
|
||||
|
||||
|
||||
def initialize_new_ocr_settings(sender, instance, **kwargs):
|
||||
DocumentTypeSettings = get_model('ocr', 'DocumentTypeSettings')
|
||||
DocumentTypeSettings = apps.get_model(
|
||||
app_label='ocr', model_name='DocumentTypeSettings'
|
||||
)
|
||||
|
||||
if kwargs['created']:
|
||||
DocumentTypeSettings.objects.create(
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
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 _
|
||||
|
||||
from .literals import SOURCE_UNCOMPRESS_CHOICE_ASK
|
||||
|
||||
|
||||
def create_default_document_source(sender, **kwargs):
|
||||
WebFormSource = get_model('sources', 'WebFormSource')
|
||||
WebFormSource = apps.get_model(
|
||||
app_label='sources', model_name='WebFormSource'
|
||||
)
|
||||
|
||||
if not WebFormSource.objects.count():
|
||||
WebFormSource.objects.create(
|
||||
@@ -16,7 +18,9 @@ def create_default_document_source(sender, **kwargs):
|
||||
|
||||
|
||||
def copy_transformations_to_version(sender, **kwargs):
|
||||
Transformation = get_model('converter', 'Transformation')
|
||||
Transformation = apps.get_model(
|
||||
app_label='converter', model_name='Transformation'
|
||||
)
|
||||
|
||||
instance = kwargs['instance']
|
||||
|
||||
@@ -28,9 +32,11 @@ def copy_transformations_to_version(sender, **kwargs):
|
||||
|
||||
|
||||
def initialize_periodic_tasks(sender, **kwargs):
|
||||
POP3Email = get_model('sources', 'POP3Email')
|
||||
IMAPEmail = get_model('sources', 'IMAPEmail')
|
||||
WatchFolderSource = get_model('sources', 'WatchFolderSource')
|
||||
POP3Email = apps.get_model(app_label='sources', model_name='POP3Email')
|
||||
IMAPEmail = apps.get_model(app_label='sources', model_name='IMAPEmail')
|
||||
WatchFolderSource = apps.get_model(
|
||||
app_label='sources', model_name='WatchFolderSource'
|
||||
)
|
||||
|
||||
for source in POP3Email.objects.filter(enabled=True):
|
||||
source.save()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from documents.models import NewVersionBlock
|
||||
from documents.permissions import (
|
||||
permission_document_create, permission_document_new_version
|
||||
)
|
||||
@@ -19,6 +19,10 @@ from .permissions import (
|
||||
|
||||
|
||||
def document_new_version_not_blocked(context):
|
||||
NewVersionBlock = apps.get_model(
|
||||
app_label='documents', model_name='NewVersionBlock'
|
||||
)
|
||||
|
||||
return not NewVersionBlock.objects.is_blocked(context['object'])
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@ from __future__ import unicode_literals
|
||||
|
||||
import json
|
||||
|
||||
from django.apps import apps
|
||||
|
||||
from celery.schedules import crontab
|
||||
from djcelery.models import PeriodicTask
|
||||
|
||||
from mayan.celery import app
|
||||
|
||||
@@ -43,7 +44,12 @@ class Statistic(object):
|
||||
|
||||
@staticmethod
|
||||
def purge_schedules():
|
||||
from .models import StatisticResult
|
||||
PeriodicTask = apps.get_model(
|
||||
app_label='djcelery', model_name='PeriodicTask'
|
||||
)
|
||||
StatisticResult = apps.get_model(
|
||||
app_label='statistics', model_name='StatisticResult'
|
||||
)
|
||||
|
||||
queryset = PeriodicTask.objects.filter(name__startswith='statistics.').exclude(name__in=Statistic.get_task_names())
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.utils.html import escape
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from acls.models import AccessControlList
|
||||
from permissions import Permission
|
||||
|
||||
from .permissions import permission_tag_view
|
||||
@@ -14,6 +14,10 @@ def widget_document_tags(document, user):
|
||||
"""
|
||||
A tag widget that displays the tags for the given document
|
||||
"""
|
||||
AccessControlList = apps.get_model(
|
||||
app_label='acls', model_name='AccessControlList'
|
||||
)
|
||||
|
||||
tags_template = []
|
||||
|
||||
tags = document.attached_tags().all()
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.models import Group
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from actstream import registry
|
||||
|
||||
from common import menu_multi_item, menu_object, menu_secondary, menu_setup
|
||||
from common.apps import MayanAppConfig
|
||||
from common.widgets import two_state_template
|
||||
@@ -23,6 +21,7 @@ from .links import (
|
||||
|
||||
|
||||
def get_groups():
|
||||
Group = apps.get_model(app_label='auth', model_name='Group')
|
||||
return ','.join([group.name for group in Group.objects.all()])
|
||||
|
||||
|
||||
@@ -38,7 +37,9 @@ class UserManagementApp(MayanAppConfig):
|
||||
|
||||
def ready(self):
|
||||
super(UserManagementApp, self).ready()
|
||||
from actstream import registry
|
||||
|
||||
Group = apps.get_model(app_label='auth', model_name='Group')
|
||||
User = get_user_model()
|
||||
|
||||
APIEndPoint(app=self, version_string='1')
|
||||
|
||||
Reference in New Issue
Block a user