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 93db2a2..d567aac 100644 --- a/games/forms.py +++ b/games/forms.py @@ -40,7 +40,7 @@ class PurchaseForm(forms.ModelForm): class EditionForm(forms.ModelForm): class Meta: model = Edition - fields = ["game", "name", "platform"] + fields = ["game", "name", "platform", "year_released", "wikidata"] class GameForm(forms.ModelForm): diff --git a/games/migrations/0015_edition_wikidata_edition_year_released.py b/games/migrations/0015_edition_wikidata_edition_year_released.py new file mode 100644 index 0000000..8b89f94 --- /dev/null +++ b/games/migrations/0015_edition_wikidata_edition_year_released.py @@ -0,0 +1,23 @@ +# Generated by Django 4.1.5 on 2023-02-20 14:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("games", "0014_device_session_device"), + ] + + operations = [ + migrations.AddField( + model_name="edition", + name="wikidata", + field=models.CharField(blank=True, default=None, max_length=50, null=True), + ), + migrations.AddField( + model_name="edition", + name="year_released", + field=models.IntegerField(default=2023), + ), + ] diff --git a/games/models.py b/games/models.py index 7866473..860cf82 100644 --- a/games/models.py +++ b/games/models.py @@ -20,6 +20,8 @@ class Edition(models.Model): game = models.ForeignKey("Game", on_delete=models.CASCADE) name = models.CharField(max_length=255) 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) def __str__(self): return self.name @@ -56,7 +58,10 @@ class Purchase(models.Model): ) def __str__(self): - return f"{self.edition} ({self.platform}, {self.get_ownership_type_display()})" + 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 ba4afc1..cf9ee44 100644 --- a/games/templates/list_sessions.html +++ b/games/templates/list_sessions.html @@ -56,7 +56,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 %}