Move the OrganizationSourceManager manager to it's own module. Cleanups.
This commit is contained in:
@@ -80,9 +80,6 @@ class WebFormUploadFormHTML5(WebFormUploadForm):
|
||||
|
||||
|
||||
class WebFormSetupForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(WebFormSetupForm, self).__init__(*args, **kwargs)
|
||||
|
||||
class Meta:
|
||||
fields = ('label', 'enabled', 'uncompress')
|
||||
model = WebFormSource
|
||||
|
||||
14
mayan/apps/sources/managers.py
Normal file
14
mayan/apps/sources/managers.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from model_utils.managers import InheritanceManager, InheritanceQuerySet
|
||||
|
||||
from organizations.managers import CurrentOrganizationManager
|
||||
|
||||
|
||||
class OrganizationSourceManager(InheritanceManager, CurrentOrganizationManager):
|
||||
def get_queryset(self):
|
||||
return InheritanceQuerySet(self.model).filter(
|
||||
**{self._get_field_name() + '__id': settings.ORGANIZATION_ID}
|
||||
)
|
||||
@@ -11,7 +11,6 @@ import poplib
|
||||
|
||||
import yaml
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.files import File
|
||||
from django.core.files.base import ContentFile
|
||||
@@ -19,7 +18,7 @@ from django.db import models, transaction
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from model_utils.managers import InheritanceManager, InheritanceQuerySet
|
||||
from model_utils.managers import InheritanceManager
|
||||
|
||||
from common.compressed_files import CompressedFile, NotACompressedFile
|
||||
from converter.literals import DIMENSION_SEPARATOR
|
||||
@@ -30,8 +29,8 @@ from documents.settings import setting_language
|
||||
from metadata.api import save_metadata_list, set_bulk_metadata
|
||||
from metadata.models import MetadataType
|
||||
from organizations.models import Organization
|
||||
from organizations.managers import CurrentOrganizationManager
|
||||
from organizations.shortcuts import get_current_organization
|
||||
from tags.models import Tag
|
||||
|
||||
from .classes import Attachment, SourceUploadedFile, StagingFile
|
||||
from .literals import (
|
||||
@@ -42,18 +41,11 @@ from .literals import (
|
||||
SOURCE_UNCOMPRESS_CHOICE_N, SOURCE_UNCOMPRESS_CHOICE_Y,
|
||||
SOURCE_CHOICE_EMAIL_IMAP, SOURCE_CHOICE_EMAIL_POP3
|
||||
)
|
||||
from .managers import OrganizationSourceManager
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class OrganizationSourceManager(InheritanceManager, CurrentOrganizationManager):
|
||||
def get_queryset(self):
|
||||
return InheritanceQuerySet(self.model).filter(
|
||||
**{self._get_field_name() + '__id': settings.ORGANIZATION_ID}
|
||||
)
|
||||
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Source(models.Model):
|
||||
organization = models.ForeignKey(
|
||||
|
||||
@@ -3,7 +3,6 @@ from __future__ import unicode_literals
|
||||
from organizations.tests.test_organization_views import OrganizationViewTestCase
|
||||
|
||||
from ..models import WebFormSource
|
||||
from ..utils import get_class, get_form_class, get_upload_form_class
|
||||
|
||||
from .literals import (
|
||||
TEST_SOURCE_LABEL, TEST_SOURCE_EDITED_LABEL, TEST_SOURCE_UNCOMPRESS_N
|
||||
|
||||
Reference in New Issue
Block a user