summaryrefslogtreecommitdiff
path: root/program/management/commands/update_hosts.py
blob: 64619cdfa519a396f454f9273f737c5fbeeccefd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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():
            is_active = None
            for show in host.shows.all():
                if show.is_active:
                    is_active = True
                else:
                    is_active = False

            host.is_active = is_active

            if not is_active:
                host.save()