summaryrefslogtreecommitdiff
path: root/program/management/commands/update_hosts.py
diff options
context:
space:
mode:
authorErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2016-03-27 18:38:29 (GMT)
committerErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2016-03-27 18:38:29 (GMT)
commit6c29ea12d96094cf1b71e6c2f22043bf92d32bcb (patch)
tree31b0b3e0187065ccfe1f479bb6689d424c022c68 /program/management/commands/update_hosts.py
parent94af0c6f391fc21f14047a8d649d4d4e8697afea (diff)
fixed update commands
Diffstat (limited to 'program/management/commands/update_hosts.py')
-rw-r--r--program/management/commands/update_hosts.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/program/management/commands/update_hosts.py b/program/management/commands/update_hosts.py
index 64619cd..3cb143b 100644
--- a/program/management/commands/update_hosts.py
+++ b/program/management/commands/update_hosts.py
@@ -7,15 +7,23 @@ class Command(NoArgsCommand):
help = 'update host by setting is_active'
def handle_noargs(self, **options):
+ activated = 0
+ deactivated = 0
+
for host in Host.objects.all():
- is_active = None
+ active_shows = 0
for show in host.shows.all():
if show.is_active:
- is_active = True
+ active_shows += 1
else:
- is_active = False
+ active_shows -= 1
+
+ host.is_active = active_shows > 0
+ host.save()
- host.is_active = is_active
+ if host.is_active:
+ activated += 1
+ else:
+ deactivated += 1
- if not is_active:
- host.save()
+ print "%s hosts activated, %s hosts de-activated " % (activated, deactivated)