fmt
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
from django.urls import reverse
|
||||
from django.test.testcases import TestCase
|
||||
from rest_framework.test import APIClient
|
||||
|
||||
from account.models import AdminType, ProblemPermission, User, UserProfile
|
||||
|
||||
|
||||
class APITestCase(TestCase):
|
||||
client_class = APIClient
|
||||
|
||||
def create_user(self, username, password, admin_type=AdminType.REGULAR_USER, login=True,
|
||||
problem_permission=ProblemPermission.NONE):
|
||||
user = User.objects.create(username=username, admin_type=admin_type, problem_permission=problem_permission)
|
||||
user.set_password(password)
|
||||
UserProfile.objects.create(user=user)
|
||||
user.save()
|
||||
if login:
|
||||
self.client.login(username=username, password=password)
|
||||
return user
|
||||
|
||||
def create_admin(self, username="admin", password="admin", login=True):
|
||||
return self.create_user(username=username, password=password, admin_type=AdminType.ADMIN,
|
||||
problem_permission=ProblemPermission.OWN,
|
||||
login=login)
|
||||
|
||||
def create_super_admin(self, username="root", password="root", login=True):
|
||||
return self.create_user(username=username, password=password, admin_type=AdminType.SUPER_ADMIN,
|
||||
problem_permission=ProblemPermission.ALL, login=login)
|
||||
|
||||
def reverse(self, url_name, *args, **kwargs):
|
||||
return reverse(url_name, *args, **kwargs)
|
||||
|
||||
def assertSuccess(self, response):
|
||||
if not response.data["error"] is None:
|
||||
raise AssertionError("response with errors, response: " + str(response.data))
|
||||
|
||||
def assertFailed(self, response, msg=None):
|
||||
self.assertTrue(response.data["error"] is not None)
|
||||
if msg:
|
||||
self.assertEqual(response.data["data"], msg)
|
||||
@@ -1,7 +1,7 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
from django.core.cache import cache
|
||||
|
||||
from django.core.cache import cache
|
||||
from django_redis.cache import RedisCache
|
||||
from django_redis.client.default import DefaultClient
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ limitations under the License.
|
||||
"""
|
||||
|
||||
import os
|
||||
import time
|
||||
import random
|
||||
import time
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from . import Captcha
|
||||
from ..api import APIView
|
||||
from ..shortcuts import img2base64
|
||||
from . import Captcha
|
||||
|
||||
|
||||
class CaptchaAPIView(APIView):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import os
|
||||
import re
|
||||
import datetime
|
||||
import random
|
||||
import re
|
||||
from base64 import b64encode
|
||||
from io import BytesIO
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
|
||||
import dramatiq
|
||||
|
||||
from utils.shortcuts import DRAMATIQ_WORKER_ARGS
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import SimditorImageUploadAPIView, SimditorFileUploadAPIView
|
||||
from .views import SimditorFileUploadAPIView, SimditorImageUploadAPIView
|
||||
|
||||
urlpatterns = [
|
||||
path("upload_image", SimditorImageUploadAPIView.as_view()),
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import os
|
||||
from django.conf import settings
|
||||
from account.serializers import ImageUploadForm, FileUploadForm
|
||||
from utils.shortcuts import rand_str
|
||||
from utils.api import CSRFExemptAPIView
|
||||
import logging
|
||||
import os
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from account.serializers import FileUploadForm, ImageUploadForm
|
||||
from utils.api import CSRFExemptAPIView
|
||||
from utils.shortcuts import rand_str
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
WebSocket utility functions for pushing real-time updates
|
||||
"""
|
||||
import logging
|
||||
from channels.layers import get_channel_layer
|
||||
|
||||
from asgiref.sync import async_to_sync
|
||||
from channels.layers import get_channel_layer
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ Python 2.6+ or 3.2+
|
||||
Cannot defense xss in browser which is belowed IE7
|
||||
浏览器版本:IE7+ 或其他浏览器,无法防御IE6及以下版本浏览器中的XSS
|
||||
"""
|
||||
import re
|
||||
import copy
|
||||
import re
|
||||
from html.parser import HTMLParser
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user