From 622c52bb2041dea8098ce712d32cc8404df6faab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Sat, 18 Feb 2023 20:53:47 +0100 Subject: [PATCH] Add support for prices on purchases --- CHANGELOG.md | 1 + games/forms.py | 9 +++++++- ..._purchase_price_purchase_price_currency.py | 23 +++++++++++++++++++ games/models.py | 2 ++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 games/migrations/0012_purchase_price_purchase_price_currency.py diff --git a/CHANGELOG.md b/CHANGELOG.md index a51ab95..787bd60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Unreleased +* Add support for purchase prices * Add support for game editions (https://git.kucharczyk.xyz/lukas/timetracker/issues/28) ## 1.0.1 / 2023-01-30 22:17+01:00 diff --git a/games/forms.py b/games/forms.py index 708a6c3..3c28af0 100644 --- a/games/forms.py +++ b/games/forms.py @@ -25,7 +25,14 @@ class PurchaseForm(forms.ModelForm): class Meta: model = Purchase - fields = ["edition", "platform", "date_purchased", "date_refunded"] + fields = [ + "edition", + "platform", + "date_purchased", + "date_refunded", + "price", + "price_currency", + ] class EditionForm(forms.ModelForm): diff --git a/games/migrations/0012_purchase_price_purchase_price_currency.py b/games/migrations/0012_purchase_price_purchase_price_currency.py new file mode 100644 index 0000000..6124f25 --- /dev/null +++ b/games/migrations/0012_purchase_price_purchase_price_currency.py @@ -0,0 +1,23 @@ +# Generated by Django 4.1.5 on 2023-02-18 19:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("games", "0011_rename_game_purchase_edition"), + ] + + operations = [ + migrations.AddField( + model_name="purchase", + name="price", + field=models.IntegerField(default=0), + ), + migrations.AddField( + model_name="purchase", + name="price_currency", + field=models.CharField(default="USD", max_length=3), + ), + ] diff --git a/games/models.py b/games/models.py index 7969df4..b9d8e44 100644 --- a/games/models.py +++ b/games/models.py @@ -30,6 +30,8 @@ class Purchase(models.Model): platform = models.ForeignKey("Platform", on_delete=models.CASCADE) date_purchased = models.DateField() date_refunded = models.DateField(blank=True, null=True) + price = models.IntegerField(default=0) + price_currency = models.CharField(max_length=3, default="USD") def __str__(self): return f"{self.edition} ({self.platform})"