Commit 0b6a759a6ebb04588330d00f5f7d5664c9981f54

Authored by Rohan Rangray
1 parent 5a20f17939
Exists in master

Fixed error in notify_users management command

Showing 1 changed file with 1 additions and 1 deletions Inline Diff

flashcards/management/commands/notifyusers.py View file @ 0b6a759
from django.core.management import BaseCommand 1 1 from django.core.management import BaseCommand
from flashcards.models import UserFlashcard, Now 2 2 from flashcards.models import UserFlashcard, Now
from django.utils.timezone import now 3 3 from django.utils.timezone import now
from datetime import timedelta 4 4 from datetime import timedelta
5 5
6 6
class Command(BaseCommand): 7 7 class Command(BaseCommand):
help = 'Notify the users if they have cards to be reviewed' 8 8 help = 'Notify the users if they have cards to be reviewed'
9 9
def handle(self, *args, **options): 10 10 def handle(self, *args, **options):
notify_list = UserFlashcard.objects.filter( 11 11 notify_list = UserFlashcard.objects.filter(
next_review__lte=Now() 12 12 next_review__lte=Now()
).exclude( 13 13 ).exclude(
user__registration_id=None, 14 14 user__registration_id=None,
user__last_notified__range=(now()-timedelta(days=1), now()) 15 15 user__last_notified__range=(now()-timedelta(days=1), now())
).values_list('user').distinct().all() 16 16 ).values_list('user').distinct().all()