From d9fad97e35de1a4a905aa6f0e09c4a371067036e Mon Sep 17 00:00:00 2001 From: virusdefender Date: Mon, 23 Jan 2017 16:48:04 +0800 Subject: [PATCH] isort --- account/decorators.py | 2 +- account/middleware.py | 4 +++- account/migrations/0001_initial.py | 7 ++++--- account/serializers.py | 4 ++-- account/tests.py | 8 ++++---- account/urls/oj.py | 2 +- account/views/admin.py | 4 +--- account/views/oj.py | 6 +++--- announcement/migrations/0001_initial.py | 3 ++- announcement/serializers.py | 4 ++-- announcement/views.py | 4 ++-- conf/serializers.py | 4 ++-- conf/tests.py | 3 ++- conf/urls/admin.py | 2 +- conf/urls/oj.py | 3 +-- conf/views.py | 9 +++++---- contest/models.py | 2 +- manage.py | 1 - oj/local_settings.py | 1 - oj/server_settings.py | 2 -- oj/settings.py | 4 ++-- problem/models.py | 4 +--- utils/api/_serializers.py | 1 - utils/api/api.py | 3 +-- utils/api/tests.py | 5 ++--- utils/management/commands/initadmin.py | 5 +++-- utils/shortcuts.py | 1 - 27 files changed, 46 insertions(+), 52 deletions(-) diff --git a/account/decorators.py b/account/decorators.py index baa7aad5..f801f95f 100644 --- a/account/decorators.py +++ b/account/decorators.py @@ -1,9 +1,9 @@ -from __future__ import unicode_literals import functools from django.utils.translation import ugettext as _ from utils.api import JSONResponse + from .models import AdminType diff --git a/account/middleware.py b/account/middleware.py index e494f1a0..29e1ea77 100644 --- a/account/middleware.py +++ b/account/middleware.py @@ -1,8 +1,10 @@ import time -from django.utils.translation import ugettext as _ + from django.contrib import auth +from django.utils.translation import ugettext as _ from utils.api import JSONResponse + from .models import AdminType diff --git a/account/migrations/0001_initial.py b/account/migrations/0001_initial.py index a028551e..c6de9c38 100644 --- a/account/migrations/0001_initial.py +++ b/account/migrations/0001_initial.py @@ -2,11 +2,12 @@ # Generated by Django 1.9.12 on 2017-01-23 07:59 from __future__ import unicode_literals -import account.models -from django.conf import settings -from django.db import migrations, models import django.db.models.deletion import jsonfield.fields +from django.conf import settings +from django.db import migrations, models + +import account.models class Migration(migrations.Migration): diff --git a/account/serializers.py b/account/serializers.py index 77c9cdc1..04d2a8e3 100644 --- a/account/serializers.py +++ b/account/serializers.py @@ -1,6 +1,6 @@ -from utils.api import serializers, DateTimeTZField +from utils.api import DateTimeTZField, serializers -from .models import User, AdminType +from .models import AdminType, User class UserLoginSerializer(serializers.Serializer): diff --git a/account/tests.py b/account/tests.py index f8fcd171..04ed9c78 100644 --- a/account/tests.py +++ b/account/tests.py @@ -3,12 +3,12 @@ from unittest import mock from django.contrib import auth from django.utils.translation import ugettext as _ - from otpauth import OtpAuth -from utils.shortcuts import rand_str -from utils.api.tests import APITestCase, APIClient -from .models import User, AdminType +from utils.api.tests import APIClient, APITestCase +from utils.shortcuts import rand_str + +from .models import AdminType, User class PermissionDecoratorTest(APITestCase): diff --git a/account/urls/oj.py b/account/urls/oj.py index bdcde3c5..6a1ef6c1 100644 --- a/account/urls/oj.py +++ b/account/urls/oj.py @@ -1,6 +1,6 @@ from django.conf.urls import url -from ..views.oj import UserLoginAPI, UserRegisterAPI, UserChangePasswordAPI +from ..views.oj import UserChangePasswordAPI, UserLoginAPI, UserRegisterAPI urlpatterns = [ url(r"^login$", UserLoginAPI.as_view(), name="user_login_api"), diff --git a/account/views/admin.py b/account/views/admin.py index a5d94891..e818b0a2 100644 --- a/account/views/admin.py +++ b/account/views/admin.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.core.exceptions import MultipleObjectsReturned from django.db.models import Q from django.utils.translation import ugettext as _ @@ -9,7 +7,7 @@ from utils.shortcuts import rand_str from ..decorators import super_admin_required from ..models import User -from ..serializers import (UserSerializer, EditUserSerializer) +from ..serializers import EditUserSerializer, UserSerializer class UserAdminAPI(APIView): diff --git a/account/views/oj.py b/account/views/oj.py index fb501990..3e48a120 100644 --- a/account/views/oj.py +++ b/account/views/oj.py @@ -1,15 +1,15 @@ from django.contrib import auth from django.core.exceptions import MultipleObjectsReturned from django.utils.translation import ugettext as _ - from otpauth import OtpAuth from utils.api import APIView, validate_serializer from utils.captcha import Captcha + from ..decorators import login_required from ..models import User, UserProfile -from ..serializers import (UserLoginSerializer, UserRegisterSerializer, - UserChangePasswordSerializer) +from ..serializers import (UserChangePasswordSerializer, UserLoginSerializer, + UserRegisterSerializer) class UserLoginAPI(APIView): diff --git a/announcement/migrations/0001_initial.py b/announcement/migrations/0001_initial.py index 345a10f6..cd92e223 100644 --- a/announcement/migrations/0001_initial.py +++ b/announcement/migrations/0001_initial.py @@ -2,9 +2,10 @@ # Generated by Django 1.9.12 on 2017-01-23 07:59 from __future__ import unicode_literals +import django.db.models.deletion from django.conf import settings from django.db import migrations, models -import django.db.models.deletion + import utils.models diff --git a/announcement/serializers.py b/announcement/serializers.py index 72393c8f..f1a5f494 100644 --- a/announcement/serializers.py +++ b/announcement/serializers.py @@ -1,7 +1,7 @@ -from utils.api import serializers - from account.models import User +from utils.api import serializers from utils.api._serializers import DateTimeTZField + from .models import Announcement diff --git a/announcement/views.py b/announcement/views.py index dbb3c6bb..04abf2cf 100644 --- a/announcement/views.py +++ b/announcement/views.py @@ -1,10 +1,10 @@ from django.utils.translation import ugettext as _ from account.decorators import super_admin_required -from utils.api import APIView, validate_serializer, IDOnlySerializer +from utils.api import APIView, IDOnlySerializer, validate_serializer from .models import Announcement -from .serializers import (CreateAnnouncementSerializer, AnnouncementSerializer, +from .serializers import (AnnouncementSerializer, CreateAnnouncementSerializer, EditAnnouncementSerializer) diff --git a/conf/serializers.py b/conf/serializers.py index 693c11ea..f4025cca 100644 --- a/conf/serializers.py +++ b/conf/serializers.py @@ -1,6 +1,6 @@ -from utils.api import serializers, DateTimeTZField +from utils.api import DateTimeTZField, serializers -from .models import SMTPConfig, WebsiteConfig, JudgeServer +from .models import JudgeServer, SMTPConfig, WebsiteConfig class EditSMTPConfigSerializer(serializers.Serializer): diff --git a/conf/tests.py b/conf/tests.py index 647d9448..c526489c 100644 --- a/conf/tests.py +++ b/conf/tests.py @@ -1,7 +1,8 @@ import hashlib from utils.api.tests import APITestCase -from .models import SMTPConfig, JudgeServerToken, JudgeServer + +from .models import JudgeServer, JudgeServerToken, SMTPConfig class SMTPConfigTest(APITestCase): diff --git a/conf/urls/admin.py b/conf/urls/admin.py index daecea22..dcb5c6fc 100644 --- a/conf/urls/admin.py +++ b/conf/urls/admin.py @@ -1,6 +1,6 @@ from django.conf.urls import url -from ..views import WebsiteConfigAPI, SMTPAPI, JudgeServerAPI +from ..views import SMTPAPI, JudgeServerAPI, WebsiteConfigAPI urlpatterns = [ url(r"^smtp$", SMTPAPI.as_view(), name="smtp_admin_api"), diff --git a/conf/urls/oj.py b/conf/urls/oj.py index 47a8dd89..db3ede37 100644 --- a/conf/urls/oj.py +++ b/conf/urls/oj.py @@ -1,7 +1,6 @@ from django.conf.urls import url -from ..views import WebsiteConfigAPI, JudgeServerHeartbeatAPI - +from ..views import JudgeServerHeartbeatAPI, WebsiteConfigAPI urlpatterns = [ url(r"^website$", WebsiteConfigAPI.as_view(), name="website_info_api"), diff --git a/conf/views.py b/conf/views.py index 5c6be3f0..4e9f12e1 100644 --- a/conf/views.py +++ b/conf/views.py @@ -6,11 +6,12 @@ from account.decorators import super_admin_required from utils.api import APIView, CSRFExemptAPIView, validate_serializer from utils.shortcuts import rand_str -from .models import SMTPConfig, WebsiteConfig, JudgeServer, JudgeServerToken -from .serializers import (WebsiteConfigSerializer, CreateEditWebsiteConfigSerializer, +from .models import JudgeServer, JudgeServerToken, SMTPConfig, WebsiteConfig +from .serializers import (CreateEditWebsiteConfigSerializer, CreateSMTPConfigSerializer, EditSMTPConfigSerializer, - SMTPConfigSerializer, TestSMTPConfigSerializer, - JudgeServerSerializer, JudgeServerHeartbeatSerializer) + JudgeServerHeartbeatSerializer, + JudgeServerSerializer, SMTPConfigSerializer, + TestSMTPConfigSerializer, WebsiteConfigSerializer) class SMTPAPI(APIView): diff --git a/contest/models.py b/contest/models.py index e6532b0b..d620a4c2 100644 --- a/contest/models.py +++ b/contest/models.py @@ -1,9 +1,9 @@ from django.db import models from django.utils.timezone import now -from group.models import Group from jsonfield import JSONField from account.models import User +from group.models import Group from problem.models import AbstractProblem from utils.models import RichTextField diff --git a/manage.py b/manage.py index 066fc698..16b46a54 100755 --- a/manage.py +++ b/manage.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -from __future__ import unicode_literals import os import sys diff --git a/oj/local_settings.py b/oj/local_settings.py index e2be1085..b9ad3b05 100644 --- a/oj/local_settings.py +++ b/oj/local_settings.py @@ -37,4 +37,3 @@ STATICFILES_DIRS = [os.path.join(BASE_DIR, "frontend/static/"), BASE_DIR] # 模板文件夹 OJ_TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'template/src/')] - diff --git a/oj/server_settings.py b/oj/server_settings.py index 9ec8dcfb..304ccb9b 100644 --- a/oj/server_settings.py +++ b/oj/server_settings.py @@ -46,5 +46,3 @@ STATICFILES_DIRS = [os.path.join(BASE_DIR, "static/release/")] # 模板文件夹 OJ_TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'template/release/')] - - diff --git a/oj/settings.py b/oj/settings.py index e25edd2a..1ececa5c 100644 --- a/oj/settings.py +++ b/oj/settings.py @@ -10,10 +10,11 @@ https://docs.djangoproject.com/en/1.8/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.8/ref/settings/ """ -from __future__ import absolute_import # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os +from .custom_settings import * + # 判断运行环境 ENV = os.environ.get("oj_env", "local") @@ -22,7 +23,6 @@ if ENV == "local": elif ENV == "server": from .server_settings import * -from .custom_settings import * BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) diff --git a/problem/models.py b/problem/models.py index 97d623b9..072abec7 100644 --- a/problem/models.py +++ b/problem/models.py @@ -1,7 +1,5 @@ -from __future__ import unicode_literals - -from jsonfield import JSONField from django.db import models +from jsonfield import JSONField from account.models import User from utils.models import RichTextField diff --git a/utils/api/_serializers.py b/utils/api/_serializers.py index 3e887873..7ad87dea 100644 --- a/utils/api/_serializers.py +++ b/utils/api/_serializers.py @@ -1,7 +1,6 @@ import json from django.utils import timezone - from rest_framework import serializers diff --git a/utils/api/api.py b/utils/api/api.py index 5141a872..bb8ce8cb 100644 --- a/utils/api/api.py +++ b/utils/api/api.py @@ -1,13 +1,12 @@ +import functools import json import logging -import functools from django.http import HttpResponse, QueryDict from django.utils.decorators import method_decorator from django.views.decorators.csrf import csrf_exempt from django.views.generic import View - logger = logging.getLogger(__name__) diff --git a/utils/api/tests.py b/utils/api/tests.py index 5ff30f85..50b12c78 100644 --- a/utils/api/tests.py +++ b/utils/api/tests.py @@ -1,9 +1,8 @@ -from django.test.testcases import TestCase from django.core.urlresolvers import reverse - +from django.test.testcases import TestCase from rest_framework.test import APIClient -from account.models import User, AdminType +from account.models import AdminType, User class APITestCase(TestCase): diff --git a/utils/management/commands/initadmin.py b/utils/management/commands/initadmin.py index d3e93afc..e33359e8 100644 --- a/utils/management/commands/initadmin.py +++ b/utils/management/commands/initadmin.py @@ -1,6 +1,7 @@ from django.core.management.base import BaseCommand -from account.models import User, UserProfile, AdminType -from utils.shortcuts import rand_str + +from account.models import AdminType, User, UserProfile +from utils.shortcuts import rand_str # NOQA class Command(BaseCommand): diff --git a/utils/shortcuts.py b/utils/shortcuts.py index c1ad448b..1dd88342 100644 --- a/utils/shortcuts.py +++ b/utils/shortcuts.py @@ -3,7 +3,6 @@ import random from django.utils.crypto import get_random_string - logger = logging.getLogger(__name__)