Skip to content

Commit

Permalink
Sort imports
Browse files Browse the repository at this point in the history
  • Loading branch information
moshthepitt committed Apr 17, 2018
1 parent cbfb789 commit ec6a7f6
Show file tree
Hide file tree
Showing 35 changed files with 246 additions and 192 deletions.
4 changes: 3 additions & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
default_section = THIRDPARTY
known_first_party = onadata
known_django = django
sections = FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
known_future2 = future
known_past = past
sections = FUTURE,STDLIB,FUTURE2,PAST,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
12 changes: 8 additions & 4 deletions onadata/apps/api/tasks.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import os
import sys
from celery import task
from celery.result import AsyncResult
from io import BytesIO

from past.builtins import basestring

from django.core.files.uploadedfile import (InMemoryUploadedFile,
TemporaryUploadedFile)
from django.utils.datastructures import MultiValueDict
from io import BytesIO

from celery import task
from celery.result import AsyncResult

from onadata.apps.api import tools
from onadata.apps.logger.models.xform import XForm
from past.builtins import basestring


def recreate_tmp_file(name, path, mime_type):
Expand Down
4 changes: 3 additions & 1 deletion onadata/apps/api/tests/viewsets/test_attachment_viewset.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import os

from past.builtins import basestring

from django.utils import timezone

from onadata.apps.api.tests.viewsets.test_abstract_viewset import \
TestAbstractViewSet
from onadata.apps.api.viewsets.attachment_viewset import AttachmentViewSet
from onadata.apps.logger.import_tools import django_file
from onadata.apps.logger.models.attachment import Attachment
from onadata.apps.logger.models.instance import get_attachment_url
from onadata.apps.logger.import_tools import django_file


def attachment_url(attachment, suffix=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from onadata.libs.utils.export_tools import get_osm_data_kwargs
from onadata.libs.utils.user_auth import get_user_default_project


MD = """
| survey |
| | type | name | label |
Expand Down
17 changes: 8 additions & 9 deletions onadata/apps/api/tests/viewsets/test_osm_viewset.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import csv
import os
from io import StringIO
from mock import patch

from django.db import IntegrityError, transaction
from django.db.transaction import TransactionManagementError
from django.test import RequestFactory
from django.test.utils import override_settings
from django.utils.dateparse import parse_datetime
from django.db import IntegrityError, transaction
from django.db.transaction import TransactionManagementError

from mock import patch

from onadata.apps.api.tests.viewsets.test_abstract_viewset import \
TestAbstractViewSet
from onadata.apps.api.viewsets.data_viewset import DataViewSet
from onadata.apps.api.viewsets.osm_viewset import OsmViewSet
from onadata.apps.api.viewsets.xform_viewset import XFormViewSet
from onadata.apps.api.viewsets.data_viewset import DataViewSet
from onadata.apps.logger.models import Attachment
from onadata.apps.logger.models import Instance
from onadata.apps.logger.models import OsmData
from onadata.apps.logger.models import Attachment, Instance, OsmData
from onadata.apps.viewer.models import Export
from onadata.libs.utils.common_tools import (
filename_from_disposition, get_response_content)
from onadata.libs.utils.common_tools import (filename_from_disposition,
get_response_content)
from onadata.libs.utils.osm import save_osm_data


Expand Down
14 changes: 10 additions & 4 deletions onadata/apps/api/tests/viewsets/test_xform_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import os
import re
from collections import OrderedDict
from datetime import datetime
from datetime import timedelta
from io import StringIO
from datetime import datetime, timedelta
from xml.dom import Node, minidom
from xml.dom import Node
from xml.dom import minidom

from django.conf import settings
from django.contrib.contenttypes.models import ContentType
Expand All @@ -25,7 +27,8 @@
import jwt
from django_digest.test import DigestAuth
from httmock import HTTMock
from mock import Mock, patch
from mock import Mock
from mock import patch
from rest_framework import status
from rest_framework.viewsets import ModelViewSet

Expand All @@ -40,7 +43,10 @@
TestAbstractViewSet
from onadata.apps.api.viewsets.project_viewset import ProjectViewSet
from onadata.apps.api.viewsets.xform_viewset import XFormViewSet
from onadata.apps.logger.models import Attachment, Instance, Project, XForm
from onadata.apps.logger.models import Attachment
from onadata.apps.logger.models import Instance
from onadata.apps.logger.models import Project
from onadata.apps.logger.models import XForm
from onadata.apps.logger.xform_instance_parser import XLSFormError
from onadata.apps.main.models import MetaData
from onadata.apps.viewer.models import Export
Expand Down
32 changes: 16 additions & 16 deletions onadata/apps/api/viewsets/dataview_viewset.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from django.http import HttpResponseBadRequest, Http404
from django.db.models.signals import post_save, post_delete
from past.builtins import basestring
from celery.result import AsyncResult

from django.db.models.signals import post_delete, post_save
from django.http import Http404, HttpResponseBadRequest

from celery.result import AsyncResult
from rest_framework import status
from rest_framework.decorators import detail_route
from rest_framework.exceptions import ParseError
Expand All @@ -12,29 +13,28 @@
from rest_framework.viewsets import ModelViewSet

from onadata.apps.api.permissions import DataViewViewsetPermissions
from onadata.apps.api.tools import get_baseviewset_class
from onadata.apps.logger.models.data_view import DataView
from onadata.apps.viewer.models.export import Export
from onadata.libs.renderers import renderers
from onadata.libs.mixins.authenticate_header_mixin import \
AuthenticateHeaderMixin
from onadata.libs.mixins.cache_control_mixin import CacheControlMixin
from onadata.libs.mixins.etags_mixin import ETagsMixin
from onadata.libs.renderers import renderers
from onadata.libs.serializers.data_serializer import JsonDataSerializer
from onadata.libs.serializers.dataview_serializer import DataViewSerializer
from onadata.libs.serializers.xform_serializer import XFormSerializer
from onadata.libs.serializers.data_serializer import JsonDataSerializer
from onadata.libs.utils import common_tags
from onadata.libs.utils.api_export_tools import custom_response_handler
from onadata.libs.utils.api_export_tools import export_async_export_response
from onadata.libs.utils.api_export_tools import process_async_export
from onadata.libs.utils.api_export_tools import response_for_format
from onadata.libs.utils.api_export_tools import include_hxl_row
from onadata.libs.utils.chart_tools import get_chart_data_for_field, \
get_field_from_field_name
from onadata.libs.utils.api_export_tools import (custom_response_handler,
export_async_export_response,
include_hxl_row,
process_async_export,
response_for_format)
from onadata.libs.utils.cache_tools import (PROJECT_LINKED_DATAVIEWS,
safe_delete)
from onadata.libs.utils.chart_tools import (get_chart_data_for_field,
get_field_from_field_name)
from onadata.libs.utils.export_tools import str_to_bool
from onadata.apps.api.tools import get_baseviewset_class
from onadata.libs.utils.cache_tools import (
PROJECT_LINKED_DATAVIEWS,
safe_delete)
from onadata.libs.utils.model_tools import get_columns_with_hxl

BaseViewset = get_baseviewset_class()
Expand Down
16 changes: 8 additions & 8 deletions onadata/apps/api/viewsets/user_profile_viewset.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import json

from past.builtins import basestring

from django.conf import settings

from rest_framework import serializers
from rest_framework import status
from rest_framework import serializers, status
from rest_framework.decorators import detail_route
from rest_framework.exceptions import ParseError
from rest_framework.filters import OrderingFilter
from rest_framework.generics import get_object_or_404
from rest_framework.viewsets import ModelViewSet
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet

from onadata.apps.api.permissions import UserProfilePermissions
from onadata.apps.api.tools import get_baseviewset_class, load_class
from onadata.apps.main.models import UserProfile
from onadata.libs import filters
from onadata.libs.mixins.authenticate_header_mixin import \
AuthenticateHeaderMixin
from onadata.libs.mixins.cache_control_mixin import CacheControlMixin
from onadata.libs.mixins.etags_mixin import ETagsMixin
from onadata.libs.mixins.object_lookup_mixin import ObjectLookupMixin
from onadata.libs.serializers.user_profile_serializer import\
from onadata.libs.serializers.user_profile_serializer import \
UserProfileSerializer
from onadata.apps.main.models import UserProfile
from onadata.apps.api.permissions import UserProfilePermissions
from onadata.apps.api.tools import load_class, get_baseviewset_class


BaseViewset = get_baseviewset_class()

Expand Down
9 changes: 6 additions & 3 deletions onadata/apps/logger/management/commands/import_instances.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=5 coding=utf-8
import os

from past.builtins import basestring

from django.contrib.auth.models import User
from django.core.management.base import BaseCommand, CommandError
from django.utils.translation import ugettext as _, ugettext_lazy
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy

from onadata.apps.logger.import_tools import import_instances_from_zip,\
import_instances_from_path
from onadata.apps.logger.import_tools import (import_instances_from_path,
import_instances_from_zip)


class Command(BaseCommand):
Expand Down
47 changes: 25 additions & 22 deletions onadata/apps/logger/models/instance.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
import math
from past.builtins import basestring
from celery import task
from datetime import datetime

from django.contrib.gis.db import models
from django.db import connection
from django.db import transaction
from django.db.models.signals import post_save
from django.db.models.signals import post_delete
from past.builtins import basestring

from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.gis.db import models
from django.contrib.gis.geos import GeometryCollection, Point
from django.contrib.postgres.fields import JSONField
from django.core.urlresolvers import reverse
from django.db import connection, transaction
from django.db.models.signals import post_delete, post_save
from django.utils import timezone
from django.utils.translation import ugettext as _

from celery import task
from taggit.managers import TaggableManager

from onadata.apps.logger.models.survey_type import SurveyType
from onadata.apps.logger.models.xform import XForm
from onadata.apps.logger.models.xform import XFORM_TITLE_LENGTH
from onadata.apps.logger.xform_instance_parser import XFormInstanceParser,\
clean_and_parse_xml, get_uuid_from_xml
from onadata.libs.utils.common_tags import ATTACHMENTS, BAMBOO_DATASET_ID,\
DELETEDAT, EDITED, GEOLOCATION, ID, MONGO_STRFTIME, NOTES, \
SUBMISSION_TIME, TAGS, UUID, XFORM_ID_STRING, SUBMITTED_BY, VERSION, \
STATUS, DURATION, START, END, LAST_EDITED, MEDIA_ALL_RECEIVED, \
TOTAL_MEDIA, MEDIA_COUNT, XFORM_ID
from onadata.libs.utils.model_tools import set_uuid
from onadata.apps.logger.models.xform import XFORM_TITLE_LENGTH, XForm
from onadata.apps.logger.xform_instance_parser import (XFormInstanceParser,
clean_and_parse_xml,
get_uuid_from_xml)
from onadata.libs.data.query import get_numeric_fields
from onadata.libs.utils.cache_tools import safe_delete
from onadata.libs.utils.cache_tools import IS_ORG
from onadata.libs.utils.cache_tools import PROJ_SUB_DATE_CACHE
from onadata.libs.utils.cache_tools import PROJ_NUM_DATASET_CACHE,\
XFORM_DATA_VERSIONS, DATAVIEW_COUNT, XFORM_COUNT
from onadata.libs.utils.cache_tools import (DATAVIEW_COUNT, IS_ORG,
PROJ_NUM_DATASET_CACHE,
PROJ_SUB_DATE_CACHE, XFORM_COUNT,
XFORM_DATA_VERSIONS, safe_delete)
from onadata.libs.utils.common_tags import (ATTACHMENTS, BAMBOO_DATASET_ID,
DELETEDAT, DURATION, EDITED, END,
GEOLOCATION, ID, LAST_EDITED,
MEDIA_ALL_RECEIVED, MEDIA_COUNT,
MONGO_STRFTIME, NOTES, START,
STATUS, SUBMISSION_TIME,
SUBMITTED_BY, TAGS, TOTAL_MEDIA,
UUID, VERSION, XFORM_ID,
XFORM_ID_STRING)
from onadata.libs.utils.dict_tools import get_values_matching_key
from onadata.libs.utils.model_tools import set_uuid
from onadata.libs.utils.timing import calculate_duration

ASYNC_POST_SUBMISSION_PROCESSING_ENABLED = \
Expand Down
15 changes: 10 additions & 5 deletions onadata/apps/logger/models/widget.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
from past.builtins import basestring

from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.contrib.gis.db import models
from django.contrib.postgres.fields import JSONField

from ordered_model.models import OrderedModel
from querybuilder.fields import AvgField, CountField, SimpleField, SumField
from querybuilder.query import Query
from past.builtins import basestring

from onadata.apps.logger.models.data_view import DataView
from onadata.apps.logger.models.instance import Instance
from onadata.apps.logger.models.xform import XForm
from onadata.libs.utils.chart_tools import (
DATA_TYPE_MAP, _flatten_multiple_dict_into_one,
_use_labels_from_group_by_name, get_field_choices,
get_field_from_field_xpath, get_field_label)
from onadata.libs.utils.chart_tools import (DATA_TYPE_MAP,
_flatten_multiple_dict_into_one,
_use_labels_from_group_by_name,
get_field_choices,
get_field_from_field_xpath,
get_field_label)
from onadata.libs.utils.common_tags import (NUMERIC_LIST, SELECT_ONE,
SUBMISSION_TIME)
from onadata.libs.utils.model_tools import generate_uuid_for_form
Expand Down
15 changes: 8 additions & 7 deletions onadata/apps/logger/tests/test_briefcase_client.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import shutil
import os.path
import requests

import shutil
from io import StringIO

from future.moves.urllib.parse import urljoin
from httmock import urlmatch, HTTMock

from django.contrib.auth import authenticate
from django.core.files.storage import get_storage_class
from django.core.files.uploadedfile import UploadedFile
from django.core.urlresolvers import reverse
from django.test import RequestFactory

import requests
from django_digest.test import Client as DigestClient
from httmock import HTTMock, urlmatch

from onadata.apps.logger.models import Instance, XForm
from onadata.apps.logger.views import download_xform, formList, xformsManifest
from onadata.apps.main.models import MetaData
from onadata.apps.main.tests.test_base import TestBase
from onadata.apps.main.views import profile, download_media_data
from onadata.apps.logger.models import Instance, XForm
from onadata.apps.logger.views import formList, download_xform, xformsManifest
from onadata.apps.main.views import download_media_data, profile
from onadata.libs.utils.briefcase_client import BriefcaseClient

storage = get_storage_class()()
Expand Down
Loading

0 comments on commit ec6a7f6

Please sign in to comment.