set edition platform to unspecified if none

This commit is contained in:
Lukáš Kucharczyk 2024-10-16 18:06:40 +02:00
parent 2ae81bb00f
commit 9992d9c9bd
Signed by: lukas
SSH Key Fingerprint: SHA256:vMuSwvwAvcT6htVAioMP7rzzwMQNi3roESyhv+nAxeg
1 changed files with 11 additions and 0 deletions

View File

@ -38,6 +38,12 @@ class Platform(models.Model):
super().save(*args, **kwargs)
def get_sentinel_platform():
return Platform.objects.get_or_create(
name="Unspecified", icon="unspecified", group="Unspecified"
)[0]
class Edition(models.Model):
class Meta:
unique_together = [["name", "platform", "year_released"]]
@ -55,6 +61,11 @@ class Edition(models.Model):
def __str__(self):
return self.sort_name
def save(self, *args, **kwargs):
if self.platform is None:
self.platform = get_sentinel_platform()
super().save(*args, **kwargs)
class PurchaseQueryset(models.QuerySet):
def refunded(self):