Correctly get next meetings when there's multiple
This commit is contained in:
parent
35dc736017
commit
6fa73af0be
|
@ -1,5 +1,7 @@
|
||||||
import time
|
import time
|
||||||
|
import datetime
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
|
from django.utils.timezone import now
|
||||||
from apiserver.api import models
|
from apiserver.api import models
|
||||||
|
|
||||||
DEFAULTS = {
|
DEFAULTS = {
|
||||||
|
@ -23,11 +25,13 @@ def changed_card():
|
||||||
def calc_next_events():
|
def calc_next_events():
|
||||||
sessions = models.Session.objects
|
sessions = models.Session.objects
|
||||||
|
|
||||||
member_meeting = sessions.filter(course=317).last()
|
member_meeting = sessions.filter(course=317, datetime__gte=now()).first()
|
||||||
monthly_clean = sessions.filter(course=273).last()
|
monthly_clean = sessions.filter(course=273, datetime__gte=now()).first()
|
||||||
|
|
||||||
cache.set('next_meeting', member_meeting.datetime)
|
if member_meeting:
|
||||||
cache.set('next_clean', monthly_clean.datetime)
|
cache.set('next_meeting', member_meeting.datetime)
|
||||||
|
if monthly_clean:
|
||||||
|
cache.set('next_clean', monthly_clean.datetime)
|
||||||
|
|
||||||
def calc_member_counts():
|
def calc_member_counts():
|
||||||
members = models.Member.objects
|
members = models.Member.objects
|
||||||
|
|
Loading…
Reference in New Issue
Block a user