1
0
mirror of https://github.com/fspc/workstand.git synced 2025-02-23 01:13:22 -05:00

Display memberships.

This commit is contained in:
Drew Larson 2016-05-31 17:36:15 -06:00
parent bd186b04fa
commit af1130de04
3 changed files with 35 additions and 4 deletions

View File

@ -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 = (

View File

@ -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;

View File

@ -189,10 +189,33 @@
</div>
</form>
</div>
{% if not form.instance.membership %}
<div class="mdl-cell mdl-cell--8-col">
<h3>No membership found.</h3>
<a class="mdl-button mdl-js-button mdl-button--flat mdl-js-ripple-effect mdl-button--colored" href="{% url 'new_membership' member_id=member.id %}">Add membership</a>
{% if form.instance.memberships %}
<table class="mdl-data-table mdl-js-data-table">
<thead>
<tr>
<th class="mdl-data-table__cell--non-numeric">Renewed at</th>
<th class="mdl-data-table__cell--non-numeric">Created at</th>
<th class="mdl-data-table__cell--non-numeric">Expires at</th>
<th class="mdl-data-table__cell--non-numeric">Paid by</th>
</tr>
</thead>
<tbody>
<h3>Membership History</h3>
{% for membership in form.instance.memberships.all %}
<tr>
<td class="mdl-data-table__cell--non-numeric">{{ membership.renewed_at }}</td>
<td class="mdl-data-table__cell--non-numeric">{{ membership.created_at }}</td>
<td class="mdl-data-table__cell--non-numeric">{{ membership.expires_at }}</td>
<td class="mdl-data-table__cell--non-numeric">{{ membership.payment.type }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<h3>No membership found.</h3>
{% endif %}
<a class="mdl-button mdl-js-button mdl-button--flat mdl-js-ripple-effect mdl-button--colored" href="{% url 'new_membership' member_id=member.id %}">Add membership</a>
</div>
{% endif %}
{% endblock %}