summaryrefslogtreecommitdiff
path: root/program/management/commands/update_hosts.py
diff options
context:
space:
mode:
authorErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2016-01-06 19:01:45 (GMT)
committerErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2016-01-06 19:01:45 (GMT)
commit49cd6812d07c4ee1519ade5ea4d20578c25a91c3 (patch)
treed95539789abea6839ee05abfbafc93a6f202deb7 /program/management/commands/update_hosts.py
parentb1b142c22135543e01a8dede7f2c70522d29d933 (diff)
added commands to update new model fields
Diffstat (limited to 'program/management/commands/update_hosts.py')
-rw-r--r--program/management/commands/update_hosts.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/program/management/commands/update_hosts.py b/program/management/commands/update_hosts.py
new file mode 100644
index 0000000..22e0596
--- /dev/null
+++ b/program/management/commands/update_hosts.py
@@ -0,0 +1,21 @@
+from django.core.management.base import NoArgsCommand
+
+from program.models import Host
+
+
+class Command(NoArgsCommand):
+ help = 'update host by setting is_active'
+
+ def handle_noargs(self, **options):
+ for host in Host.objects.all():
+ for show in host.shows.all():
+ hosts_active_show = None
+ if show.has_active_programslots:
+ hosts_active_show = True
+ else:
+ hosts_active_show = False
+
+ host.hosts_active_show = hosts_active_show
+
+ if not hosts_active_show:
+ host.save()