format code

This commit is contained in:
virusdefender 2017-04-19 01:37:10 +08:00
parent c41a739e1f
commit 8128e076f2
17 changed files with 41 additions and 73 deletions

View File

@ -1,7 +1,5 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from celery import shared_task
from utils.mail import send_email

View File

@ -1,10 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from django.conf.urls import url
from ..views.oj import (UserChangePasswordAPI, UserLoginAPI, UserRegisterAPI,
ApplyResetPasswordAPI, ResetPasswordAPI)
from ..views.oj import (ApplyResetPasswordAPI, ResetPasswordAPI,
UserChangePasswordAPI, UserLoginAPI, UserRegisterAPI)
urlpatterns = [
url(r"^login/?$", UserLoginAPI.as_view(), name="user_login_api"),

View File

@ -1,10 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from django.conf.urls import url
from ..views.user import (UserInfoAPI, UserProfileAPI, AvatarUploadAPI,
SSOAPI, TwoFactorAuthAPI)
from ..views.user import (SSOAPI, AvatarUploadAPI, TwoFactorAuthAPI,
UserInfoAPI, UserProfileAPI)
urlpatterns = [
url(r"^user/?$", UserInfoAPI.as_view(), name="user_info_api"),

View File

@ -1,14 +1,11 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from datetime import timedelta
from otpauth import OtpAuth
from django.contrib import auth
from django.conf import settings
from django.contrib import auth
from django.core.exceptions import MultipleObjectsReturned
from django.utils.translation import ugettext as _
from django.utils.timezone import now
from django.utils.translation import ugettext as _
from otpauth import OtpAuth
from conf.models import WebsiteConfig
from utils.api import APIView, validate_serializer
@ -17,9 +14,10 @@ from utils.shortcuts import rand_str
from ..decorators import login_required
from ..models import User, UserProfile
from ..serializers import (UserChangePasswordSerializer, UserLoginSerializer,
UserRegisterSerializer,
ApplyResetPasswordSerializer, ResetPasswordSerializer)
from ..serializers import (ApplyResetPasswordSerializer,
ResetPasswordSerializer,
UserChangePasswordSerializer, UserLoginSerializer,
UserRegisterSerializer)
from ..tasks import _send_email

View File

@ -1,15 +1,11 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import qrcode
from io import StringIO
from otpauth import OtpAuth
import qrcode
from django.conf import settings
from django.http import HttpResponse
from django.utils.translation import ugettext as _
from otpauth import OtpAuth
from conf.models import WebsiteConfig
from utils.api import APIView, validate_serializer
@ -17,8 +13,8 @@ from utils.shortcuts import rand_str
from ..decorators import login_required
from ..models import User
from ..serializers import (EditUserSerializer, UserSerializer,
SSOSerializer, TwoFactorAuthCodeSerializer)
from ..serializers import (EditUserSerializer, SSOSerializer,
TwoFactorAuthCodeSerializer, UserSerializer)
class UserInfoAPI(APIView):

View File

@ -1,12 +1,12 @@
import copy
from datetime import datetime, timedelta
import copy
from django.utils import timezone
from utils.api._serializers import DateTimeTZField
from utils.api.tests import APITestCase
from .models import ContestAnnouncement
from .models import ContestRuleType
from .models import ContestAnnouncement, ContestRuleType
DEFAULT_CONTEST_DATA = {"title": "test title", "description": "test description",
"start_time": timezone.localtime(timezone.now()),

View File

@ -1,6 +1,7 @@
import dateutil.parser
from utils.api import APIView, validate_serializer
from ..models import Contest, ContestAnnouncement
from ..serializers import (ContestAnnouncementSerializer, ContestSerializer,
CreateConetestSeriaizer,

View File

@ -9,4 +9,5 @@ coverage
python-dateutil
celery
Envelopes
qrcode
qrcode
flake8-coding

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3
import copy
import base64
import copy
import random
import string
import xml.etree.ElementTree as ET

View File

@ -7,11 +7,6 @@ DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
},
# submission 的 name 和 engine 请勿修改,其他代码会用到
'submission': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db1.sqlite3'),
}
}
@ -33,3 +28,4 @@ ALLOWED_HOSTS = ["*"]
TEST_CASE_DIR = "/tmp"
LOG_PATH = "log/"

View File

@ -12,15 +12,6 @@ DATABASES = {
'PORT': 3306,
'USER': os.environ["MYSQL_ENV_MYSQL_USER"],
'PASSWORD': os.environ["MYSQL_ENV_MYSQL_ROOT_PASSWORD"]
},
'submission': {
'NAME': 'oj_submission',
'ENGINE': 'django.db.backends.mysql',
'CONN_MAX_AGE': 0.1,
'HOST': os.environ["MYSQL_PORT_3306_TCP_ADDR"],
'PORT': 3306,
'USER': os.environ["MYSQL_ENV_MYSQL_USER"],
'PASSWORD': os.environ["MYSQL_ENV_MYSQL_ROOT_PASSWORD"]
}
}
@ -43,3 +34,4 @@ ALLOWED_HOSTS = ['*']
TEST_CASE_DIR = "/test_case"
LOG_PATH = "log/"

View File

@ -104,8 +104,6 @@ STATIC_URL = '/static/'
AUTH_USER_MODEL = 'account.User'
LOG_PATH = "log/"
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
@ -118,13 +116,13 @@ LOGGING = {
'django_error': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': LOG_PATH + 'django.log',
'filename': os.path.join(LOG_PATH, 'django.log'),
'formatter': 'standard'
},
'app_info': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': LOG_PATH + 'app_info.log',
'filename': os.path.join(LOG_PATH, 'app_info.log'),
'formatter': 'standard'
},
'console': {
@ -152,17 +150,13 @@ LOGGING = {
},
}
if DEBUG:
REST_FRAMEWORK = {
'TEST_REQUEST_DEFAULT_FORMAT': 'json'
}
else:
REST_FRAMEWORK = {
'TEST_REQUEST_DEFAULT_FORMAT': 'json',
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
)
}
REST_FRAMEWORK = {
'TEST_REQUEST_DEFAULT_FORMAT': 'json',
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
)
}
# for celery
BROKER_URL = 'redis://%s:%s/%s' % (REDIS_QUEUE["host"], str(REDIS_QUEUE["port"]), str(REDIS_QUEUE["db"]))

View File

@ -6,6 +6,7 @@ from zipfile import ZipFile
from django.conf import settings
from utils.api.tests import APITestCase
from .models import ProblemTag
from .views.admin import TestCaseUploadAPI

View File

@ -1,6 +1,6 @@
from django.conf.urls import url
from ..views.admin import ProblemAPI, TestCaseUploadAPI, ContestProblemAPI
from ..views.admin import ContestProblemAPI, ProblemAPI, TestCaseUploadAPI
urlpatterns = [
url(r"^test_case/upload/?$", TestCaseUploadAPI.as_view(), name="test_case_upload_api"),

View File

@ -10,9 +10,10 @@ from contest.models import Contest
from utils.api import APIView, CSRFExemptAPIView, validate_serializer
from utils.shortcuts import rand_str
from ..models import Problem, ProblemRuleType, ProblemTag, ContestProblem
from ..serializers import (CreateProblemSerializer, EditProblemSerializer,
ProblemSerializer, TestCaseUploadForm, CreateContestProblemSerializer)
from ..models import ContestProblem, Problem, ProblemRuleType, ProblemTag
from ..serializers import (CreateContestProblemSerializer,
CreateProblemSerializer, EditProblemSerializer,
ProblemSerializer, TestCaseUploadForm)
class TestCaseUploadAPI(CSRFExemptAPIView):

View File

@ -1,12 +1,11 @@
import sys
import getopt
import os
import sys
opts, args = getopt.getopt(sys.argv[1:], "cm:", ["coverage=", "module="])
is_coverage = False
test_module = ""
waf_addr = "127.0.0.1:50001"
setting = "oj.settings"
for opt, arg in opts:

View File

@ -1,6 +1,3 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from envelopes import Envelope
from conf.models import SMTPConfig