diff --git a/bikeshop_project/assets/js/components/SignIn.jsx b/bikeshop_project/assets/js/components/SignIn.jsx
index 34bea38..9abb834 100644
--- a/bikeshop_project/assets/js/components/SignIn.jsx
+++ b/bikeshop_project/assets/js/components/SignIn.jsx
@@ -2,11 +2,21 @@ import fetch from 'isomorphic-fetch';
import moment from 'moment';
import React from 'react';
import RaisedButton from 'material-ui/RaisedButton';
+import Dialog from 'material-ui/Dialog';
import Member from './Member';
import Purpose from './Purpose';
import SignedInList from './SignedInList';
+const renderMemberStatus = member => {
+ if (member.banned) {
+ return
@@ -148,6 +198,38 @@ export default class SignIn extends React.Component {
+ {this.state.modal.member &&
+
]}
+ >
+
+ {renderMemberStatus(member)}
+
+ { member.notes &&
+
+
Notes
+
{member.notes}
+
+ }
+
+
Membership Details
+ {!member.membership
+ ?
No membership 😿
+ :
+ - Renewed
- {member.membership.renewed_at.format('MMMM Do, YYYY')} ({member.membership.renewed_at.fromNow()})
+ - {member.membership.expires_at.isAfter()
+ ? 'Expires'
+ : 'Expired'}
+
+ - {member.membership.expires_at.format('MMMM Do, YYYY')} ({member.membership.expires_at.fromNow()})
+
+ }
+
+
+ }
);
}
diff --git a/bikeshop_project/registration/views.py b/bikeshop_project/registration/views.py
index 0ea34a3..18cbd37 100644
--- a/bikeshop_project/registration/views.py
+++ b/bikeshop_project/registration/views.py
@@ -1,6 +1,7 @@
import json
from django.contrib.auth.decorators import login_required
+from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
from django.http import HttpResponse, HttpResponseRedirect, JsonResponse
from django.shortcuts import get_object_or_404
@@ -13,7 +14,7 @@ from rest_framework import viewsets
from rest_framework.renderers import JSONRenderer
from rest_framework.serializers import ModelSerializer
-from core.models import Visit
+from core.models import Visit, Membership
from registration.utils import signin_member, get_signed_in_members
from .serializers import MemberSerializer
from .forms import MemberForm
@@ -83,9 +84,16 @@ class MemberSignIn(View):
def post(self, request):
member = get_object_or_404(Member, id=request.POST.get('id'))
visit = signin_member(member, request.POST.get('purpose'))
+ try:
+ membership = Membership.objects.select_related('payment').filter(member=member).last()
+ except ObjectDoesNotExist:
+ membership = None
+ membership_dict = dict(renewed_at=membership.renewed_at, payment=membership.payment.type,
+ expires_at=membership.expires_at) if membership else None
data = dict(results=dict(id=member.id, first_name=member.first_name, last_name=member.last_name,
suspended=member.suspended, banned=member.banned,
- created_at=visit.created_at.isoformat()))
+ created_at=visit.created_at.isoformat(), notes=member.notes,
+ membership=membership_dict))
return JsonResponse(data=data, safe=False, status=201)