Record time whenever cards change
This commit is contained in:
parent
f75b782afd
commit
668a0dd349
|
@ -1,5 +1,5 @@
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
from apiserver.api import models, utils
|
from apiserver.api import models, utils, utils_stats
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
@ -22,3 +22,5 @@ class Command(BaseCommand):
|
||||||
self.stdout.write('Tallied {} active members in {} s'.format(
|
self.stdout.write('Tallied {} active members in {} s'.format(
|
||||||
count, str(time.time() - start)
|
count, str(time.time() - start)
|
||||||
))
|
))
|
||||||
|
|
||||||
|
utils_stats.changed_card()
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from django.core.cache import cache
|
||||||
import time
|
import time
|
||||||
|
|
||||||
DEFAULTS = {
|
DEFAULTS = {
|
||||||
|
@ -10,3 +11,10 @@ DEFAULTS = {
|
||||||
'bay_108_temp': None,
|
'bay_108_temp': None,
|
||||||
'bay_110_temp': None,
|
'bay_110_temp': None,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def changed_card():
|
||||||
|
'''
|
||||||
|
Called whenever the card list could change, ie. cards added, modified, or
|
||||||
|
user status becoming overdue by 3 months
|
||||||
|
'''
|
||||||
|
cache.set('last_card_change', time.time())
|
||||||
|
|
|
@ -134,6 +134,7 @@ class MemberViewSet(Base, Retrieve, Update):
|
||||||
member.save()
|
member.save()
|
||||||
utils.tally_membership_months(member)
|
utils.tally_membership_months(member)
|
||||||
utils.gen_member_forms(member)
|
utils.gen_member_forms(member)
|
||||||
|
utils_stats.changed_card()
|
||||||
return Response(200)
|
return Response(200)
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,6 +143,14 @@ class CardViewSet(Base, Create, Retrieve, Update, Destroy):
|
||||||
queryset = models.Card.objects.all()
|
queryset = models.Card.objects.all()
|
||||||
serializer_class = serializers.CardSerializer
|
serializer_class = serializers.CardSerializer
|
||||||
|
|
||||||
|
def perform_create(self, serializer):
|
||||||
|
serializer.save()
|
||||||
|
utils_stats.changed_card()
|
||||||
|
|
||||||
|
def perform_update(self, serializer):
|
||||||
|
serializer.save()
|
||||||
|
utils_stats.changed_card()
|
||||||
|
|
||||||
|
|
||||||
class CourseViewSet(Base, List, Retrieve, Create, Update):
|
class CourseViewSet(Base, List, Retrieve, Create, Update):
|
||||||
permission_classes = [AllowMetadata | IsAuthenticated, IsAdminOrReadOnly | IsInstructorOrReadOnly]
|
permission_classes = [AllowMetadata | IsAuthenticated, IsAdminOrReadOnly | IsInstructorOrReadOnly]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user