From 226c7c390576d38d0195b5434efea4c3a1857b3b Mon Sep 17 00:00:00 2001 From: CapooL <111524029+CapooL@users.noreply.github.com> Date: Wed, 6 Dec 2023 23:26:59 +0800 Subject: [PATCH] fix(words): fix the missing self (#350) * fix(words): fix the missing self * fix(words): fix the wrong name of variable --- .../word/pronunciation/urls.py | 2 +- .../word/pronunciation/views.py | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/hinghwa-dict-backend/word/pronunciation/urls.py b/hinghwa-dict-backend/word/pronunciation/urls.py index f04fae38..86c19b8c 100644 --- a/hinghwa-dict-backend/word/pronunciation/urls.py +++ b/hinghwa-dict-backend/word/pronunciation/urls.py @@ -16,7 +16,7 @@ path("/combine", combinePronunciationV2), path("/translate", translatePronunciation), path("//visibility", csrf_exempt(ManageApproval.put)), # PUT PN0105 修改审核结果 - path("//examine", csrf_exempt(ManageApproval.post)), # POST PN0106 审核 + path("//examine", csrf_exempt(ManageApproval.as_view())), # POST PN0106 审核 path("/ranking", csrf_exempt(PronunciationRanking.as_view())), # PN0205语音榜单 path("/", combinePronunciation), ] diff --git a/hinghwa-dict-backend/word/pronunciation/views.py b/hinghwa-dict-backend/word/pronunciation/views.py index 9846d788..1ad7bc94 100644 --- a/hinghwa-dict-backend/word/pronunciation/views.py +++ b/hinghwa-dict-backend/word/pronunciation/views.py @@ -13,7 +13,7 @@ from django.db.models import Q, Count, Max from django.core.paginator import Paginator from pydub import AudioSegment as audio - +from rewards.transactions.dto import transactions_all from user.models import User from utils.token import get_request_user, token_pass, token_user from user.dto.user_simple import user_simple @@ -40,6 +40,7 @@ manage_points_in_pronunciation, revert_points_in_pronunciation, ) +from rewards.transactions.dto import transactions_all # 从id中获取单条语音 @@ -294,7 +295,7 @@ def combinePronunciationV2(request): class ManagePronunciation(View): # PN0101 获取发音信息 - def get(request, id): + def get(self, request, id): pronunciation = get_pronunciation_by_id(id) pronunciation.views += 1 pronunciation.save() @@ -304,7 +305,7 @@ def get(request, id): ) # PN0103 更改发音信息 - def put(request, id): + def put(self, request, id): token_pass(request.headers, -1) pronunciation = get_pronunciation_by_id(id) body = demjson.decode(request.body) if len(request.body) else {} @@ -323,7 +324,7 @@ def put(request, id): return JsonResponse({}, status=200) # PN0104 删除发音 - def delete(request, id): + def delete(self, request, id): token_pass(request.headers, -1) pronunciation = get_pronunciation_by_id(id) body = demjson.decode(request.body) if len(request.body) else {} @@ -345,7 +346,7 @@ def delete(request, id): class ManageApproval(View): # PN0106 审核语音 - def post(request, id): + def post(self, request, id): token_pass(request.headers, -1) verifier = get_request_user(request) body = demjson.decode(request.body) if len(request.body) else {} @@ -367,11 +368,9 @@ def post(request, id): contributor = pronunciation.contributor if result: content = f"恭喜您,您的语音{pro}审核通过" - transaction_info = manage_points_in_pronunciation(contributor.id) - + transaction = manage_points_in_pronunciation(contributor.id) else: content = f"很遗憾,您的语音{pro}审核未通过" - transaction_info = revert_points_in_pronunciation(contributor.id) sendNotification( verifier, [contributor], @@ -379,10 +378,10 @@ def post(request, id): action_object=pronunciation, title=f"【通知】语音({pronunciation.word.word})审核结果", ) - return JsonResponse(transaction_info, status=200) + return JsonResponse(transaction, status=200) # PN0105 更改审核结果 - def put(request, id): + def put(self, request, id): token_pass(request.headers, -1) verifier = get_request_user(request) body = demjson.decode(request.body) if len(request.body) else {}