Return alarm light value over /stats/ API
This commit is contained in:
parent
750eed0fb6
commit
d990a64efb
|
@ -25,6 +25,7 @@ DEFAULTS = {
|
||||||
'mumble_users': [],
|
'mumble_users': [],
|
||||||
'card_scans': 0,
|
'card_scans': 0,
|
||||||
'track': {},
|
'track': {},
|
||||||
|
'alarm': {},
|
||||||
}
|
}
|
||||||
|
|
||||||
def changed_card():
|
def changed_card():
|
||||||
|
|
|
@ -462,6 +462,11 @@ class StatsViewSet(viewsets.ViewSet, List):
|
||||||
cached_stats = cache.get_many(stats_keys)
|
cached_stats = cache.get_many(stats_keys)
|
||||||
stats = utils_stats.DEFAULTS.copy()
|
stats = utils_stats.DEFAULTS.copy()
|
||||||
stats.update(cached_stats)
|
stats.update(cached_stats)
|
||||||
|
|
||||||
|
user = self.request.user
|
||||||
|
if not user.is_authenticated or not user.member.vetted_date:
|
||||||
|
stats.pop('alarm', None)
|
||||||
|
|
||||||
return Response(stats)
|
return Response(stats)
|
||||||
|
|
||||||
@action(detail=False, methods=['post'])
|
@action(detail=False, methods=['post'])
|
||||||
|
@ -487,8 +492,8 @@ class StatsViewSet(viewsets.ViewSet, List):
|
||||||
@action(detail=False, methods=['post'])
|
@action(detail=False, methods=['post'])
|
||||||
def alarm(self, request):
|
def alarm(self, request):
|
||||||
try:
|
try:
|
||||||
logging.info('Alarm value: ' + str(request.data['data']))
|
alarm = dict(time=time.time(), data=int(request.data['data']))
|
||||||
#cache.set('alarm', int(request.data['data']))
|
cache.set('alarm', alarm)
|
||||||
return Response(200)
|
return Response(200)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise exceptions.ValidationError(dict(data='Invalid integer.'))
|
raise exceptions.ValidationError(dict(data='Invalid integer.'))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user