Retally membership months on any transaction change

This commit is contained in:
Tanner Collin 2020-01-19 08:59:16 +00:00
parent 73b6d19c19
commit 712a6c533f
2 changed files with 12 additions and 2 deletions

View File

@ -9,7 +9,7 @@ from rest_auth.registration.views import RegisterView
from fuzzywuzzy import fuzz, process
from collections import OrderedDict
from . import models, serializers
from . import models, serializers, utils
class AllowMetadata(BasePermission):
def has_permission(self, request, view):
@ -197,8 +197,18 @@ class TransactionViewSet(Base, Create, Retrieve, Update):
queryset = models.Transaction.objects.all()
serializer_class = serializers.TransactionSerializer
def retally_membership(self):
member_id = self.request.data['member_id']
member = get_object_or_404(models.Member, id=member_id)
utils.tally_membership_months(member)
def perform_create(self, serializer):
serializer.save(recorder=self.request.user)
self.retally_membership()
def perform_update(self, serializer):
serializer.save()
self.retally_membership()
class UserView(views.APIView):

View File

@ -40,7 +40,7 @@ function ClassTable(props) {
</Table.Row>
)
:
<p>None</p>
<Table.Row><Table.Cell>None</Table.Cell></Table.Row>
}
</Table.Body>
</Table>