Skip to content

Commit

Permalink
fix(words): fix the missing self (#350)
Browse files Browse the repository at this point in the history
* fix(words): fix the missing self

* fix(words): fix the wrong name of variable
  • Loading branch information
CapooL authored Dec 6, 2023
1 parent 3bb7f2d commit 226c7c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion hinghwa-dict-backend/word/pronunciation/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
path("/combine", combinePronunciationV2),
path("/translate", translatePronunciation),
path("/<int:id>/visibility", csrf_exempt(ManageApproval.put)), # PUT PN0105 修改审核结果
path("/<int:id>/examine", csrf_exempt(ManageApproval.post)), # POST PN0106 审核
path("/<int:id>/examine", csrf_exempt(ManageApproval.as_view())), # POST PN0106 审核
path("/ranking", csrf_exempt(PronunciationRanking.as_view())), # PN0205语音榜单
path("/<str:ipa>", combinePronunciation),
]
19 changes: 9 additions & 10 deletions hinghwa-dict-backend/word/pronunciation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,6 +40,7 @@
manage_points_in_pronunciation,
revert_points_in_pronunciation,
)
from rewards.transactions.dto import transactions_all


# 从id中获取单条语音
Expand Down Expand Up @@ -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()
Expand All @@ -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 {}
Expand All @@ -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 {}
Expand All @@ -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 {}
Expand All @@ -367,22 +368,20 @@ 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],
content=content + reason,
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 {}
Expand Down

0 comments on commit 226c7c3

Please sign in to comment.