适配Django 4.2
This commit is contained in:
parent
95da12f63a
commit
7c6be79974
2 changed files with 8 additions and 3 deletions
|
@ -21,9 +21,9 @@ class RunOrderAPI:
|
||||||
def run_order(self, data: RunOrderSchema):
|
def run_order(self, data: RunOrderSchema):
|
||||||
if data.level < 1 or data.level > 3:
|
if data.level < 1 or data.level > 3:
|
||||||
raise APIException("贸易站等级错误")
|
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("跑单技能错误")
|
raise APIException("跑单技能错误")
|
||||||
if data.level != 3 and data.skill == "t":
|
if data.level != 3 and data.skill == RunOrder.Tequila:
|
||||||
raise APIException("跑单技能与贸易站等级不匹配")
|
raise APIException("跑单技能与贸易站等级不匹配")
|
||||||
version = MowerVersion.objects.get_or_create(version=data.version)[0]
|
version = MowerVersion.objects.get_or_create(version=data.version)[0]
|
||||||
anonymous = AnonymousUser.objects.get_or_create(uuid=data.uuid)[0]
|
anonymous = AnonymousUser.objects.get_or_create(uuid=data.uuid)[0]
|
||||||
|
|
|
@ -10,7 +10,12 @@ class AnonymousUser(models.Model):
|
||||||
|
|
||||||
|
|
||||||
class RunOrder(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)
|
version = models.ForeignKey(MowerVersion, on_delete=models.CASCADE)
|
||||||
uuid = models.ForeignKey(AnonymousUser, on_delete=models.CASCADE)
|
uuid = models.ForeignKey(AnonymousUser, on_delete=models.CASCADE)
|
||||||
time = models.DateTimeField(auto_now_add=True)
|
time = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
Loading…
Reference in a new issue