diff --git a/CHANGELOG.md b/CHANGELOG.md index 787bd60..2f9e104 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Unreleased +* Add support for purchase ownership information (https://git.kucharczyk.xyz/lukas/timetracker/issues/48) * Add support for purchase prices * Add support for game editions (https://git.kucharczyk.xyz/lukas/timetracker/issues/28) diff --git a/games/forms.py b/games/forms.py index 3c28af0..08662ea 100644 --- a/games/forms.py +++ b/games/forms.py @@ -32,6 +32,7 @@ class PurchaseForm(forms.ModelForm): "date_refunded", "price", "price_currency", + "ownership_type", ] diff --git a/games/migrations/0013_purchase_ownership_type.py b/games/migrations/0013_purchase_ownership_type.py new file mode 100644 index 0000000..02a3a23 --- /dev/null +++ b/games/migrations/0013_purchase_ownership_type.py @@ -0,0 +1,31 @@ +# Generated by Django 4.1.5 on 2023-02-18 19:54 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("games", "0012_purchase_price_purchase_price_currency"), + ] + + operations = [ + migrations.AddField( + model_name="purchase", + name="ownership_type", + field=models.CharField( + choices=[ + ("ph", "Physical"), + ("di", "Digital"), + ("du", "Digital Upgrade"), + ("re", "Rented"), + ("bo", "Borrowed"), + ("tr", "Trial"), + ("de", "Demo"), + ("pi", "Pirated"), + ], + default="di", + max_length=2, + ), + ), + ] diff --git a/games/models.py b/games/models.py index b9d8e44..6070c4a 100644 --- a/games/models.py +++ b/games/models.py @@ -26,12 +26,34 @@ class Edition(models.Model): class Purchase(models.Model): + PHYSICAL = "ph" + DIGITAL = "di" + DIGITALUPGRADE = "du" + RENTED = "re" + BORROWED = "bo" + TRIAL = "tr" + DEMO = "de" + PIRATED = "pi" + OWNERSHIP_TYPES = [ + (PHYSICAL, "Physical"), + (DIGITAL, "Digital"), + (DIGITALUPGRADE, "Digital Upgrade"), + (RENTED, "Rented"), + (BORROWED, "Borrowed"), + (TRIAL, "Trial"), + (DEMO, "Demo"), + (PIRATED, "Pirated"), + ] + edition = models.ForeignKey("Edition", on_delete=models.CASCADE) 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") + ownership_type = models.CharField( + max_length=2, choices=OWNERSHIP_TYPES, default=DIGITAL + ) def __str__(self): return f"{self.edition} ({self.platform})"