diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-04-15 18:41:03 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-04-15 18:41:03 (GMT) |
commit | 17f110df8c14ea258d9227d08471a4a82bfa4657 (patch) | |
tree | f2aaf3e4bbf132fa3d0fbbbafca88a420f8225a7 /program/management/commands/update_shows.py | |
parent | 1d521e1c65babb8412b4959bd476596e0aa36aa6 (diff) | |
parent | 179a462bf561dc0cb4d19133e7e3684055278296 (diff) |
merged master into stable after new deployment
Diffstat (limited to 'program/management/commands/update_shows.py')
-rw-r--r-- | program/management/commands/update_shows.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/program/management/commands/update_shows.py b/program/management/commands/update_shows.py new file mode 100644 index 0000000..a337f21 --- /dev/null +++ b/program/management/commands/update_shows.py @@ -0,0 +1,29 @@ +from django.core.management.base import NoArgsCommand + +from program.models import Show + + +class Command(NoArgsCommand): + help = 'update shows by setting is_active' + + def handle_noargs(self, **options): + activated = 0 + deactivated = 0 + + for show in Show.objects.exclude(pk=1): + for programslot in show.programslots.all(): + active_programslots = 0 + if programslot.is_active: + active_programslots += 1 + else: + active_programslots -= 1 + + show.is_active = active_programslots > 0 + show.save() + + if show.is_active: + activated += 1 + else: + deactivated += 1 + + print "%s shows activated, %s shows de-activated" % (activated, deactivated) |