def user_dnd(self, user_pk):
if 'DnD_' + str(user_pk) in cache.keys("DnD_*"):
#DnD = cache.get('DnD_' + str(user_pk))
DnD = True
else:
DnD = False
try:
event_start, event_end, instance = ScheduledOccurrence.objects.filter(event__in=ScheduledEvent.objects.filter(event=1, members__in=[user_pk])).next_occurrence()
NOW = datetime.datetime.now(datetime.timezone.utc).timestamp()
if NOW >= event_start.timestamp() and NOW <= event_end.timestamp():
DnD = True
cache.set('DnD_' + str(user_pk), DnD, timeout=event_end.timestamp())
except:
pass
return DnD
评论列表
文章目录