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

removed update_{hosts,programslots,shows} management commands.

parent 5983b58a
No related branches found
No related tags found
1 merge request!3Recognize activity
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):
activated = 0
deactivated = 0
for host in Host.objects.all():
active_shows = 0
for show in host.shows.all():
if show.is_active:
active_shows += 1
else:
active_shows -= 1
host.is_active = active_shows > 0
host.save()
if host.is_active:
activated += 1
else:
deactivated += 1
print "%s hosts activated, %s hosts de-activated " % (activated, deactivated)
from django.core.management.base import NoArgsCommand
from program.models import ProgramSlot
from datetime import datetime
class Command(NoArgsCommand):
help = 'update programslots by setting is_active'
def handle_noargs(self, **options):
deactivated = ProgramSlot.objects.filter(until__lt=datetime.now()).update(is_active=False)
activated = ProgramSlot.objects.filter(until__gt=datetime.now()).update(is_active=True)
print "%s program slots activated, %s program slots de-activated" % (activated, deactivated)
from django.core.management.base import NoArgsCommand
from program.models import Show
from datetime import datetime
class Command(NoArgsCommand):
help = 'update shows by setting is_active'
def handle_noargs(self, **options):
deactivated = Show.objects.exclude(id=1).filter(programslots__until__lt=datetime.now()).update(is_active=False)
activated = Show.objects.exclude(id=1).filter(programslots__until__gt=datetime.now()).distinct().update(is_active=True)
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.
Finish editing this message first!
Please register or to comment