diff --git a/bikeshop_project/core/models.py b/bikeshop_project/core/models.py index 828ea8c..f26f45e 100644 --- a/bikeshop_project/core/models.py +++ b/bikeshop_project/core/models.py @@ -1,5 +1,8 @@ from django.db import models from django.utils import timezone +from django.utils.functional import cached_property + +from dateutil.relativedelta import relativedelta class Membership(models.Model): @@ -24,6 +27,10 @@ class Membership(models.Model): null=True ) + @cached_property + def expires_at(self): + return self.renewed_at + relativedelta(years=1) + class Payment(models.Model): payment_choices = ( diff --git a/bikeshop_project/core/static/scss/screen.scss b/bikeshop_project/core/static/scss/screen.scss index 3c91d7b..dcf06ef 100644 --- a/bikeshop_project/core/static/scss/screen.scss +++ b/bikeshop_project/core/static/scss/screen.scss @@ -12,6 +12,7 @@ @import "vendor/material-design-lite/src/palette/palette"; @import "vendor/material-design-lite/src/menu/menu"; @import "vendor/material-design-lite/src/card/card"; +@import "vendor/material-design-lite/src/data-table/data-table"; html, body { font-family: 'Roboto', 'Helvetica', sans-serif; diff --git a/bikeshop_project/registration/templates/edit_member_form.html b/bikeshop_project/registration/templates/edit_member_form.html index a89749c..90f3cc2 100644 --- a/bikeshop_project/registration/templates/edit_member_form.html +++ b/bikeshop_project/registration/templates/edit_member_form.html @@ -189,10 +189,33 @@ - {% if not form.instance.membership %}
-

No membership found.

- Add membership + {% if form.instance.memberships %} + + + + + + + + + + +

Membership History

+ {% for membership in form.instance.memberships.all %} + + + + + + + {% endfor %} + +
Renewed atCreated atExpires atPaid by
{{ membership.renewed_at }}{{ membership.created_at }}{{ membership.expires_at }}{{ membership.payment.type }}
+ {% else %} +

No membership found.

+ {% endif %} + Add membership
- {% endif %} + {% endblock %}