Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/django_program/manage/views_checkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 8 additions & 5 deletions src/django_program/registration/views_checkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""

import json
import logging

from django.db.models import Count, Prefetch
from django.http import HttpRequest, HttpResponse, JsonResponse
Expand All @@ -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.
Expand Down Expand Up @@ -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):
Expand Down
Loading