From 7c6be79974bd637fdec122e9d252b84df21eda72 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Wed, 13 Dec 2023 04:53:00 +0000 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8DDjango=204.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- run_order/api.py | 4 ++-- run_order/models.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/run_order/api.py b/run_order/api.py index babdb45..2a64f6a 100644 --- a/run_order/api.py +++ b/run_order/api.py @@ -21,9 +21,9 @@ class RunOrderAPI: def run_order(self, data: RunOrderSchema): if data.level < 1 or data.level > 3: raise APIException("贸易站等级错误") - if data.skill not in RunOrder.SKILL_CHOICES: + if data.skill not in [i[0] for i in RunOrder.SKILL_CHOICES]: raise APIException("跑单技能错误") - if data.level != 3 and data.skill == "t": + if data.level != 3 and data.skill == RunOrder.Tequila: raise APIException("跑单技能与贸易站等级不匹配") version = MowerVersion.objects.get_or_create(version=data.version)[0] anonymous = AnonymousUser.objects.get_or_create(uuid=data.uuid)[0] diff --git a/run_order/models.py b/run_order/models.py index 22f2182..3f65bc0 100644 --- a/run_order/models.py +++ b/run_order/models.py @@ -10,7 +10,12 @@ class AnonymousUser(models.Model): class RunOrder(models.Model): - SKILL_CHOICES = {"p": "但书", "t": "龙舌兰"} + Proviso = "p" + Tequila = "t" + SKILL_CHOICES = [ + ("p", "但书"), + ("t", "龙舌兰"), + ] version = models.ForeignKey(MowerVersion, on_delete=models.CASCADE) uuid = models.ForeignKey(AnonymousUser, on_delete=models.CASCADE) time = models.DateTimeField(auto_now_add=True)