diff --git a/conftest.py b/conftest.py index be07351..8be7a51 100644 --- a/conftest.py +++ b/conftest.py @@ -69,7 +69,7 @@ def db_init(db): # note: db is a predefined fixture and required here to have t u2.save() # this is for tests: dt = Domain.objects.create( - domain=TESTDOMAIN, # special: test-domain update secret! + name=TESTDOMAIN, # special: test-domain update secret! nameserver_ip=NAMESERVER_IP, nameserver_update_algorithm=NAMESERVER_UPDATE_ALGORITHM, nameserver_update_secret=NAMESERVER_UPDATE_SECRET, @@ -78,7 +78,7 @@ def db_init(db): # note: db is a predefined fixture and required here to have t ) # this is for querying: d = Domain.objects.create( - domain=BASEDOMAIN, + name=BASEDOMAIN, nameserver_ip=NAMESERVER_IP, nameserver_update_algorithm=NAMESERVER_UPDATE_ALGORITHM, nameserver_update_secret='invalid=', # we don't send updates there (and the real key is really secret) @@ -87,10 +87,10 @@ def db_init(db): # note: db is a predefined fixture and required here to have t ) # a Host for api / session update tests hostname = TEST_HOST.split('.', 1)[0] - h = Host(subdomain=hostname, domain=dt, created_by=u) + h = Host(name=hostname, domain=dt, created_by=u) h.generate_secret(secret=TEST_SECRET) hostname2 = TEST_HOST2.split('.', 1)[0] - h2 = Host(subdomain=hostname2, domain=dt, created_by=u2) + h2 = Host(name=hostname2, domain=dt, created_by=u2) h2.generate_secret(secret=TEST_SECRET2) # "update other service" ddns_client feature diff --git a/nsupdate/api/_tests/test_api.py b/nsupdate/api/_tests/test_api.py index 2135ace..d06bf9c 100644 --- a/nsupdate/api/_tests/test_api.py +++ b/nsupdate/api/_tests/test_api.py @@ -96,7 +96,7 @@ def test_nic_update_authorized(client): def test_nic_update_authorized_ns_unavailable(client): - d = Domain.objects.get(domain=TESTDOMAIN) + d = Domain.objects.get(name=TESTDOMAIN) d.available = False # simulate DNS unavailability d.save() # prepare: we must make sure the real test is not a nochg update diff --git a/nsupdate/main/admin.py b/nsupdate/main/admin.py index aab0d4e..442d0e0 100644 --- a/nsupdate/main/admin.py +++ b/nsupdate/main/admin.py @@ -8,17 +8,17 @@ from .models import Host, Domain, BlacklistedDomain, ServiceUpdater, ServiceUpda class DomainAdmin(admin.ModelAdmin): - list_display = ("domain", "public", "available", "created_by") + list_display = ("name", "public", "available", "created_by") list_filter = ("created", "public", "available") class HostAdmin(admin.ModelAdmin): - list_display = ("subdomain", "domain", "created_by", "client_faults", "abuse", "abuse_blocked") + list_display = ("name", "domain", "created_by", "client_faults", "abuse", "abuse_blocked") list_filter = ("created", "abuse", "abuse_blocked", "domain") class BlacklistedDomainAdmin(admin.ModelAdmin): - list_display = ("domain", "created_by") + list_display = ("name_re", "created_by") list_filter = ("created", ) diff --git a/nsupdate/main/dnstools.py b/nsupdate/main/dnstools.py index 092009c..34d780d 100644 --- a/nsupdate/main/dnstools.py +++ b/nsupdate/main/dnstools.py @@ -244,12 +244,12 @@ def get_ns_info(fqdn): # single-host update secret use case # XXX we need 2 DB accesses for the usual case just to support this rare case domain = str(fqdn) - d = Domain.objects.get(domain=domain) + d = Domain.objects.get(name=domain) except Domain.DoesNotExist: # now check the base zone, the usual case # zone update secret use case domain = fqdn.domain - d = Domain.objects.get(domain=domain) + d = Domain.objects.get(name=domain) if not d.available: if d.last_update + timedelta(seconds=UNAVAILABLE_RETRY) > now(): # if there are troubles with a nameserver, we set available=False @@ -330,7 +330,7 @@ def set_ns_availability(domain, available): """ from .models import Domain domain = str(domain).rstrip('.') - d = Domain.objects.get(domain=domain) + d = Domain.objects.get(name=domain) d.available = available d.save() if available: diff --git a/nsupdate/main/forms.py b/nsupdate/main/forms.py index bec7df7..dce6a86 100644 --- a/nsupdate/main/forms.py +++ b/nsupdate/main/forms.py @@ -11,9 +11,9 @@ from .models import Host, Domain, ServiceUpdaterHostConfig class CreateHostForm(forms.ModelForm): class Meta(object): model = Host - fields = ['subdomain', 'domain', 'comment'] + fields = ['name', 'domain', 'comment'] widgets = { - 'subdomain': forms.widgets.TextInput(attrs=dict(autofocus=None)), + 'name': forms.widgets.TextInput(attrs=dict(autofocus=None)), } @@ -26,10 +26,10 @@ class EditHostForm(forms.ModelForm): class CreateDomainForm(forms.ModelForm): class Meta(object): model = Domain - fields = ['domain', 'nameserver_ip', 'nameserver_update_algorithm', + fields = ['name', 'nameserver_ip', 'nameserver_update_algorithm', 'public', 'available', 'comment'] widgets = { - 'domain': forms.widgets.TextInput(attrs=dict(autofocus=None)), + 'name': forms.widgets.TextInput(attrs=dict(autofocus=None)), } diff --git a/nsupdate/main/migrations/0026_auto__del_field_host_subdomain__add_field_host_name__del_unique_host_s.py b/nsupdate/main/migrations/0026_auto__del_field_host_subdomain__add_field_host_name__del_unique_host_s.py new file mode 100644 index 0000000..8a65970 --- /dev/null +++ b/nsupdate/main/migrations/0026_auto__del_field_host_subdomain__add_field_host_name__del_unique_host_s.py @@ -0,0 +1,154 @@ +# -*- 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): + # Removing index on 'Host', fields ['subdomain', 'domain'] + db.delete_index(u'main_host', ['subdomain', 'domain_id']) + + # Renaming field 'Host.subdomain' + db.rename_column(u'main_host', 'subdomain', 'name') + + # Renaming field 'Domain.domain' + db.rename_column(u'main_domain', 'domain', 'name') + + # Renaming field 'BlacklistedDomain.domain' + db.rename_column(u'main_blacklisteddomain', 'domain', 'name_re') + + # Adding index on 'Host', fields ['name', 'domain'] + db.create_index(u'main_host', ['name', 'domain_id']) + + def backwards(self, orm): + # Removing index on 'Host', fields ['name', 'domain'] + db.delete_index(u'main_host', ['name', 'domain_id']) + + # Renaming field 'Host.subdomain' + db.rename_column(u'main_host', 'name', 'subdomain') + + # Renaming field 'Domain.domain' + db.rename_column(u'main_domain', 'name', 'domain') + + # Renaming field 'BlacklistedDomain.domain' + db.rename_column(u'main_blacklisteddomain', 'name_re', 'domain') + + # Adding index on 'Host', fields ['subdomain', 'domain'] + db.create_index(u'main_host', ['subdomain', 'domain_id']) + + + 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']"}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'last_update': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'name_re': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}) + }, + 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']"}), + 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', [], {'unique': 'True', 'max_length': '255'}), + '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': "(('name', 'domain'),)", 'object_name': 'Host', 'index_together': "(('name', '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'}), + 'client_result_msg': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'null': 'True', 'blank': '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': "'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'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'server_faults': ('django.db.models.fields.PositiveIntegerField', [], {'default': '0'}), + 'server_result_msg': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'null': 'True', 'blank': 'True'}), + '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 94b1f95..7c488c3 100644 --- a/nsupdate/main/models.py +++ b/nsupdate/main/models.py @@ -32,7 +32,7 @@ def result_fmt(msg): class BlacklistedDomain(models.Model): - domain = models.CharField( + name_re = models.CharField( max_length=255, unique=True, help_text=_('Blacklisted domain. Evaluated as regex (search).')) @@ -42,12 +42,12 @@ class BlacklistedDomain(models.Model): created_by = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='blacklisted_domains') def __unicode__(self): - return u"%s" % (self.domain, ) + return u"%s" % (self.name_re, ) def domain_blacklist_validator(value): for bd in BlacklistedDomain.objects.all(): - if re.search(bd.domain, value): + if re.search(bd.name_re, value): raise ValidationError(u'This name is blacklisted') @@ -69,7 +69,7 @@ UPDATE_ALGORITHM_CHOICES = [(k, k) for k in UPDATE_ALGORITHMS] class Domain(models.Model): - domain = models.CharField( + name = models.CharField( max_length=255, # RFC 2181 (and also: max length of unique fields) unique=True, help_text=_("Name of the zone where dynamic hosts may get added")) @@ -105,7 +105,7 @@ class Domain(models.Model): created_by = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='domains') def __unicode__(self): - return u"%s" % (self.domain, ) + return u"%s" % (self.name, ) def generate_ns_secret(self): algorithm = self.nameserver_update_algorithm @@ -122,12 +122,12 @@ class Domain(models.Model): class Host(models.Model): - subdomain = models.CharField( + name = models.CharField( max_length=255, # RFC 2181 (and considering having multiple joined labels here later) validators=[ RegexValidator( regex=r'^(([a-z0-9][a-z0-9\-]*[a-z0-9])|[a-z0-9])$', - message='Invalid subdomain: only "a-z", "0-9" and "-" is allowed' + message='Invalid host name: only "a-z", "0-9" and "-" is allowed' ), domain_blacklist_validator, ], @@ -194,14 +194,14 @@ class Host(models.Model): def __unicode__(self): return u"%s.%s" % ( - self.subdomain, self.domain.domain) + self.name, self.domain.name) class Meta(object): - unique_together = (('subdomain', 'domain'), ) - index_together = (('subdomain', 'domain'), ) + unique_together = (('name', 'domain'), ) + index_together = (('name', 'domain'), ) def get_fqdn(self): - return dnstools.FQDN(self.subdomain, self.domain.domain) + return dnstools.FQDN(self.name, self.domain.name) @classmethod def get_by_fqdn(cls, fqdn, **kwargs): @@ -210,7 +210,7 @@ class Host(models.Model): if len(splitted) != 2: raise ValueError("get_by_fqdn(%s): FQDN has to contain (at least) one dot" % fqdn) try: - host = Host.objects.get(subdomain=splitted[0], domain__domain=splitted[1], **kwargs) + host = Host.objects.get(name=splitted[0], domain__name=splitted[1], **kwargs) except Host.DoesNotExist: return None except Host.MultipleObjectsReturned: diff --git a/nsupdate/main/templates/main/domain.html b/nsupdate/main/templates/main/domain.html index 6fe9461..27832b0 100644 --- a/nsupdate/main/templates/main/domain.html +++ b/nsupdate/main/templates/main/domain.html @@ -3,7 +3,7 @@ {% block content %}
-

{{ domain.domain }}

+

{{ domain.name }}

{% trans "Edit Domain" %}

{% trans "You can't change the domain name. If you want to have another domain name, you have to delete this domain and create a new one." %}

diff --git a/nsupdate/main/templates/main/generate_ns_secret.html b/nsupdate/main/templates/main/generate_ns_secret.html index 9aa7265..005c405 100644 --- a/nsupdate/main/templates/main/generate_ns_secret.html +++ b/nsupdate/main/templates/main/generate_ns_secret.html @@ -19,7 +19,7 @@
 // configuration snippet for bind 9 nameserver (put it into /etc/bind9/named.conf )
 
-key "{{ object.domain }}." {
+key "{{ object.name }}." {
     // everyone who has this key may update this zone:
     // must be same algorithm as in the Domain record of the nsupdate.info based service
     algorithm {{ object.get_bind9_algorithm }};
@@ -29,21 +29,21 @@ key "{{ object.domain }}." {
     secret "{{ shared_secret }}";
 };
 
-zone {{ object.domain }} {
+zone {{ object.name }} {
         type master;
         // bind9 needs write permissions into that directory and into that file:
-        file "/etc/bind/zones/{{ object.domain }}";
+        file "/etc/bind/zones/{{ object.name }}";
         update-policy {
             // these "deny" entries are needed for the service domain,
             // if you add another domain, you may want to check the need
             // for other "deny" entries if the zone is not fully available.
             // we don't allow updates to the infrastructure hosts:
-            deny  {{ object.domain }}.      name      {{ object.domain }};
-            deny  {{ object.domain }}.      name  www.{{ object.domain }};
-            deny  {{ object.domain }}.      name ipv4.{{ object.domain }};
-            deny  {{ object.domain }}.      name ipv6.{{ object.domain }};
+            deny  {{ object.name }}.      name      {{ object.name }};
+            deny  {{ object.name }}.      name  www.{{ object.name }};
+            deny  {{ object.name }}.      name ipv4.{{ object.name }};
+            deny  {{ object.name }}.      name ipv6.{{ object.name }};
             // but we allow updates to any other host:
-            grant {{ object.domain }}. subdomain {{ object.domain }};
+            grant {{ object.name }}. subdomain {{ object.name }};
         };
 };
 
@@ -54,19 +54,19 @@ zone {{ object.domain }} { $ORIGIN . $TTL 3600 ; 1 hour ; note: please fix SOA, NS, A, AAAA, MX as needed: -{{ object.domain }} IN SOA ns1.{{ object.domain }}. root.{{ object.domain }}. ( +{{ object.name }} IN SOA ns1.{{ object.name }}. root.{{ object.name }}. ( 2013123101 ; serial YYYYMMDDNN 7200 ; refresh (2 hours) 1800 ; retry (30 minutes) 604800 ; expire (1 week) 60 ; minimum (1 minute) ) - NS ns1.{{ object.domain }}. - NS ns2.{{ object.domain }}. + NS ns1.{{ object.name }}. + NS ns2.{{ object.name }}. A 1.2.3.4 AAAA :: - MX 10 mail.{{ object.domain }}. -$ORIGIN {{ object.domain }}. + MX 10 mail.{{ object.name }}. +$ORIGIN {{ object.name }}. $TTL 3600 ; 1 hour ; note: the www, ipv4, ipv6 host entries are ONLY needed if you run the ; nsupdate.info service on these hosts. if you just want to add another diff --git a/nsupdate/main/templates/main/overview.html b/nsupdate/main/templates/main/overview.html index 4303a4e..055beec 100644 --- a/nsupdate/main/templates/main/overview.html +++ b/nsupdate/main/templates/main/overview.html @@ -95,7 +95,7 @@ {% for domain in your_domains %} - {{ domain.domain }} + {{ domain.name }} {{ domain.public|yesno }} {{ domain.available|yesno }} {{ domain.created_by }} @@ -106,7 +106,7 @@ {% endfor %} {% for domain in public_domains %} - {{ domain.domain }} + {{ domain.name }} {{ domain.public|yesno }} {{ domain.available|yesno }} {{ domain.created_by }} diff --git a/nsupdate/management/commands/_tests/test_faults.py b/nsupdate/management/commands/_tests/test_faults.py index 0c5875a..cc2c3df 100644 --- a/nsupdate/management/commands/_tests/test_faults.py +++ b/nsupdate/management/commands/_tests/test_faults.py @@ -12,7 +12,7 @@ def test_faults_reset(): # trigger execution of all code for coverage, test resetting # set flags and counters hostname = TEST_HOST.split('.', 1)[0] - h = Host.objects.get(subdomain=hostname) + h = Host.objects.get(name=hostname) h.client_faults = 1 h.server_faults = 1 h.available = False @@ -26,7 +26,7 @@ def test_faults_reset(): reset_abuse=True, reset_abuse_blocked=True, reset_available=True) # check if the resetting worked - h = Host.objects.get(subdomain=hostname) + h = Host.objects.get(name=hostname) assert h.client_faults == 0 assert h.server_faults == 0 assert h.available is True @@ -36,27 +36,27 @@ def test_faults_reset(): def test_faults_no_abuse(): hostname = TEST_HOST.split('.', 1)[0] - h = Host.objects.get(subdomain=hostname) + h = Host.objects.get(name=hostname) h.client_faults = 10 # below threshold h.abuse = False h.save() # flag abusive hosts management.call_command('faults', flag_abuse=23) # check if it did not get flagged - h = Host.objects.get(subdomain=hostname) + h = Host.objects.get(name=hostname) assert h.client_faults == 10 assert h.abuse is False def test_faults_abuse(): hostname = TEST_HOST.split('.', 1)[0] - h = Host.objects.get(subdomain=hostname) + h = Host.objects.get(name=hostname) h.client_faults = 42 # above threshold h.abuse = False h.save() # flag abusive hosts management.call_command('faults', flag_abuse=23) # check if it did get flagged - h = Host.objects.get(subdomain=hostname) + h = Host.objects.get(name=hostname) assert h.client_faults == 0 assert h.abuse is True