Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show stripcard expiration date in main view #76

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions aanmelden/src/migrations/0022_userinfo_stripcard_expires.py
Original file line number Diff line number Diff line change
@@ -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)),
),
]
4 changes: 4 additions & 0 deletions aanmelden/src/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down Expand Up @@ -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}"
Expand Down
1 change: 1 addition & 0 deletions aanmelden/src/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion aanmelden/templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<strong>{{ user.userinfo.stripcard_used }}</strong>
van de
<strong>{{ user.userinfo.stripcard_count }}</strong>
keer gebruikt.
keer gebruikt en geldig tot <strong>{{ user.userinfo.stripcard_expires }}</strong>.
</div>
{% endif %}

Expand Down
Loading