diff --git a/aanmelden/src/migrations/0022_userinfo_stripcard_expires.py b/aanmelden/src/migrations/0022_userinfo_stripcard_expires.py new file mode 100644 index 0000000..8023790 --- /dev/null +++ b/aanmelden/src/migrations/0022_userinfo_stripcard_expires.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.8 on 2024-08-09 10:47 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('src', '0021_alter_slot_name'), + ] + + operations = [ + migrations.AddField( + model_name='userinfo', + name='stripcard_expires', + field=models.DateField(default=datetime.date(2099, 1, 1)), + ), + ] diff --git a/aanmelden/src/models.py b/aanmelden/src/models.py index 9e7d352..70980c8 100644 --- a/aanmelden/src/models.py +++ b/aanmelden/src/models.py @@ -4,6 +4,7 @@ from django.contrib.auth import get_user_model from django.db import models from django.forms.models import model_to_dict +from django.utils import timezone DAY_NUMBERS = {"mon": 0, "tue": 1, "wed": 2, "thu": 3, "fri": 4, "sat": 5, "sun": 6} @@ -55,6 +56,9 @@ class UserInfo(models.Model): account_type = models.CharField(max_length=100, default="", null=False) stripcard_used = models.IntegerField(default=0, null=False) stripcard_count = models.IntegerField(default=0, null=False) + stripcard_expires = models.DateField( + default=timezone.datetime(year=2099, month=1, day=1).date(), null=False + ) def __str__(self): return f"User details for {self.user}" diff --git a/aanmelden/src/views.py b/aanmelden/src/views.py index aea105d..7b6d46f 100644 --- a/aanmelden/src/views.py +++ b/aanmelden/src/views.py @@ -85,6 +85,7 @@ def get(self, request, *args, **kwargs): if "stripcard_used" in user_profile: found_user.userinfo.stripcard_used = user_profile["stripcard_used"] found_user.userinfo.stripcard_count = user_profile["stripcard_count"] + found_user.userinfo.stripcard_expires = user_profile["stripcard_expires"] else: # No active stripcard -> reset counters found_user.userinfo.stripcard_used = 0 diff --git a/aanmelden/templates/main.html b/aanmelden/templates/main.html index 7f5d958..c5f5b5d 100644 --- a/aanmelden/templates/main.html +++ b/aanmelden/templates/main.html @@ -20,7 +20,7 @@ {{ user.userinfo.stripcard_used }} van de {{ user.userinfo.stripcard_count }} - keer gebruikt. + keer gebruikt en geldig tot {{ user.userinfo.stripcard_expires }}. {% endif %}