From f26ae31882338892055969c5c803a18fad0267a8 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 30 May 2014 02:03:48 +0200 Subject: [PATCH] s/ssl_update_v4/tls_update_v4/g (and same for v6) SSL is the old/outdated name. Since 1999, it's called TLS. Changed model field names. Added a schema migration to rename the DB columns. Note: the schema migration also adds/removes the index introduced in cs 32289ebb183907e8618ff251dd5846fd00fe9423 --- ..._ipv6__del_field_host_ssl_update_ipv4__.py | 142 ++++++++++++++++++ nsupdate/main/models.py | 8 +- nsupdate/main/templates/main/overview.html | 4 +- nsupdate/main/templates/main/status.html | 8 +- nsupdate/main/views.py | 16 +- 5 files changed, 160 insertions(+), 18 deletions(-) create mode 100644 nsupdate/main/migrations/0024_auto__del_field_host_ssl_update_ipv6__del_field_host_ssl_update_ipv4__.py diff --git a/nsupdate/main/migrations/0024_auto__del_field_host_ssl_update_ipv6__del_field_host_ssl_update_ipv4__.py b/nsupdate/main/migrations/0024_auto__del_field_host_ssl_update_ipv6__del_field_host_ssl_update_ipv4__.py new file mode 100644 index 0000000..7a66cc0 --- /dev/null +++ b/nsupdate/main/migrations/0024_auto__del_field_host_ssl_update_ipv6__del_field_host_ssl_update_ipv4__.py @@ -0,0 +1,142 @@ +# -*- coding: utf-8 -*- +from south.utils import datetime_utils as datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Renaming field 'Host.ssl_update_ipv6' + db.rename_column(u'main_host', 'ssl_update_ipv6', 'tls_update_ipv6') + + # Renaming field 'Host.ssl_update_ipv4' + db.rename_column(u'main_host', 'ssl_update_ipv4', 'tls_update_ipv4') + + # Adding index on 'Host', fields ['subdomain', 'domain'] + db.create_index(u'main_host', ['subdomain', 'domain_id']) + + + def backwards(self, orm): + # Removing index on 'Host', fields ['subdomain', 'domain'] + db.delete_index(u'main_host', ['subdomain', 'domain_id']) + + # Renaming field 'Host.tls_update_ipv4' + db.rename_column(u'main_host', 'tls_update_ipv4', 'ssl_update_ipv4') + + # Renaming field 'Host.tls_update_ipv6' + db.rename_column(u'main_host', 'tls_update_ipv6', 'ssl_update_ipv6') + + + models = { + u'auth.group': { + 'Meta': {'object_name': 'Group'}, + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + u'auth.permission': { + 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + u'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + u'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + u'main.blacklisteddomain': { + 'Meta': {'object_name': 'BlacklistedDomain'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'blacklisted_domains'", 'to': u"orm['auth.User']"}), + 'domain': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'last_update': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) + }, + u'main.domain': { + 'Meta': {'object_name': 'Domain'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'domains'", 'to': u"orm['auth.User']"}), + 'domain': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'last_update': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'nameserver_ip': ('django.db.models.fields.GenericIPAddressField', [], {'max_length': '39'}), + 'nameserver_update_algorithm': ('django.db.models.fields.CharField', [], {'default': "'HMAC_SHA512'", 'max_length': '16'}), + 'nameserver_update_secret': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '88'}), + 'public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) + }, + u'main.host': { + 'Meta': {'unique_together': "(('subdomain', 'domain'),)", 'object_name': 'Host', 'index_together': "(('subdomain', 'domain'),)"}, + 'abuse': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'abuse_blocked': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'client_faults': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}), + 'comment': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'hosts'", 'to': u"orm['auth.User']"}), + 'domain': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['main.Domain']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'last_update': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'last_update_ipv4': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), + 'last_update_ipv6': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), + 'server_faults': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}), + 'subdomain': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'tls_update_ipv4': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'tls_update_ipv6': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'update_secret': ('django.db.models.fields.CharField', [], {'max_length': '64'}) + }, + u'main.serviceupdater': { + 'Meta': {'object_name': 'ServiceUpdater'}, + 'accept_ipv4': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'accept_ipv6': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'comment': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'serviceupdater'", 'to': u"orm['auth.User']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'last_update': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '32'}), + 'path': ('django.db.models.fields.CharField', [], {'default': "'/nic/update'", 'max_length': '255'}), + 'secure': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'server': ('django.db.models.fields.CharField', [], {'max_length': '255'}) + }, + u'main.serviceupdaterhostconfig': { + 'Meta': {'object_name': 'ServiceUpdaterHostConfig'}, + 'comment': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'created_by': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'serviceupdaterhostconfigs'", 'to': u"orm['auth.User']"}), + 'give_ipv4': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'give_ipv6': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'host': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'serviceupdaterhostconfigs'", 'to': u"orm['main.Host']"}), + 'hostname': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'last_update': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'service': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['main.ServiceUpdater']"}) + } + } + + complete_apps = ['main'] diff --git a/nsupdate/main/models.py b/nsupdate/main/models.py index 368dacc..a417066 100644 --- a/nsupdate/main/models.py +++ b/nsupdate/main/models.py @@ -165,8 +165,8 @@ class Host(models.Model): last_update_ipv4 = models.DateTimeField(blank=True, null=True) last_update_ipv6 = models.DateTimeField(blank=True, null=True) # how we received the last update for v4/v6 addr - ssl_update_ipv4 = models.BooleanField(default=False) - ssl_update_ipv6 = models.BooleanField(default=False) + tls_update_ipv4 = models.BooleanField(default=False) + tls_update_ipv6 = models.BooleanField(default=False) last_update = models.DateTimeField(auto_now=True) created = models.DateTimeField(auto_now_add=True) @@ -217,10 +217,10 @@ class Host(models.Model): def poke(self, kind, secure): if kind == 'ipv4': self.last_update_ipv4 = now() - self.ssl_update_ipv4 = secure + self.tls_update_ipv4 = secure else: self.last_update_ipv6 = now() - self.ssl_update_ipv6 = secure + self.tls_update_ipv6 = secure self.save() def register_client_fault(self, increment=1): diff --git a/nsupdate/main/templates/main/overview.html b/nsupdate/main/templates/main/overview.html index 9e29f03..a18d525 100644 --- a/nsupdate/main/templates/main/overview.html +++ b/nsupdate/main/templates/main/overview.html @@ -33,7 +33,7 @@
{% if host.last_update_ipv4 %} ({{ host.last_update_ipv4|timesince }}, - {% if not host.ssl_update_ipv4 %} + {% if not host.tls_update_ipv4 %} no {% else %} {% endif %}TLS) {% else %} @@ -44,7 +44,7 @@
{% if host.last_update_ipv6 %} ({{ host.last_update_ipv6|timesince }}, - {% if not host.ssl_update_ipv6 %} + {% if not host.tls_update_ipv6 %} no {% else %} {% endif %}TLS) {% else %} diff --git a/nsupdate/main/templates/main/status.html b/nsupdate/main/templates/main/status.html index e91e6da..e107b46 100644 --- a/nsupdate/main/templates/main/status.html +++ b/nsupdate/main/templates/main/status.html @@ -22,13 +22,13 @@
Unavailable / Abuse / Abuse-Blocked:
{{ hosts_unavailable }} / {{ hosts_abuse }} / {{ hosts_abuse_blocked }}
ip v4 (tls) / v6 (tls) updated last 2d:
-
{{ hosts_ipv4_2d }} ({{ hosts_ipv4_ssl_2d }}) / {{ hosts_ipv6_2d }} ({{ hosts_ipv6_ssl_2d }})
+
{{ hosts_ipv4_2d }} ({{ hosts_ipv4_tls_2d }}) / {{ hosts_ipv6_2d }} ({{ hosts_ipv6_tls_2d }})
ip v4 (tls) / v6 (tls) updated last 2w:
-
{{ hosts_ipv4_2w }} ({{ hosts_ipv4_ssl_2w }}) / {{ hosts_ipv6_2w }} ({{ hosts_ipv6_ssl_2w }})
+
{{ hosts_ipv4_2w }} ({{ hosts_ipv4_tls_2w }}) / {{ hosts_ipv6_2w }} ({{ hosts_ipv6_tls_2w }})
ip v4 (tls) / v6 (tls) updated last 2m:
-
{{ hosts_ipv4_2m }} ({{ hosts_ipv4_ssl_2m }}) / {{ hosts_ipv6_2m }} ({{ hosts_ipv6_ssl_2m }})
+
{{ hosts_ipv4_2m }} ({{ hosts_ipv4_tls_2m }}) / {{ hosts_ipv6_2m }} ({{ hosts_ipv6_tls_2m }})
ip v4 (tls) / v6 (tls) updated last 2y:
-
{{ hosts_ipv4_2y }} ({{ hosts_ipv4_ssl_2y }}) / {{ hosts_ipv6_2y }} ({{ hosts_ipv6_ssl_2y }})
+
{{ hosts_ipv4_2y }} ({{ hosts_ipv4_tls_2y }}) / {{ hosts_ipv6_2y }} ({{ hosts_ipv6_tls_2y }})
diff --git a/nsupdate/main/views.py b/nsupdate/main/views.py index e5e5f1d..187e695 100644 --- a/nsupdate/main/views.py +++ b/nsupdate/main/views.py @@ -123,20 +123,20 @@ class StatusView(TemplateView): before_2y = t_now - timedelta(days=730) context['hosts_ipv4_2d'] = Host.objects.filter(last_update_ipv4__gt=before_2d).count() context['hosts_ipv6_2d'] = Host.objects.filter(last_update_ipv6__gt=before_2d).count() - context['hosts_ipv4_ssl_2d'] = Host.objects.filter(last_update_ipv4__gt=before_2d, ssl_update_ipv4=True).count() - context['hosts_ipv6_ssl_2d'] = Host.objects.filter(last_update_ipv6__gt=before_2d, ssl_update_ipv6=True).count() + context['hosts_ipv4_tls_2d'] = Host.objects.filter(last_update_ipv4__gt=before_2d, tls_update_ipv4=True).count() + context['hosts_ipv6_tls_2d'] = Host.objects.filter(last_update_ipv6__gt=before_2d, tls_update_ipv6=True).count() context['hosts_ipv4_2w'] = Host.objects.filter(last_update_ipv4__gt=before_2w).count() context['hosts_ipv6_2w'] = Host.objects.filter(last_update_ipv6__gt=before_2w).count() - context['hosts_ipv4_ssl_2w'] = Host.objects.filter(last_update_ipv4__gt=before_2w, ssl_update_ipv4=True).count() - context['hosts_ipv6_ssl_2w'] = Host.objects.filter(last_update_ipv6__gt=before_2w, ssl_update_ipv6=True).count() + context['hosts_ipv4_tls_2w'] = Host.objects.filter(last_update_ipv4__gt=before_2w, tls_update_ipv4=True).count() + context['hosts_ipv6_tls_2w'] = Host.objects.filter(last_update_ipv6__gt=before_2w, tls_update_ipv6=True).count() context['hosts_ipv4_2m'] = Host.objects.filter(last_update_ipv4__gt=before_2m).count() context['hosts_ipv6_2m'] = Host.objects.filter(last_update_ipv6__gt=before_2m).count() - context['hosts_ipv4_ssl_2m'] = Host.objects.filter(last_update_ipv4__gt=before_2m, ssl_update_ipv4=True).count() - context['hosts_ipv6_ssl_2m'] = Host.objects.filter(last_update_ipv6__gt=before_2m, ssl_update_ipv6=True).count() + context['hosts_ipv4_tls_2m'] = Host.objects.filter(last_update_ipv4__gt=before_2m, tls_update_ipv4=True).count() + context['hosts_ipv6_tls_2m'] = Host.objects.filter(last_update_ipv6__gt=before_2m, tls_update_ipv6=True).count() context['hosts_ipv4_2y'] = Host.objects.filter(last_update_ipv4__gt=before_2y).count() context['hosts_ipv6_2y'] = Host.objects.filter(last_update_ipv6__gt=before_2y).count() - context['hosts_ipv4_ssl_2y'] = Host.objects.filter(last_update_ipv4__gt=before_2y, ssl_update_ipv4=True).count() - context['hosts_ipv6_ssl_2y'] = Host.objects.filter(last_update_ipv6__gt=before_2y, ssl_update_ipv6=True).count() + context['hosts_ipv4_tls_2y'] = Host.objects.filter(last_update_ipv4__gt=before_2y, tls_update_ipv4=True).count() + context['hosts_ipv6_tls_2y'] = Host.objects.filter(last_update_ipv6__gt=before_2y, tls_update_ipv6=True).count() user_model = get_user_model() context['users_total'] = user_model.objects.count() context['users_active'] = user_model.objects.filter(is_active=True).count()