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 {}