Improve purchase __str__
This commit is contained in:
parent
62cd17f702
commit
cce810e8cf
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## Improved
|
## Improved
|
||||||
* Disallow choosing non-game purchase as related purchase
|
* Disallow choosing non-game purchase as related purchase
|
||||||
|
* Improve display of purchases
|
||||||
|
|
||||||
## 1.5.0 / 2023-11-14 19:27+01:00
|
## 1.5.0 / 2023-11-14 19:27+01:00
|
||||||
|
|
||||||
|
|
|
@ -128,10 +128,15 @@ class Purchase(models.Model):
|
||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
platform_info = self.platform
|
additional_info = [
|
||||||
if self.platform != self.edition.platform:
|
self.get_type_display() if self.type != Purchase.GAME else "",
|
||||||
platform_info = f"{self.edition.platform} version on {self.platform}"
|
f"{self.edition.platform} version on {self.platform}"
|
||||||
return f"{self.edition} ({platform_info}, {self.edition.year_released}, {self.get_ownership_type_display()})"
|
if self.platform != self.edition.platform
|
||||||
|
else self.platform,
|
||||||
|
self.edition.year_released,
|
||||||
|
self.get_ownership_type_display(),
|
||||||
|
]
|
||||||
|
return f"{self.edition} ({', '.join(filter(None, map(str, additional_info)))})"
|
||||||
|
|
||||||
def is_game(self):
|
def is_game(self):
|
||||||
return self.type == self.GAME
|
return self.type == self.GAME
|
||||||
|
|
Loading…
Reference in New Issue