18 lines
511 B
Python
18 lines
511 B
Python
"""Helper for recording activity events from views/services."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Optional
|
|
|
|
from apps.enrollments.models import ActivityEvent, ActivityKind
|
|
|
|
|
|
def record_event(*, course, actor, kind: str, payload: Optional[dict] = None) -> ActivityEvent:
|
|
"""Create an ActivityEvent. `kind` must be one of ActivityKind.values."""
|
|
return ActivityEvent.objects.create(
|
|
course=course,
|
|
actor=actor,
|
|
kind=kind,
|
|
payload=payload or {},
|
|
)
|