set edition platform to unspecified if none
This commit is contained in:
parent
2ae81bb00f
commit
9992d9c9bd
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue