summaryrefslogtreecommitdiff
path: root/program/management/commands/update_programslots.py
blob: f0cc59ddd228de94e6715ed6a425bba64410f2a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from django.core.management.base import NoArgsCommand

from program.models import ProgramSlot

from datetime import date


class Command(NoArgsCommand):
    help = 'update programslots by setting is_active'

    def handle_noargs(self, **options):
        activated = 0
        deactivated = 0

        for programslot in ProgramSlot.objects.all():
            programslot.is_active = programslot.until > date.today()
            programslot.save()

            if programslot.is_active:
                activated += 1
            else:
                deactivated += 1

        print "%s program slots activated, %s program slots de-activated" % (activated, deactivated)