summaryrefslogtreecommitdiff
path: root/program/management/commands
diff options
context:
space:
mode:
Diffstat (limited to 'program/management/commands')
-rw-r--r--program/management/commands/__init__.py2
-rw-r--r--program/management/commands/update_hosts.py29
-rw-r--r--program/management/commands/update_programslots.py24
-rw-r--r--program/management/commands/update_shows.py29
4 files changed, 82 insertions, 2 deletions
diff --git a/program/management/commands/__init__.py b/program/management/commands/__init__.py
index 3aa4ca5..e69de29 100644
--- a/program/management/commands/__init__.py
+++ b/program/management/commands/__init__.py
@@ -1,2 +0,0 @@
-__author__ = 'ers'
- \ No newline at end of file
diff --git a/program/management/commands/update_hosts.py b/program/management/commands/update_hosts.py
new file mode 100644
index 0000000..3cb143b
--- /dev/null
+++ b/program/management/commands/update_hosts.py
@@ -0,0 +1,29 @@
+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)
diff --git a/program/management/commands/update_programslots.py b/program/management/commands/update_programslots.py
new file mode 100644
index 0000000..f0cc59d
--- /dev/null
+++ b/program/management/commands/update_programslots.py
@@ -0,0 +1,24 @@
+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):
+ 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)
diff --git a/program/management/commands/update_shows.py b/program/management/commands/update_shows.py
new file mode 100644
index 0000000..a337f21
--- /dev/null
+++ b/program/management/commands/update_shows.py
@@ -0,0 +1,29 @@
+from django.core.management.base import NoArgsCommand
+
+from program.models import Show
+
+
+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):
+ for programslot in show.programslots.all():
+ active_programslots = 0
+ if programslot.is_active:
+ active_programslots += 1
+ else:
+ active_programslots -= 1
+
+ show.is_active = active_programslots > 0
+ show.save()
+
+ if show.is_active:
+ activated += 1
+ else:
+ deactivated += 1
+
+ print "%s shows activated, %s shows de-activated" % (activated, deactivated)