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)