Browse Source

Display memberships.

feature/python-error-tracking
Drew Larson 9 years ago
parent
commit
af1130de04
  1. 7
      bikeshop_project/core/models.py
  2. 1
      bikeshop_project/core/static/scss/screen.scss
  3. 27
      bikeshop_project/registration/templates/edit_member_form.html

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

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

27
bikeshop_project/registration/templates/edit_member_form.html

@ -189,10 +189,33 @@
</div>
</form>
</div>
{% if not form.instance.membership %}
<div class="mdl-cell mdl-cell--8-col">
{% 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 %}

Loading…
Cancel
Save