Handle orphan cards
This commit is contained in:
parent
8f0b278dd4
commit
58b3e4bcc5
|
@ -422,10 +422,10 @@ class DoorViewSet(viewsets.ViewSet, List):
|
||||||
active_member_cards = {}
|
active_member_cards = {}
|
||||||
|
|
||||||
for card in cards:
|
for card in cards:
|
||||||
if card.user:
|
try:
|
||||||
member = card.user.member
|
|
||||||
else:
|
|
||||||
member = models.Member.objects.get(id=card.member_id)
|
member = models.Member.objects.get(id=card.member_id)
|
||||||
|
except models.Member.DoesNotExist:
|
||||||
|
continue
|
||||||
if member.paused_date: continue
|
if member.paused_date: continue
|
||||||
|
|
||||||
active_member_cards[card.card_number] = '{} ({})'.format(
|
active_member_cards[card.card_number] = '{} ({})'.format(
|
||||||
|
@ -441,10 +441,10 @@ class DoorViewSet(viewsets.ViewSet, List):
|
||||||
card.last_seen_at = utils.today_alberta_tz()
|
card.last_seen_at = utils.today_alberta_tz()
|
||||||
card.save()
|
card.save()
|
||||||
|
|
||||||
if card.user:
|
try:
|
||||||
member = card.user.member
|
|
||||||
else:
|
|
||||||
member = models.Member.objects.get(id=card.member_id)
|
member = models.Member.objects.get(id=card.member_id)
|
||||||
|
except models.Member.DoesNotExist:
|
||||||
|
raise Http404
|
||||||
t = utils.now_alberta_tz().strftime('%Y-%m-%d %H:%M:%S, %a %I:%M %p')
|
t = utils.now_alberta_tz().strftime('%Y-%m-%d %H:%M:%S, %a %I:%M %p')
|
||||||
logger.info('Time: {} - Name: {} {} ({})'.format(t, member.first_name, member.last_name, member.id))
|
logger.info('Time: {} - Name: {} {} ({})'.format(t, member.first_name, member.last_name, member.id))
|
||||||
|
|
||||||
|
@ -463,7 +463,10 @@ class LockoutViewSet(viewsets.ViewSet, List):
|
||||||
active_member_cards = {}
|
active_member_cards = {}
|
||||||
|
|
||||||
for card in cards:
|
for card in cards:
|
||||||
member = get_object_or_404(models.Member, id=card.member_id)
|
try:
|
||||||
|
member = models.Member.objects.get(id=card.member_id)
|
||||||
|
except models.Member.DoesNotExist:
|
||||||
|
continue
|
||||||
if member.paused_date: continue
|
if member.paused_date: continue
|
||||||
|
|
||||||
authorization = {}
|
authorization = {}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user