适配Django 4.2

This commit is contained in:
zhbaor 2023-12-13 04:53:00 +00:00
parent 95da12f63a
commit 7c6be79974
2 changed files with 8 additions and 3 deletions

View file

@ -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]

View file

@ -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)