summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--program/management/commands/update_hosts.py21
-rw-r--r--program/management/commands/update_programslots.py14
-rw-r--r--program/management/commands/update_shows.py22
3 files changed, 57 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()
diff --git a/program/management/commands/update_programslots.py b/program/management/commands/update_programslots.py
new file mode 100644
index 0000000..62de064
--- /dev/null
+++ b/program/management/commands/update_programslots.py
@@ -0,0 +1,14 @@
+from django.core.management.base import NoArgsCommand
+
+from program.models import ProgramSlot
+
+from datetime import date
+
+
+class Command(NoArgsCommand):
+ help = 'update programslots by setting is_active'
+
+ def handle_noargs(self, **options):
+ for programslot in ProgramSlot.objects.all():
+ programslot.is_active = programslot.until > date.today()
+ programslot.save()
diff --git a/program/management/commands/update_shows.py b/program/management/commands/update_shows.py
new file mode 100644
index 0000000..d582bb5
--- /dev/null
+++ b/program/management/commands/update_shows.py
@@ -0,0 +1,22 @@
+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):
+ for show in Show.objects.exclude(pk=1):
+ has_active_programslots = None
+ for programslot in show.programslots.all():
+ if programslot.until > date.today():
+ has_active_programslots = True
+ else:
+ has_active_programslots = False
+ show.has_active_programslots = has_active_programslots
+
+ if not has_active_programslots:
+ show.save()