Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump django version to 5.0.3 #359

Merged
merged 12 commits into from
Mar 18, 2024
8 changes: 6 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches:
- main
- develop
workflow_dispatch: {}
workflow_dispatch: { }
pull_request:
branches:
- main
Expand All @@ -18,7 +18,11 @@ jobs:
- name: Install ffmpeg
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: ffmpeg
packages: ffmpeg
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
cd hinghwa-dict-backend
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint-changed-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.8"
python-version: "3.10"

- name: Install dependencies
run: |
Expand Down
8 changes: 4 additions & 4 deletions hinghwa-dict-backend/HinghwaDict/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
https://docs.djangoproject.com/en/3.0/ref/settings/
"""

import logging
import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import time

import environ

env = environ.Env()
Expand Down Expand Up @@ -217,8 +216,8 @@
"formatters": {
"standard": {
"format": "[%(asctime)s] [%(levelname)s] : "
"[%(filename)s:%(lineno)d] [%(module)s:%(funcName)s] "
"- %(message)s"
"[%(filename)s:%(lineno)d] [%(module)s:%(funcName)s] "
"- %(message)s"
lin594 marked this conversation as resolved.
Show resolved Hide resolved
},
"simple": {"format": "%(levelname)s %(module)s %(lineno)d %(message)s"},
"verbose": {
Expand Down Expand Up @@ -315,3 +314,4 @@
SIMPLEUI_HOME_INFO = False
SIMPLEUI_HOME_ACTION = False
SIMPLEUI_ANALYSIS = False
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
16 changes: 8 additions & 8 deletions hinghwa-dict-backend/article/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import demjson
import demjson3
from django.http import JsonResponse
from django.utils import timezone
from django.views.decorators.csrf import csrf_exempt
Expand Down Expand Up @@ -70,7 +70,7 @@ def get(self, request) -> JsonResponse:
def post(self, request) -> JsonResponse:
token = token_pass(request.headers)
user = token_user(token)
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
article_form = ArticleForm(body)
if not article_form.is_valid():
raise BadRequestException()
Expand All @@ -90,7 +90,7 @@ def post(self, request) -> JsonResponse:

# AT0202 文章内容批量获取
def put(self, request) -> JsonResponse:
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
result = Article.objects.filter(id__in=body["articles"])
try:
token = token_pass(request.headers)
Expand Down Expand Up @@ -156,7 +156,7 @@ def put(self, request, id) -> JsonResponse:
raise ArticleNotFoundException()
article = article[0]
token = token_pass(request.headers, article.author.id)
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
body = body["article"]
article_form = ArticleForm(body)
for key in body:
Expand Down Expand Up @@ -196,7 +196,7 @@ def put(self, request, id) -> JsonResponse:
if not article.exists():
raise ArticleNotFoundException()
article = article[0]
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
article.visibility = body["result"]
if article.visibility:
content = f"恭喜您的 文章(id={id}) 已通过审核"
Expand Down Expand Up @@ -271,7 +271,7 @@ def post(self, request, id) -> JsonResponse:
):
raise ArticleNotFoundException()
article = article[0]
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
comment_form = CommentForm(body)
if not comment_form.is_valid():
raise BadRequestException()
Expand All @@ -292,7 +292,7 @@ def delete(self, request, id) -> JsonResponse:
article[0].visibility or user.is_superuser or user == article[0].author
):
raise ArticleNotFoundException()
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
comment = Comment.objects.get(id=body["id"])
if token_pass(request.headers, comment.user.id) or token_pass(
request.headers, -1
Expand All @@ -305,7 +305,7 @@ def delete(self, request, id) -> JsonResponse:
class SearchComment(View):
# AT0403 评论内容批量获取
def put(self, request) -> JsonResponse:
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
result = Comment.objects.filter(id__in=body["comments"])
result = filterInOrder(result, body["comments"])
comments = []
Expand Down
8 changes: 4 additions & 4 deletions hinghwa-dict-backend/music/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import demjson
import demjson3
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from django.views import View
Expand Down Expand Up @@ -32,7 +32,7 @@ def get(self, request) -> JsonResponse:
def post(self, request) -> JsonResponse:
token = token_pass(request.headers)
user = token_user(token)
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
music_form = MusicForm(body)
if not music_form.is_valid():
raise BadRequestException()
Expand All @@ -43,7 +43,7 @@ def post(self, request) -> JsonResponse:

# MC0202 音乐批量获取
def put(self, request) -> JsonResponse:
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
result = Music.objects.filter(id__in=body["music"])
result = filterInOrder(result, body["music"])
musics = []
Expand Down Expand Up @@ -73,7 +73,7 @@ def put(self, request, id) -> JsonResponse:
raise MusicNotFoundException()
music = music[0]
token = token_pass(request.headers, music.contributor.id)
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
body = body["music"]
music_form = MusicForm(body)
for key in body:
Expand Down
4 changes: 2 additions & 2 deletions hinghwa-dict-backend/quiz/cert/view/cert_all.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import demjson
import demjson3
from django.http import JsonResponse
from django.views import View
from ...models import Cert
Expand All @@ -17,7 +17,7 @@ class AllCert(View):
# QZ0502创建证书
def post(self, request):
token_pass(request.headers, -1)
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
cert_form = CertForm(body["cert"])
if not cert_form.is_valid():
raise BadRequestException()
Expand Down
4 changes: 2 additions & 2 deletions hinghwa-dict-backend/quiz/paper/view/manage_all.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.http import JsonResponse
import demjson
import demjson3
from ..dto.paper_all import paper_all
from django.views import View
from django.views.decorators.csrf import csrf_exempt
Expand All @@ -15,7 +15,7 @@ class ManageAllPaper(View):
def post(self, request):
token_pass(request.headers, -1)
number = int(request.GET["number"])
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
title = body["title"]
request_type = request.GET["type"]
type_list = request_type.split(",")
Expand Down
1 change: 0 additions & 1 deletion hinghwa-dict-backend/quiz/paper/view/manage_single.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import demjson
from django.http import JsonResponse
from ..dto.paper_all import paper_all
from django.views import View
Expand Down
1 change: 0 additions & 1 deletion hinghwa-dict-backend/quiz/paper/view/paper_record_all.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.http import JsonResponse
import demjson
from ..dto.paper_record_dto import paper_record_all
from django.views import View
from ...models import Quiz, Paper
Expand Down
4 changes: 2 additions & 2 deletions hinghwa-dict-backend/quiz/quiz_record/view/quiz_record_all.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.http import JsonResponse
import demjson
import demjson3
from ..dto.quiz_record import quiz_record
from django.views import View
from ...models import Quiz, Paper, QuizRecord
Expand All @@ -21,7 +21,7 @@ class QuizRecordAll(View):
# QZ0401创建答题记录
def post(self, request):
token_pass(request.headers)
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
record_form = QuizRecordForm(body)
quiz_id = request.GET["quiz_id"]
quiz = Quiz.objects.filter(id=quiz_id)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.http import JsonResponse
import demjson
import demjson3
from ..dto.quiz_record import quiz_record
from django.views import View
from ...models import Paper, QuizRecord, PaperRecord
Expand Down Expand Up @@ -27,7 +27,7 @@ def get(self, request, record_id):
# QZ0404更改特定答题记录
def put(self, request, record_id):
token_pass(request.headers, -1)
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
if body["paper_record"] != "":
paper = PaperRecord.objects.filter(id=body["paper_record"])
if not paper.exists():
Expand Down
8 changes: 4 additions & 4 deletions hinghwa-dict-backend/quiz/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import demjson
import demjson3
from django.http import JsonResponse
from django.conf import settings
from django.views import View
Expand Down Expand Up @@ -40,7 +40,7 @@ def get(self, request, id) -> JsonResponse:
# QZ0103 修改单个测试
def put(self, request, id) -> JsonResponse:
try:
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
token = token_pass(request.headers)
user = token_user(token)
quiz = Quiz.objects.filter(id=id)
Expand Down Expand Up @@ -107,7 +107,7 @@ def get(self, request) -> JsonResponse:

# QZ0102 增加单个测试
def post(self, request) -> JsonResponse:
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
token = token_pass(request.headers)
user = token_user(token)
quiz_form = QuizForm(body)
Expand Down Expand Up @@ -142,7 +142,7 @@ def put(self, request, id) -> JsonResponse:
if not quiz.exists():
raise QuizNotFoundException()
quiz = quiz[0]
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
quiz.visibility = body["result"]
if quiz.visibility:
content = f"问题(id={id})已通过审核"
Expand Down
10 changes: 5 additions & 5 deletions hinghwa-dict-backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
setuptools==57.4.0
django==3.1.14
demjson~=2.2.4
setuptools==69.1.1
django==5.0.3
demjson3~=3.0.6
pyjwt~=2.4.0
django-cors-headers
django-cors-headers~=4.3.1
xlrd~=2.0.1
cos-python-sdk-v5
apscheduler==3.7.0
django_apscheduler
django-notifications-hq==1.6.0
django-notifications-hq==1.8.3
pydub==0.25.1
ffmpeg==1.4
ffprobe==0.5
Expand Down
4 changes: 2 additions & 2 deletions hinghwa-dict-backend/rewards/orders/views/Manage_all.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import demjson
import demjson3
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt

Expand Down Expand Up @@ -29,7 +29,7 @@ def post(self, request) -> JsonResponse:
if not product.exists():
raise ProductsNotFoundException()
product = product[0]
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
if user.user_info.points_now < product.points:
return JsonResponse({"msg": "用户积分不足"}, status=403)
if product.quantity <= 0:
Expand Down
4 changes: 2 additions & 2 deletions hinghwa-dict-backend/rewards/orders/views/Manage_single.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import demjson
import demjson3
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from ..dto.orders_all import order_all
Expand Down Expand Up @@ -46,7 +46,7 @@ def put(self, request, order_id):
user_id = order.user.id
token = token_pass(request.headers, -1) or token_pass(request.headers, user_id)
if token:
body = demjson.decode(request.body)
body = demjson3.decode(request.body)

for key in body:
setattr(order, key, body[key])
Expand Down
4 changes: 2 additions & 2 deletions hinghwa-dict-backend/rewards/products/views/Manage_all.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import demjson
import demjson3
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from ..dto.product_all import product_all
Expand All @@ -16,7 +16,7 @@ class ManageAllProducts(View):
@csrf_exempt
def post(self, request) -> JsonResponse:
token = token_pass(request.headers, -1)
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
products_form = ProductInfoForm(body)
if not products_form.is_valid():
raise BadRequestException()
Expand Down
4 changes: 2 additions & 2 deletions hinghwa-dict-backend/rewards/products/views/Manage_single.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import demjson
import demjson3
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from ..dto.product_all import product_all
Expand Down Expand Up @@ -37,7 +37,7 @@ def put(self, request, id) -> JsonResponse:
if not products.exists():
raise ProductsNotFoundException()
products = products[0]
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
for key in body:
setattr(products, key, body[key])
products.save()
Expand Down
4 changes: 2 additions & 2 deletions hinghwa-dict-backend/rewards/titles/views/Manage_all.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import demjson
import demjson3
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from ..dto.title_all import title_all
Expand Down Expand Up @@ -40,7 +40,7 @@ def get(self, request):
@csrf_exempt
def post(self, request) -> JsonResponse:
token = token_pass(request.headers, -1)
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
title_form = TitleInfoForm(body)
if not title_form.is_valid():
raise BadRequestException()
Expand Down
4 changes: 2 additions & 2 deletions hinghwa-dict-backend/rewards/titles/views/Manage_single.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import demjson
import demjson3
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from ..dto.title_all import title_all
Expand Down Expand Up @@ -37,7 +37,7 @@ def put(self, request, id) -> JsonResponse:
if not title.exists():
raise TitleNotFoundException()
title = title[0]
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
for key in body:
setattr(title, key, body[key])
title.save()
Expand Down
4 changes: 2 additions & 2 deletions hinghwa-dict-backend/user/view/forget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import demjson
import demjson3
from django.contrib.auth.models import User
from django.http import JsonResponse
from django.views import View
Expand Down Expand Up @@ -27,7 +27,7 @@ def get(self, request):
# LG0202 重置密码
def put(self, request, id):
# 检查验证码并重置用户密码
body = demjson.decode(request.body)
body = demjson3.decode(request.body)
user = check_request_user(request, id)
if user.username != body["username"]:
raise ForbiddenException("用户名不匹配")
Expand Down
Loading
Loading