diff options
author | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2016-01-06 19:01:45 (GMT) |
---|---|---|
committer | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2016-01-06 19:01:45 (GMT) |
commit | 49cd6812d07c4ee1519ade5ea4d20578c25a91c3 (patch) | |
tree | d95539789abea6839ee05abfbafc93a6f202deb7 /program/management/commands/update_shows.py | |
parent | b1b142c22135543e01a8dede7f2c70522d29d933 (diff) |
added commands to update new model fields
Diffstat (limited to 'program/management/commands/update_shows.py')
-rw-r--r-- | program/management/commands/update_shows.py | 22 |
1 files changed, 22 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..d582bb5 --- /dev/null +++ b/program/management/commands/update_shows.py @@ -0,0 +1,22 @@ +from django.core.management.base import NoArgsCommand + +from program.models import Show + +from datetime import date + + +class Command(NoArgsCommand): + help = 'update shows by setting is_active' + + def handle_noargs(self, **options): + for show in Show.objects.exclude(pk=1): + has_active_programslots = None + for programslot in show.programslots.all(): + if programslot.until > date.today(): + has_active_programslots = True + else: + has_active_programslots = False + show.has_active_programslots = has_active_programslots + + if not has_active_programslots: + show.save() |