doorcontrol: Grant instructors access for ~1 hour around their class times
Also the required foundation for #14
This commit is contained in:
parent
d8e6a69719
commit
12271ef327
@ -1,7 +1,10 @@
|
||||
import dataclasses
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
from typing import TypedDict
|
||||
|
||||
from django.utils import timezone
|
||||
|
||||
from django_q.tasks import async_task
|
||||
|
||||
from cmsmanage.django_q2_helper import q_task_group
|
||||
@ -62,6 +65,17 @@ class DoorMember:
|
||||
if getattr(member, attribute_rule.access_field)
|
||||
}
|
||||
|
||||
# grant instructors access for ~1 hour around their class times
|
||||
if hasattr(member, "eventinstructor") and getattr(member, door.access_field):
|
||||
now = timezone.now()
|
||||
margin = timedelta(hours=1)
|
||||
if member.eventinstructor.eventext_set.filter(
|
||||
occurred=True,
|
||||
meeting_times__start__lt=now + margin,
|
||||
meeting_times__end__gt=now - margin,
|
||||
).exists():
|
||||
reasons_and_schedules["Instructor for Active Class"] = "Unlimited"
|
||||
|
||||
reasons = sorted(reasons_and_schedules.keys())
|
||||
|
||||
return cls(
|
||||
|
Loading…
Reference in New Issue
Block a user