diff --git a/CHANGELOG.md b/CHANGELOG.md index 26f6d41..1349845 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Unreleased +* Add wikidata ID and year for editions * Allow filtering by game, edition, purchase from the session list * Add icons for the above diff --git a/frontend/src/index.css b/frontend/src/index.css index cb1629e..0bd1c9a 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -14,7 +14,7 @@ textarea { #session-table { display: grid; - grid-template-columns: 3fr repeat(3, 1fr) 0.5fr 1fr; + grid-template-columns: 3fr 2fr repeat(2, 1fr) 0.5fr 1fr; } .purchase-name > span:nth-child(2) { diff --git a/games/forms.py b/games/forms.py index b67c294..3ca0138 100644 --- a/games/forms.py +++ b/games/forms.py @@ -147,7 +147,7 @@ class EditionForm(forms.ModelForm): class Meta: model = Edition - fields = ["game", "name", "sort_name", "platform", "year_released", "wikidata"] + fields = ["game", "name", "platform", "year_released", "wikidata"] class GameForm(forms.ModelForm): diff --git a/games/models.py b/games/models.py index 18d3c67..5799390 100644 --- a/games/models.py +++ b/games/models.py @@ -38,13 +38,9 @@ class Edition(models.Model): game = models.ForeignKey("Game", on_delete=models.CASCADE) name = models.CharField(max_length=255) - sort_name = models.CharField(max_length=255, null=True, blank=True, default=None) - platform = models.ForeignKey( - "Platform", on_delete=models.CASCADE, null=True, blank=True, default=None - ) - year_released = models.IntegerField(null=True, blank=True, default=None) + platform = models.ForeignKey("Platform", on_delete=models.CASCADE) + year_released = models.IntegerField(default=datetime.today().year) wikidata = models.CharField(max_length=50, null=True, blank=True, default=None) - created_at = models.DateTimeField(auto_now_add=True) def __str__(self): return self.sort_name @@ -134,27 +130,10 @@ class Purchase(models.Model): created_at = models.DateTimeField(auto_now_add=True) def __str__(self): - additional_info = [ - self.get_type_display() if self.type != Purchase.GAME else "", - f"{self.edition.platform} version on {self.platform}" - 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): - return self.type == self.GAME - - def save(self, *args, **kwargs): - if self.type == Purchase.GAME: - self.name = "" - elif self.type != Purchase.GAME and not self.related_purchase: - raise ValidationError( - f"{self.get_type_display()} must have a related purchase." - ) - super().save(*args, **kwargs) + platform_info = self.platform + if self.platform != self.edition.platform: + platform_info = f"{self.edition.platform} version on {self.platform}" + return f"{self.edition} ({platform_info}, {self.edition.year_released}, {self.get_ownership_type_display()})" class Platform(models.Model): diff --git a/games/templates/list_sessions.html b/games/templates/list_sessions.html index b3ae83f..2241c33 100644 --- a/games/templates/list_sessions.html +++ b/games/templates/list_sessions.html @@ -55,7 +55,15 @@ -
{{ data.purchase.platform }}
+
+ + {% if data.purchase.platform != data.purchase.edition.platform %} + {{data.purchase.edition.platform}} on {{ data.purchase.platform }} + {% else %} + {{ data.purchase.platform }} + {% endif %} + +
{{ data.timestamp_start | date:"d/m/Y H:i" }}
{% if data.unfinished %}