From 8cc0a1dae3ded38934e2f33e169e01d101d1b577 Mon Sep 17 00:00:00 2001
From: Ernesto Rico-Schmidt <ernesto.rico-schmidt@evolaris.net>
Date: Wed, 17 Aug 2016 19:00:51 +0200
Subject: [PATCH] removed is_active from Host, Show and ProgramSlot.

---
 program/admin.py                               | 10 +++++-----
 .../migrations/0009_host_remove_is_active.py   | 18 ++++++++++++++++++
 .../migrations/0010_show_remove_is_active.py   | 18 ++++++++++++++++++
 .../0011_programslot_remove_is_active.py       | 18 ++++++++++++++++++
 program/models.py                              |  6 ------
 program/templates/host_detail.html             |  7 +------
 program/templates/show_detail.html             |  4 +---
 program/templates/show_list.html               |  4 +---
 program/views.py                               |  6 +++---
 9 files changed, 65 insertions(+), 26 deletions(-)
 create mode 100644 program/migrations/0009_host_remove_is_active.py
 create mode 100644 program/migrations/0010_show_remove_is_active.py
 create mode 100644 program/migrations/0011_programslot_remove_is_active.py

diff --git a/program/admin.py b/program/admin.py
index b840d03b..7f090280 100644
--- a/program/admin.py
+++ b/program/admin.py
@@ -29,8 +29,8 @@ class ShowTopicAdmin(admin.ModelAdmin):
 
 
 class HostAdmin(admin.ModelAdmin):
-    list_display = ('name', 'is_active')
-    list_filter = ('is_active', 'is_always_visible')
+    list_display = ('name',)
+    list_filter = ('is_always_visible',)
 
 
 class NoteAdmin(admin.ModelAdmin):
@@ -73,7 +73,7 @@ class ProgramSlotAdmin(admin.ModelAdmin):
     inlines = (TimeSlotInline,)
     fields = (('rrule', 'byweekday'), ('dstart', 'tstart', 'tend'), 'until', 'is_repetition', 'automation_id')
     list_display = ('get_show_name', 'byweekday', 'rrule', 'tstart', 'tend', 'until')
-    list_filter = ('is_active', 'byweekday', 'rrule', 'is_repetition')
+    list_filter = ('byweekday', 'rrule', 'is_repetition')
     ordering = ('byweekday', 'dstart')
     save_on_top = True
     search_fields = ('show__name',)
@@ -103,8 +103,8 @@ class ProgramSlotInline(admin.TabularInline):
 class ShowAdmin(admin.ModelAdmin):
     filter_horizontal = ('hosts', 'owners', 'musicfocus', 'showinformation', 'showtopic')
     inlines = (ProgramSlotInline,)
-    list_display = ('name', 'short_description', 'is_active')
-    list_filter = ('is_active', 'broadcastformat', 'showinformation', 'showtopic', 'musicfocus')
+    list_display = ('name', 'short_description')
+    list_filter = ('broadcastformat', 'showinformation', 'showtopic', 'musicfocus')
     ordering = ('slug',)
     prepopulated_fields = {'slug': ('name',)}
     search_fields = ('name', 'short_description', 'description')
diff --git a/program/migrations/0009_host_remove_is_active.py b/program/migrations/0009_host_remove_is_active.py
new file mode 100644
index 00000000..f6647f04
--- /dev/null
+++ b/program/migrations/0009_host_remove_is_active.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('program', '0008_show_remove_automation_id'),
+    ]
+
+    operations = [
+        migrations.RemoveField(
+            model_name='host',
+            name='is_active',
+        ),
+    ]
diff --git a/program/migrations/0010_show_remove_is_active.py b/program/migrations/0010_show_remove_is_active.py
new file mode 100644
index 00000000..543bdc1d
--- /dev/null
+++ b/program/migrations/0010_show_remove_is_active.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('program', '0009_host_remove_is_active'),
+    ]
+
+    operations = [
+        migrations.RemoveField(
+            model_name='show',
+            name='is_active',
+        ),
+    ]
diff --git a/program/migrations/0011_programslot_remove_is_active.py b/program/migrations/0011_programslot_remove_is_active.py
new file mode 100644
index 00000000..ab8295af
--- /dev/null
+++ b/program/migrations/0011_programslot_remove_is_active.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('program', '0010_show_remove_is_active.py'),
+    ]
+
+    operations = [
+        migrations.RemoveField(
+            model_name='programslot',
+            name='is_active',
+        ),
+    ]
diff --git a/program/models.py b/program/models.py
index b11d1802..8f6a65b6 100644
--- a/program/models.py
+++ b/program/models.py
@@ -211,7 +211,6 @@ class MusicFocus(models.Model):
 class Host(models.Model):
     name = models.CharField(_("Name"), max_length=128)
     is_always_visible = models.BooleanField(_("Is always visible"), default=False)
-    is_active = models.BooleanField(_("Is active"), default=True, editable=False)
     email = models.EmailField(_("E-Mail"), blank=True)
     website = models.URLField(_("Website"), blank=True)
 
@@ -243,7 +242,6 @@ class Show(models.Model):
     description = tinymce_models.HTMLField(_("Description"), blank=True, null=True)
     email = models.EmailField(_("E-Mail"), blank=True, null=True)
     website = models.URLField(_("Website"), blank=True, null=True)
-    is_active = models.BooleanField(_("Is active"), default=True, editable=False)
     created = models.DateTimeField(auto_now_add=True, editable=False)
     last_updated = models.DateTimeField(auto_now=True, editable=False)
 
@@ -306,7 +304,6 @@ class ProgramSlot(models.Model):
     tstart = models.TimeField(_("Start time"))
     tend = models.TimeField(_("End time"))
     until = models.DateField(_("Last date"))
-    is_active = models.BooleanField(_("Is active"), default=True, editable=False)
     is_repetition = models.BooleanField(_("Is repetition"), default=False)
     automation_id = models.IntegerField(_("Automation ID"), blank=True, null=True, choices=get_automation_id_choices())
     created = models.DateTimeField(auto_now_add=True, editable=False)
@@ -351,9 +348,6 @@ class ProgramSlot(models.Model):
         else:
             old = False
 
-        self.is_active = self.until > date.today()
-        self.show.is_active = self.until > date.today()
-
         super(ProgramSlot, self).save(*args, **kwargs)
 
         if self.rrule.freq == 0:
diff --git a/program/templates/host_detail.html b/program/templates/host_detail.html
index 73182d67..87a4c12d 100644
--- a/program/templates/host_detail.html
+++ b/program/templates/host_detail.html
@@ -10,12 +10,7 @@
     <div id="shows">
         <div id="shows-title">Sendungen</div>
         {% for show in host.shows.all %}
-            {% if show.is_active %}
-                <div class="show {{ show.broadcastformat.slug }}"><a
-                        href="{% url "show-detail" show.slug %}">{{ show }}</a></div>
-            {% else %}
-                <div class="show {{ show.broadcastformat.slug }}">{{ show }}</div>
-            {% endif %}
+            <div class="show {{ show.broadcastformat.slug }}">{{ show }}</div>
         {% endfor %}
     </div>
 
diff --git a/program/templates/show_detail.html b/program/templates/show_detail.html
index 47d20a1a..9fb9fb0c 100644
--- a/program/templates/show_detail.html
+++ b/program/templates/show_detail.html
@@ -14,9 +14,7 @@
             {% if show.id != 1 %}
                 <p id="programslots">
                     {% for slot in show.programslots.all %}
-                        {% if slot.is_active %}
-                            <span class="programslot">{{ slot }}</span><br/>
-                        {% endif %}
+                        <span class="programslot">{{ slot }}</span><br/>
                     {% endfor %}
                 </p>
             {% endif %}
diff --git a/program/templates/show_list.html b/program/templates/show_list.html
index 62594e92..96ea4975 100644
--- a/program/templates/show_list.html
+++ b/program/templates/show_list.html
@@ -41,9 +41,7 @@
                     <h3 class="show-title"><a href="{% url "show-detail" show.slug %}">{{ show.name }}</a></h3>
                     <ul class="show-programslots">
                         {% for programslot in show.programslots.all %}
-                            {% if programslot.is_active %}
-                                <li class="show-programslot">{{ programslot }}</li>
-                            {% endif %}
+                            <li class="show-programslot">{{ programslot }}</li>
                         {% endfor %}
                     </ul>
                     <p class="show-description">{{ show.short_description }}</p>
diff --git a/program/views.py b/program/views.py
index cfebbd1b..94164b68 100644
--- a/program/views.py
+++ b/program/views.py
@@ -15,19 +15,19 @@ from program.utils import tofirstdayinisoweek
 
 class HostListView(ListView):
     context_object_name = 'host_list'
-    queryset = Host.objects.filter(Q(is_active=True) | Q(is_always_visible=True)).distinct()
+    queryset = Host.objects.filter(is_always_visible=True).distinct()
     template_name = 'host_list.html'
 
 
 class HostDetailView(DetailView):
     context_object_name = 'host'
-    queryset = Host.objects.filter(Q(is_active=True) | Q(is_always_visible=True)).distinct()
+    queryset = Host.objects.filter(is_always_visible=True).distinct()
     template_name = 'host_detail.html'
 
 
 class ShowListView(ListView):
     context_object_name = 'show_list'
-    queryset = Show.objects.filter(is_active=True).exclude(id=1).distinct()
+    queryset = Show.objects.exclude(id=1).distinct()
     template_name = 'show_list.html'
 
     def get_queryset(self):
-- 
GitLab