Skip to content

Commit 75a51f7

Browse files
authored
Merge pull request #11 from EventAccess/pr-fix-scanned-1
Fix API endpoint `scanned`
2 parents b026945 + 862d639 commit 75a51f7

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

backendapi/views.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
from django.shortcuts import render
2+
from django.views.decorators.csrf import csrf_exempt
23
from django.views.decorators.http import require_POST
34
from django.views.decorators.cache import never_cache
45
from django.http import JsonResponse
56

67
from database.models import Attendant
78

89

10+
@csrf_exempt
911
@require_POST
1012
@never_cache
1113
def scanned(request, tag: bytes):
1214
try:
13-
attendant = Attendant.objects.get(tag=tag)
15+
attendant = Attendant.objects.get(nfc_id=tag)
1416
# TODO: Queue event
1517
return JsonResponse({"valid": attendant.is_valid}, status=202)
1618

1719
except Attendant.DoesNotExist:
18-
return JsonResponse({"error": "No such tag"}, status=404)
20+
return JsonResponse({"error": "No such tag", "valid": False}, status=404)

config/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# SECURITY WARNING: don't run with debug turned on in production!
2626
DEBUG = True
2727

28-
ALLOWED_HOSTS = []
28+
ALLOWED_HOSTS = ["*"]
2929

3030

3131
# Application definition

0 commit comments

Comments
 (0)