mirror of
https://github.com/fspc/workstand.git
synced 2025-02-23 09:13:23 -05:00
Display memberships.
This commit is contained in:
parent
bd186b04fa
commit
af1130de04
@ -1,5 +1,8 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from django.utils.functional import cached_property
|
||||||
|
|
||||||
|
from dateutil.relativedelta import relativedelta
|
||||||
|
|
||||||
|
|
||||||
class Membership(models.Model):
|
class Membership(models.Model):
|
||||||
@ -24,6 +27,10 @@ class Membership(models.Model):
|
|||||||
null=True
|
null=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def expires_at(self):
|
||||||
|
return self.renewed_at + relativedelta(years=1)
|
||||||
|
|
||||||
|
|
||||||
class Payment(models.Model):
|
class Payment(models.Model):
|
||||||
payment_choices = (
|
payment_choices = (
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
@import "vendor/material-design-lite/src/palette/palette";
|
@import "vendor/material-design-lite/src/palette/palette";
|
||||||
@import "vendor/material-design-lite/src/menu/menu";
|
@import "vendor/material-design-lite/src/menu/menu";
|
||||||
@import "vendor/material-design-lite/src/card/card";
|
@import "vendor/material-design-lite/src/card/card";
|
||||||
|
@import "vendor/material-design-lite/src/data-table/data-table";
|
||||||
|
|
||||||
html, body {
|
html, body {
|
||||||
font-family: 'Roboto', 'Helvetica', sans-serif;
|
font-family: 'Roboto', 'Helvetica', sans-serif;
|
||||||
|
@ -189,10 +189,33 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% if not form.instance.membership %}
|
|
||||||
<div class="mdl-cell mdl-cell--8-col">
|
<div class="mdl-cell mdl-cell--8-col">
|
||||||
<h3>No membership found.</h3>
|
{% if form.instance.memberships %}
|
||||||
<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>
|
<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>
|
</div>
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user