diff --git a/src/django_program/manage/views_checkin.py b/src/django_program/manage/views_checkin.py index 6b98213..d00cd9f 100644 --- a/src/django_program/manage/views_checkin.py +++ b/src/django_program/manage/views_checkin.py @@ -62,7 +62,7 @@ def get_context_data(self, **kwargs: object) -> dict[str, object]: context["active_nav"] = "checkin" total_attendees = Attendee.objects.filter(conference=conference).count() - checked_in_count = Attendee.objects.filter(conference=conference, checkins__isnull=False).distinct().count() + checked_in_count = Attendee.objects.filter(conference=conference, checked_in_at__isnull=False).count() check_in_rate = round((checked_in_count / total_attendees * 100), 1) if total_attendees > 0 else 0 today_start = timezone.now().replace(hour=0, minute=0, second=0, microsecond=0) diff --git a/src/django_program/registration/views_checkin.py b/src/django_program/registration/views_checkin.py index 381d7e7..6970265 100644 --- a/src/django_program/registration/views_checkin.py +++ b/src/django_program/registration/views_checkin.py @@ -7,7 +7,6 @@ """ import json -import logging from django.db.models import Count, Prefetch from django.http import HttpRequest, HttpResponse, JsonResponse @@ -20,8 +19,6 @@ from django_program.registration.models import Order, OrderLineItem from django_program.registration.services.checkin import CheckInService, RedemptionService -logger = logging.getLogger(__name__) - class StaffRequiredMixin: """Require staff or superuser access for check-in API views. @@ -100,11 +97,17 @@ def _get_ticket_type_name(order: Order | None) -> str: def _parse_json_body(request: HttpRequest) -> dict[str, object] | None: - """Parse JSON from request body, returning None on failure.""" + """Parse JSON from request body, returning None on failure. + + Returns None if the body is not valid JSON or is not an object (dict). + """ try: - return json.loads(request.body) # type: ignore[no-any-return] + payload = json.loads(request.body) except (json.JSONDecodeError, ValueError): return None + if not isinstance(payload, dict): + return None + return payload class ScanView(StaffRequiredMixin, View):