blob: 0dafb8837cb47a44bb6aff5f75e8398cc64c1f28 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
from django.core.management.base import NoArgsCommand
from program.models import Show
from datetime import datetime
class Command(NoArgsCommand):
help = 'update shows by setting is_active'
def handle_noargs(self, **options):
deactivated = Show.objects.exclude(id=1).filter(programslots__until__lt=datetime.now()).update(is_active=False)
activated = Show.objects.exclude(id=1).filter(programslots__until__gt=datetime.now()).distinct().update(is_active=True)
print "%s shows activated, %s shows de-activated" % (activated, deactivated)
|