Skip to content
Snippets Groups Projects
Commit 6c29ea12 authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

fixed update commands

parent 94af0c6f
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......@@ -9,6 +9,16 @@ 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)
......@@ -2,21 +2,28 @@ 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):
activated = 0
deactivated = 0
for show in Show.objects.exclude(pk=1):
is_active = None
for programslot in show.programslots.all():
if programslot.until > date.today():
is_active = True
active_programslots = 0
if programslot.is_active:
active_programslots += 1
else:
is_active = False
show.is_active = is_active
active_programslots -= 1
show.is_active = active_programslots > 0
show.save()
if show.is_active:
activated += 1
else:
deactivated += 1
if not is_active:
show.save()
print "%s shows activated, %s shows de-activated" % (activated, deactivated)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment