backend/app/events/services.py

14 lines
364 B
Python
Raw Normal View History

2022-10-08 19:31:01 +03:00
from rest_framework.generics import get_object_or_404
from events.models import EventAttendance
def submit_attendance(token: str):
attendance = get_object_or_404(EventAttendance, token=token)
if not attendance.attended:
attendance.attended = True
attendance.save()
attendance.event.attended += 1
attendance.event.save()