diff --git a/games/forms.py b/games/forms.py index b67c294..29f1009 100644 --- a/games/forms.py +++ b/games/forms.py @@ -83,6 +83,7 @@ class PurchaseForm(forms.ModelForm): "date_purchased": custom_date_widget, "date_refunded": custom_date_widget, "date_finished": custom_date_widget, + "date_dropped": custom_date_widget, } model = Purchase fields = [ @@ -91,6 +92,8 @@ class PurchaseForm(forms.ModelForm): "date_purchased", "date_refunded", "date_finished", + "date_dropped", + "infinite", "price", "price_currency", "ownership_type", diff --git a/games/migrations/0034_purchase_date_dropped_purchase_infinite.py b/games/migrations/0034_purchase_date_dropped_purchase_infinite.py new file mode 100644 index 0000000..8ac5087 --- /dev/null +++ b/games/migrations/0034_purchase_date_dropped_purchase_infinite.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.7 on 2024-01-03 21:27 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("games", "0033_alter_edition_unique_together"), + ] + + operations = [ + migrations.AddField( + model_name="purchase", + name="date_dropped", + field=models.DateField(blank=True, null=True), + ), + migrations.AddField( + model_name="purchase", + name="infinite", + field=models.BooleanField(default=False), + ), + ] diff --git a/games/models.py b/games/models.py index 1b23611..574d461 100644 --- a/games/models.py +++ b/games/models.py @@ -116,6 +116,8 @@ class Purchase(models.Model): date_purchased = models.DateField() date_refunded = models.DateField(blank=True, null=True) date_finished = models.DateField(blank=True, null=True) + date_dropped = models.DateField(blank=True, null=True) + infinite = models.BooleanField(default=False) price = models.IntegerField(default=0) price_currency = models.CharField(max_length=3, default="USD") ownership_type = models.CharField( diff --git a/games/templates/stats.html b/games/templates/stats.html index befb63d..290a92e 100644 --- a/games/templates/stats.html +++ b/games/templates/stats.html @@ -205,6 +205,33 @@ {% endfor %} + +

Unfinished Purchases

+ + + + + + + + + + {% for purchase in purchased_unfinished %} + + + + + + {% endfor %} + +
NamePrice ({{ total_spent_currency }})Date
+ + {{ purchase.edition.name }} + {% if purchase.type == "dlc" %}({{ purchase.name }}, {{ purchase.get_type_display }}){% endif %} + + {{ purchase.price }}{{ purchase.date_purchased | date:"d/m/Y" }}
+

All Purchases

diff --git a/games/views.py b/games/views.py index cc326f9..9d7b29b 100644 --- a/games/views.py +++ b/games/views.py @@ -362,10 +362,11 @@ def stats(request, year: int = 0): ) this_year_purchases_refunded = this_year_purchases_with_currency.refunded() - this_year_purchases_unfinished = this_year_purchases_without_refunded.filter( - date_finished__isnull=True - ).filter( - Q(type=Purchase.GAME) | Q(type=Purchase.DLC) + this_year_purchases_unfinished = ( + this_year_purchases_without_refunded.filter(date_finished__isnull=True) + .filter(date_dropped__isnull=True) + .filter(infinite=False) + .filter(Q(type=Purchase.GAME) | Q(type=Purchase.DLC)) ) # do not count battle passes etc. this_year_purchases_without_refunded_count = (