From 4cc01df43773552fc7757241d071adc2bd21ccbd Mon Sep 17 00:00:00 2001 From: CapooL <2053217188@qq.com> Date: Fri, 26 Jan 2024 23:58:27 +0800 Subject: [PATCH] style(quiz): reformat the code --- hinghwa-dict-backend/HinghwaDict/settings.py | 9 +++-- hinghwa-dict-backend/HinghwaDict/urls.py | 1 + .../article/migrations/0001_initial.py | 14 ++++++-- hinghwa-dict-backend/article/models.py | 5 ++- hinghwa-dict-backend/article/views.py | 12 +++++-- .../music/migrations/0001_initial.py | 5 ++- .../quiz/migrations/0001_initial.py | 5 ++- .../quiz/migrations/0004_quiz_paper.py | 4 ++- hinghwa-dict-backend/quiz/models.py | 4 ++- .../rewards/migrations/0001_initial.py | 4 ++- hinghwa-dict-backend/user/dto/user_all.py | 8 +++-- .../user/migrations/0001_initial.py | 12 +++++-- .../utils/exception/types/bad_request.py | 3 +- .../website/migrations/0001_initial.py | 25 +++++++++++--- hinghwa-dict-backend/website/models.py | 12 +++++-- .../word/application/views.py | 4 ++- .../word/migrations/0001_initial.py | 34 ++++++++++++++----- .../word/migrations/0004_word_list.py | 14 ++++++-- hinghwa-dict-backend/word/models.py | 28 +++++++++++---- .../pronunciation/dto/pronunciation_all.py | 16 +++++---- .../pronunciation/dto/pronunciation_normal.py | 16 +++++---- .../word/pronunciation/urls.py | 8 +++-- .../word/pronunciation/views.py | 2 +- hinghwa-dict-backend/word/word/views.py | 4 ++- 24 files changed, 185 insertions(+), 64 deletions(-) diff --git a/hinghwa-dict-backend/HinghwaDict/settings.py b/hinghwa-dict-backend/HinghwaDict/settings.py index 96a9adbd..c1f2d502 100644 --- a/hinghwa-dict-backend/HinghwaDict/settings.py +++ b/hinghwa-dict-backend/HinghwaDict/settings.py @@ -9,6 +9,7 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.0/ref/settings/ """ + import logging import os @@ -188,8 +189,12 @@ "token", ) # parameter of Tencent cos -COS_SECRET_ID = env.str("COS_SECRET_ID", "DEFAULT_COS_SECRET_ID") # 替换为用户的 secretId -COS_SECRET_KEY = env.str("COS_SECRET_KEY", "DEFAULT_COS_SECRET_KEY") # 替换为用户的 secretKey +COS_SECRET_ID = env.str( + "COS_SECRET_ID", "DEFAULT_COS_SECRET_ID" +) # 替换为用户的 secretId +COS_SECRET_KEY = env.str( + "COS_SECRET_KEY", "DEFAULT_COS_SECRET_KEY" +) # 替换为用户的 secretKey COS_BUCKET = env.str("COS_BUCKET", "DEFAULT_COS_BUCKET") # BucketName-APPID COS_REGION = env.str("COS_REGION", "DEFAULT_COS_REGION") diff --git a/hinghwa-dict-backend/HinghwaDict/urls.py b/hinghwa-dict-backend/HinghwaDict/urls.py index 88eedb6e..1265acdc 100644 --- a/hinghwa-dict-backend/HinghwaDict/urls.py +++ b/hinghwa-dict-backend/HinghwaDict/urls.py @@ -13,6 +13,7 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ + from django.contrib import admin from django.urls import path, include diff --git a/hinghwa-dict-backend/article/migrations/0001_initial.py b/hinghwa-dict-backend/article/migrations/0001_initial.py index 4c36c095..0b1cb774 100644 --- a/hinghwa-dict-backend/article/migrations/0001_initial.py +++ b/hinghwa-dict-backend/article/migrations/0001_initial.py @@ -25,7 +25,9 @@ class Migration(migrations.Migration): ), ( "views", - models.IntegerField(default=0, editable=False, verbose_name="阅读量"), + models.IntegerField( + default=0, editable=False, verbose_name="阅读量" + ), ), ( "publish_time", @@ -39,7 +41,10 @@ class Migration(migrations.Migration): ), ("content", models.TextField(verbose_name="正文")), ("cover", models.URLField(verbose_name="图片地址")), - ("visibility", models.BooleanField(default=False, verbose_name="是否审核")), + ( + "visibility", + models.BooleanField(default=False, verbose_name="是否审核"), + ), ( "author", models.ForeignKey( @@ -78,7 +83,10 @@ class Migration(migrations.Migration): ), ), ("content", models.TextField(max_length=500, verbose_name="内容")), - ("time", models.DateTimeField(auto_now_add=True, verbose_name="评论时间")), + ( + "time", + models.DateTimeField(auto_now_add=True, verbose_name="评论时间"), + ), ( "article", models.ForeignKey( diff --git a/hinghwa-dict-backend/article/models.py b/hinghwa-dict-backend/article/models.py index 80cfc87f..33f44e9e 100644 --- a/hinghwa-dict-backend/article/models.py +++ b/hinghwa-dict-backend/article/models.py @@ -60,7 +60,10 @@ class Comment(models.Model): verbose_name="父评论", ) article = models.ForeignKey( - Article, on_delete=models.CASCADE, related_name="comments", verbose_name="评论文章" + Article, + on_delete=models.CASCADE, + related_name="comments", + verbose_name="评论文章", ) like_users = models.ManyToManyField( User, diff --git a/hinghwa-dict-backend/article/views.py b/hinghwa-dict-backend/article/views.py index dc271f0a..244e8042 100644 --- a/hinghwa-dict-backend/article/views.py +++ b/hinghwa-dict-backend/article/views.py @@ -80,7 +80,11 @@ def post(self, request) -> JsonResponse: article.save() content = f"我创建了文章(id={article.id}),请及时去审核" sendNotification( - article.author, None, content, title="【提醒】文章待审核", action_object=article + article.author, + None, + content, + title="【提醒】文章待审核", + action_object=article, ) return JsonResponse({"id": article.id}, status=200) @@ -165,7 +169,11 @@ def put(self, request, id) -> JsonResponse: article.save() content = f"我修改了文章(id={article.id}),请及时去审核" sendNotification( - article.author, None, content, title="【提醒】文章待审核", action_object=article + article.author, + None, + content, + title="【提醒】文章待审核", + action_object=article, ) return JsonResponse({}, status=200) diff --git a/hinghwa-dict-backend/music/migrations/0001_initial.py b/hinghwa-dict-backend/music/migrations/0001_initial.py index d0469150..242e7fbe 100644 --- a/hinghwa-dict-backend/music/migrations/0001_initial.py +++ b/hinghwa-dict-backend/music/migrations/0001_initial.py @@ -27,7 +27,10 @@ class Migration(migrations.Migration): ("title", models.CharField(max_length=100, verbose_name="曲名")), ("artist", models.CharField(max_length=100, verbose_name="作者")), ("cover", models.URLField(verbose_name="音乐封面地址")), - ("visibility", models.BooleanField(default=False, verbose_name="是否可见")), + ( + "visibility", + models.BooleanField(default=False, verbose_name="是否可见"), + ), ( "contributor", models.ForeignKey( diff --git a/hinghwa-dict-backend/quiz/migrations/0001_initial.py b/hinghwa-dict-backend/quiz/migrations/0001_initial.py index 9bc08acc..b35463fd 100644 --- a/hinghwa-dict-backend/quiz/migrations/0001_initial.py +++ b/hinghwa-dict-backend/quiz/migrations/0001_initial.py @@ -26,7 +26,10 @@ class Migration(migrations.Migration): ), ("answer", models.IntegerField(default=0, verbose_name="答案序号")), ("explanation", models.TextField(verbose_name="答案解析")), - ("visibility", models.BooleanField(default=False, verbose_name="是否审核")), + ( + "visibility", + models.BooleanField(default=False, verbose_name="是否审核"), + ), ], options={ "verbose_name": "测试题", diff --git a/hinghwa-dict-backend/quiz/migrations/0004_quiz_paper.py b/hinghwa-dict-backend/quiz/migrations/0004_quiz_paper.py index a5ed03f2..72a57514 100644 --- a/hinghwa-dict-backend/quiz/migrations/0004_quiz_paper.py +++ b/hinghwa-dict-backend/quiz/migrations/0004_quiz_paper.py @@ -17,7 +17,9 @@ class Migration(migrations.Migration): fields=[ ( "title", - models.CharField(blank=True, max_length=50, verbose_name="试卷标题"), + models.CharField( + blank=True, max_length=50, verbose_name="试卷标题" + ), ), ( "id", diff --git a/hinghwa-dict-backend/quiz/models.py b/hinghwa-dict-backend/quiz/models.py index 8510a32d..efdb2800 100644 --- a/hinghwa-dict-backend/quiz/models.py +++ b/hinghwa-dict-backend/quiz/models.py @@ -16,7 +16,9 @@ class Quiz(models.Model): answer = models.IntegerField(default=0, verbose_name="答案序号", editable=True) explanation = models.TextField(verbose_name="答案解析") visibility = models.BooleanField(default=False, verbose_name="是否审核") - voice_source = models.URLField(max_length=200, verbose_name="播报语音链接", default="") + voice_source = models.URLField( + max_length=200, verbose_name="播报语音链接", default="" + ) type = models.CharField(blank=True, max_length=50, verbose_name="问题类型") def __str__(self): diff --git a/hinghwa-dict-backend/rewards/migrations/0001_initial.py b/hinghwa-dict-backend/rewards/migrations/0001_initial.py index 20af86d7..16ecdc3e 100644 --- a/hinghwa-dict-backend/rewards/migrations/0001_initial.py +++ b/hinghwa-dict-backend/rewards/migrations/0001_initial.py @@ -26,7 +26,9 @@ class Migration(migrations.Migration): ), ( "details", - models.TextField(blank=True, max_length=200, verbose_name="商品详情"), + models.TextField( + blank=True, max_length=200, verbose_name="商品详情" + ), ), ( "id", diff --git a/hinghwa-dict-backend/user/dto/user_all.py b/hinghwa-dict-backend/user/dto/user_all.py index 72d441b9..619a58e0 100644 --- a/hinghwa-dict-backend/user/dto/user_all.py +++ b/hinghwa-dict-backend/user/dto/user_all.py @@ -30,9 +30,11 @@ def user_all(user: User) -> dict: response.update( { - "login_time": localtime(user.last_login).__format__("%Y-%m-%d %H:%M:%S") - if user.last_login - else "", + "login_time": ( + localtime(user.last_login).__format__("%Y-%m-%d %H:%M:%S") + if user.last_login + else "" + ), } ) return response diff --git a/hinghwa-dict-backend/user/migrations/0001_initial.py b/hinghwa-dict-backend/user/migrations/0001_initial.py index 07b1d529..59b6b9e0 100644 --- a/hinghwa-dict-backend/user/migrations/0001_initial.py +++ b/hinghwa-dict-backend/user/migrations/0001_initial.py @@ -26,11 +26,15 @@ class Migration(migrations.Migration): ), ( "wechat", - models.CharField(blank=True, max_length=128, verbose_name="微信标识码"), + models.CharField( + blank=True, max_length=128, verbose_name="微信标识码" + ), ), ( "qq", - models.CharField(blank=True, max_length=128, verbose_name="qq标识码"), + models.CharField( + blank=True, max_length=128, verbose_name="qq标识码" + ), ), ( "nickname", @@ -38,7 +42,9 @@ class Migration(migrations.Migration): ), ( "birthday", - models.DateField(blank=True, default="1970-1-1", verbose_name="生日"), + models.DateField( + blank=True, default="1970-1-1", verbose_name="生日" + ), ), ( "telephone", diff --git a/hinghwa-dict-backend/utils/exception/types/bad_request.py b/hinghwa-dict-backend/utils/exception/types/bad_request.py index a51bc061..bd23aa9f 100644 --- a/hinghwa-dict-backend/utils/exception/types/bad_request.py +++ b/hinghwa-dict-backend/utils/exception/types/bad_request.py @@ -54,6 +54,7 @@ class ReturnUsersNumException(BadRequestException): """ def __init__( - self, msg="请在return_users_num字段中加入请求的点赞人数,要求为正整数,或者不发送return_users_num字段" + self, + msg="请在return_users_num字段中加入请求的点赞人数,要求为正整数,或者不发送return_users_num字段", ): super().__init__(msg) diff --git a/hinghwa-dict-backend/website/migrations/0001_initial.py b/hinghwa-dict-backend/website/migrations/0001_initial.py index d6efe746..626c1587 100644 --- a/hinghwa-dict-backend/website/migrations/0001_initial.py +++ b/hinghwa-dict-backend/website/migrations/0001_initial.py @@ -20,8 +20,14 @@ class Migration(migrations.Migration): ), ), ("english", models.CharField(max_length=255, verbose_name="英文表达")), - ("mandarin", models.CharField(max_length=255, verbose_name="普通话表达")), - ("character", models.CharField(max_length=255, verbose_name="方言表达")), + ( + "mandarin", + models.CharField(max_length=255, verbose_name="普通话表达"), + ), + ( + "character", + models.CharField(max_length=255, verbose_name="方言表达"), + ), ("pinyin", models.CharField(max_length=255, verbose_name="方言拼音")), ], options={ @@ -41,9 +47,18 @@ class Migration(migrations.Migration): verbose_name="ID", ), ), - ("announcements", models.TextField(default="[]", verbose_name="本站公告")), - ("hot_articles", models.TextField(default="[]", verbose_name="热门文章")), - ("word_of_the_day", models.TextField(default="1", verbose_name="每日一词")), + ( + "announcements", + models.TextField(default="[]", verbose_name="本站公告"), + ), + ( + "hot_articles", + models.TextField(default="[]", verbose_name="热门文章"), + ), + ( + "word_of_the_day", + models.TextField(default="1", verbose_name="每日一词"), + ), ("carousel", models.TextField(default="[]", verbose_name="精品推荐")), ], options={ diff --git a/hinghwa-dict-backend/website/models.py b/hinghwa-dict-backend/website/models.py index 2b7d45ac..47916d09 100644 --- a/hinghwa-dict-backend/website/models.py +++ b/hinghwa-dict-backend/website/models.py @@ -3,10 +3,16 @@ class Website(models.Model): - announcements = models.TextField(verbose_name="本站公告", default="[]") # list[文章id] - hot_articles = models.TextField(verbose_name="热门文章", default="[]") # list[文章id] + announcements = models.TextField( + verbose_name="本站公告", default="[]" + ) # list[文章id] + hot_articles = models.TextField( + verbose_name="热门文章", default="[]" + ) # list[文章id] word_of_the_day = models.TextField(verbose_name="每日一词", default="1") # int - carousel = models.TextField(verbose_name="精品推荐", default="[]") # dict{id,source} + carousel = models.TextField( + verbose_name="精品推荐", default="[]" + ) # dict{id,source} class Meta: verbose_name_plural = "网页内容" diff --git a/hinghwa-dict-backend/word/application/views.py b/hinghwa-dict-backend/word/application/views.py index bbaac6fd..eb4199fd 100644 --- a/hinghwa-dict-backend/word/application/views.py +++ b/hinghwa-dict-backend/word/application/views.py @@ -106,7 +106,9 @@ def put(self, request, id) -> JsonResponse: """ WD0404 修改申请 """ - user = token_user(token_pass(request.headers, -1)) # user = 操作用户(仅限管理员) + user = token_user( + token_pass(request.headers, -1) + ) # user = 操作用户(仅限管理员) application = find_application(id) application.verifier = user feedback = None diff --git a/hinghwa-dict-backend/word/migrations/0001_initial.py b/hinghwa-dict-backend/word/migrations/0001_initial.py index 807c537e..00958b13 100644 --- a/hinghwa-dict-backend/word/migrations/0001_initial.py +++ b/hinghwa-dict-backend/word/migrations/0001_initial.py @@ -62,7 +62,9 @@ class Migration(migrations.Migration): ("annotation", models.TextField(blank=True, verbose_name="附注")), ( "mandarin", - models.TextField(blank=True, default="[]", verbose_name="对应普通话词语"), + models.TextField( + blank=True, default="[]", verbose_name="对应普通话词语" + ), ), ( "standard_ipa", @@ -70,13 +72,20 @@ class Migration(migrations.Migration): ), ( "standard_pinyin", - models.CharField(blank=True, max_length=30, verbose_name="标准拼音"), + models.CharField( + blank=True, max_length=30, verbose_name="标准拼音" + ), ), ( "views", - models.IntegerField(default=0, editable=False, verbose_name="访问量"), + models.IntegerField( + default=0, editable=False, verbose_name="访问量" + ), + ), + ( + "visibility", + models.BooleanField(default=False, verbose_name="是否审核"), ), - ("visibility", models.BooleanField(default=False, verbose_name="是否审核")), ( "contributor", models.ForeignKey( @@ -127,10 +136,15 @@ class Migration(migrations.Migration): ("pinyin", models.CharField(max_length=50, verbose_name="拼音")), ("county", models.CharField(max_length=100, verbose_name="县区")), ("town", models.CharField(max_length=100, verbose_name="乡镇")), - ("visibility", models.BooleanField(default=False, verbose_name="是否可见")), + ( + "visibility", + models.BooleanField(default=False, verbose_name="是否可见"), + ), ( "views", - models.IntegerField(default=0, editable=False, verbose_name="访问量"), + models.IntegerField( + default=0, editable=False, verbose_name="访问量" + ), ), ( "contributor", @@ -192,7 +206,9 @@ class Migration(migrations.Migration): ("annotation", models.TextField(blank=True, verbose_name="附注")), ( "mandarin", - models.TextField(blank=True, default="[]", verbose_name="对应普通话词语"), + models.TextField( + blank=True, default="[]", verbose_name="对应普通话词语" + ), ), ( "standard_ipa", @@ -200,7 +216,9 @@ class Migration(migrations.Migration): ), ( "standard_pinyin", - models.CharField(blank=True, max_length=30, verbose_name="标准拼音"), + models.CharField( + blank=True, max_length=30, verbose_name="标准拼音" + ), ), ( "contributor", diff --git a/hinghwa-dict-backend/word/migrations/0004_word_list.py b/hinghwa-dict-backend/word/migrations/0004_word_list.py index 6e517779..753ae1d7 100644 --- a/hinghwa-dict-backend/word/migrations/0004_word_list.py +++ b/hinghwa-dict-backend/word/migrations/0004_word_list.py @@ -41,11 +41,19 @@ class Migration(migrations.Migration): verbose_name="ID", ), ), - ("createTime", models.DateTimeField(blank=True, verbose_name="创建时间")), - ("updateTime", models.DateTimeField(blank=True, verbose_name="更新时间")), + ( + "createTime", + models.DateTimeField(blank=True, verbose_name="创建时间"), + ), + ( + "updateTime", + models.DateTimeField(blank=True, verbose_name="更新时间"), + ), ( "description", - models.CharField(blank=True, max_length=100, verbose_name="词单简介"), + models.CharField( + blank=True, max_length=100, verbose_name="词单简介" + ), ), ( "author", diff --git a/hinghwa-dict-backend/word/models.py b/hinghwa-dict-backend/word/models.py index ab193c98..30f587d3 100644 --- a/hinghwa-dict-backend/word/models.py +++ b/hinghwa-dict-backend/word/models.py @@ -25,7 +25,9 @@ class Word(models.Model): annotation = models.TextField(verbose_name="附注", blank=True) mandarin = models.TextField(verbose_name="对应普通话词语", blank=True, default="[]") standard_ipa = models.CharField(max_length=100, verbose_name="标准IPA", blank=True) - standard_pinyin = models.CharField(max_length=100, verbose_name="标准拼音", blank=True) + standard_pinyin = models.CharField( + max_length=100, verbose_name="标准拼音", blank=True + ) views = models.IntegerField(default=0, verbose_name="访问量", editable=False) visibility = models.BooleanField(default=False, verbose_name="是否审核") related_words = models.ManyToManyField( @@ -69,7 +71,10 @@ class Application(models.Model): ) reason = models.CharField(max_length=200, blank=True, verbose_name="理由") contributor = models.ForeignKey( - User, on_delete=models.CASCADE, related_name="applications", verbose_name="贡献者" + User, + on_delete=models.CASCADE, + related_name="applications", + verbose_name="贡献者", ) verifier = models.ForeignKey( User, @@ -86,12 +91,17 @@ class Application(models.Model): annotation = models.TextField(verbose_name="附注", blank=True) mandarin = models.TextField(verbose_name="对应普通话词语", blank=True, default="[]") standard_ipa = models.CharField(max_length=30, verbose_name="标准IPA", blank=True) - standard_pinyin = models.CharField(max_length=30, verbose_name="标准拼音", blank=True) + standard_pinyin = models.CharField( + max_length=30, verbose_name="标准拼音", blank=True + ) related_words = models.ManyToManyField( Word, related_name="related_applications", verbose_name="相关词汇", blank=True ) related_articles = models.ManyToManyField( - Article, related_name="related_applications", verbose_name="相关帖子", blank=True + Article, + related_name="related_applications", + verbose_name="相关帖子", + blank=True, ) def granted(self): @@ -127,7 +137,10 @@ class Meta: class Pronunciation(models.Model): word = models.ForeignKey( - Word, on_delete=models.CASCADE, related_name="pronunciation", verbose_name="词语" + Word, + on_delete=models.CASCADE, + related_name="pronunciation", + verbose_name="词语", ) source = models.URLField(verbose_name="来源") ipa = models.CharField(max_length=50, verbose_name="ipa") @@ -212,7 +225,10 @@ class Meta: class List(models.Model): name = models.CharField(blank=True, max_length=30, verbose_name="词单名称") author = models.ForeignKey( - User, on_delete=models.CASCADE, related_name="list_words", verbose_name="词单作者" + User, + on_delete=models.CASCADE, + related_name="list_words", + verbose_name="词单作者", ) words = models.ManyToManyField( Word, diff --git a/hinghwa-dict-backend/word/pronunciation/dto/pronunciation_all.py b/hinghwa-dict-backend/word/pronunciation/dto/pronunciation_all.py index 78ec2bf8..7269b81c 100644 --- a/hinghwa-dict-backend/word/pronunciation/dto/pronunciation_all.py +++ b/hinghwa-dict-backend/word/pronunciation/dto/pronunciation_all.py @@ -17,13 +17,15 @@ def pronunciation_all(pronunciation: Pronunciation) -> dict: "county": pronunciation.county, "town": pronunciation.town, "visibility": pronunciation.visibility, - "verifier": { - "nickname": pronunciation.verifier.user_info.nickname, - "avatar": pronunciation.verifier.user_info.avatar, - "id": pronunciation.verifier.id, - } - if pronunciation.verifier - else None, + "verifier": ( + { + "nickname": pronunciation.verifier.user_info.nickname, + "avatar": pronunciation.verifier.user_info.avatar, + "id": pronunciation.verifier.id, + } + if pronunciation.verifier + else None + ), "granted": pronunciation.granted(), "upload_time": localtime(pronunciation.upload_time).strftime( "%Y-%m-%d %H:%M:%S" diff --git a/hinghwa-dict-backend/word/pronunciation/dto/pronunciation_normal.py b/hinghwa-dict-backend/word/pronunciation/dto/pronunciation_normal.py index aeecd696..8187cf7f 100644 --- a/hinghwa-dict-backend/word/pronunciation/dto/pronunciation_normal.py +++ b/hinghwa-dict-backend/word/pronunciation/dto/pronunciation_normal.py @@ -14,13 +14,15 @@ def pronunciation_normal(pronunciation: Pronunciation) -> dict: "county": pronunciation.county, "town": pronunciation.town, "visibility": pronunciation.visibility, - "verifier": { - "nickname": pronunciation.verifier.user_info.nickname, - "avatar": pronunciation.verifier.user_info.avatar, - "id": pronunciation.verifier.id, - } - if pronunciation.verifier - else None, + "verifier": ( + { + "nickname": pronunciation.verifier.user_info.nickname, + "avatar": pronunciation.verifier.user_info.avatar, + "id": pronunciation.verifier.id, + } + if pronunciation.verifier + else None + ), "granted": pronunciation.granted(), } return response diff --git a/hinghwa-dict-backend/word/pronunciation/urls.py b/hinghwa-dict-backend/word/pronunciation/urls.py index 86c19b8c..aebbf53c 100644 --- a/hinghwa-dict-backend/word/pronunciation/urls.py +++ b/hinghwa-dict-backend/word/pronunciation/urls.py @@ -15,8 +15,12 @@ path("/", csrf_exempt(ManagePronunciation.as_view())), path("/combine", combinePronunciationV2), path("/translate", translatePronunciation), - path("//visibility", csrf_exempt(ManageApproval.put)), # PUT PN0105 修改审核结果 - path("//examine", csrf_exempt(ManageApproval.as_view())), # POST PN0106 审核 + path( + "//visibility", csrf_exempt(ManageApproval.put) + ), # PUT PN0105 修改审核结果 + 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 1ad7bc94..0dd8a86c 100644 --- a/hinghwa-dict-backend/word/pronunciation/views.py +++ b/hinghwa-dict-backend/word/pronunciation/views.py @@ -469,7 +469,7 @@ def translatePronunciation(request): Arg( [ os.path.join(settings.MEDIA_ROOT, "audio", "temp"), - os.path.join(settings.SAVED_PINYIN, "submit") + os.path.join(settings.SAVED_PINYIN, "submit"), # os.path.join(settings.BASE_DIR, "AudioCompare", "submit") ] ) diff --git a/hinghwa-dict-backend/word/word/views.py b/hinghwa-dict-backend/word/word/views.py index e2fc4590..e383a7b0 100644 --- a/hinghwa-dict-backend/word/word/views.py +++ b/hinghwa-dict-backend/word/word/views.py @@ -449,5 +449,7 @@ def post(self, request) -> JsonResponse: ] if len(result) > 100: result = result[:100] - return JsonResponse({"words": result, "msg": "请求的词语太多了,请更精确一些"}, status=400) + return JsonResponse( + {"words": result, "msg": "请求的词语太多了,请更精确一些"}, status=400 + ) return JsonResponse({"words": result}, status=200)