Permalink
Browse files

pep8

  • Loading branch information...
1 parent 89e5894 commit 9ac4202de67ff451447362c6e1706bf06b20b5a0 @ngokevin committed Dec 5, 2012
View
81 cyder/cydns/address_record/models.py
@@ -2,14 +2,13 @@
from django.core.exceptions import ValidationError, ObjectDoesNotExist
import cydns
-import cydhcp as cydhcp
from cyder.cydns.cname.models import CNAME
from cyder.cydns.view.models import View
from cyder.cydns.ip.models import Ip
-from cyder.cydns.models import set_fqdn, check_for_cname, check_for_delegation
+from cyder.cydns.models import set_fqdn, check_for_cname
from cyder.cydns.models import check_TLD_condition
-from cyder.cydns.validation import validate_first_label, validate_name
-from cyder.cydns.validation import validate_ttl, validate_views
+from cyder.cydns.validation import (validate_first_label, validate_name,
+ validate_ttl)
from cyder.cydns.domain.models import Domain
from cyder.cydns.mixins import ObjectUrlMixin
from cyder.cydns.soa.utils import update_soa
@@ -22,32 +21,34 @@ class BaseAddressRecord(Ip, ObjectUrlMixin):
... ip_type=ip_type)
"""
- label = models.CharField(max_length=63, blank=True, null=True,
- validators=[validate_first_label],
- help_text="The short hostname goes here. If this is a record "
- "for the selected domain, leave this field blank")
- domain = models.ForeignKey(Domain, null=False, help_text="FQDN of the "
- "domain after the short hostname. "
- "(Ex: <i>Vlan</i>.<i>DC</i>.mozilla.com)")
+ label = models.CharField(
+ max_length=63, blank=True, null=True,
+ validators=[validate_first_label],
+ help_text='The short hostname goes here. If this is a record '
+ 'for the selected domain, leave this field blank')
+ domain = models.ForeignKey(Domain, null=False, help_text='FQDN of the '
+ 'domain after the short hostname. '
+ '(Ex: <i>Vlan</i>.<i>DC</i>.mozilla.com)')
fqdn = models.CharField(max_length=255, blank=True, null=True,
validators=[validate_name])
- ttl = models.PositiveIntegerField(default=3600, blank=True, null=True,
- validators=[validate_ttl], help_text="Time to Live of the record")
+ ttl = models.PositiveIntegerField(
+ default=3600, blank=True, null=True,
+ validators=[validate_ttl], help_text='Time to Live of the record')
comment = models.CharField(max_length=1000, blank=True, null=True,
- help_text="Comments about this record.")
+ help_text='Comments about this record.')
views = models.ManyToManyField(View, blank=True)
- search_fields = ("fqdn", "ip_str")
+ search_fields = ('fqdn', 'ip_str')
class Meta:
abstract = True
def __str__(self):
- return "{0} {1} {2}".format(self.fqdn,
+ return '{0} {1} {2}'.format(self.fqdn,
self.record_type(), str(self.ip_str))
def __repr__(self):
- return "<Address Record '{0}'>".format(str(self))
+ return '<Address Record "{0}">'.format(str(self))
def details(self):
"""For tables."""
@@ -96,7 +97,7 @@ def save(self, *args, **kwargs):
prune_tree(db_domain)
def clean(self, *args, **kwargs):
- validate_glue = kwargs.pop("validate_glue", True)
+ validate_glue = kwargs.pop('validate_glue', True)
if validate_glue:
self.check_glue_status()
set_fqdn(self)
@@ -108,30 +109,32 @@ def clean(self, *args, **kwargs):
pass
check_for_cname(self)
- urd = kwargs.pop("update_reverse_domain", False)
+ urd = kwargs.pop('update_reverse_domain', False)
self.clean_ip(update_reverse_domain=urd)
- if not kwargs.pop("ignore_interface", False):
- from cyder.cydhcp.interface.static_intr.models import StaticInterface
+ from cyder.cydhcp.interface.static_intr.models import StaticInterface
+ if not kwargs.pop('ignore_interface', False):
if StaticInterface.objects.filter(fqdn=self.fqdn,
ip_upper=self.ip_upper,
ip_lower=self.ip_lower).exists():
- raise ValidationError("A Static Interface has already "
- "reserved this A record.")
+ raise ValidationError('A Static Interface has already '
+ 'reserved this A record.')
def delete(self, *args, **kwargs):
"""Address Records that are glue records or that are pointed to
by a CNAME should not be removed from the database.
"""
- if kwargs.pop("validate_glue", True):
+ if kwargs.pop('validate_glue', True):
if self.nameserver_set.exists():
- raise ValidationError("Cannot delete the record {0}. It is "
- "a glue record.".format(self.record_type()))
- if kwargs.pop("check_cname", True):
+ raise ValidationError(
+ 'Cannot delete the record {0}. It is a glue record.'
+ .format(self.record_type()))
+ if kwargs.pop('check_cname', True):
if CNAME.objects.filter(target=self.fqdn):
- raise ValidationError("A CNAME points to this {0} record. "
- "Change the CNAME before deleting this record.".
- format(self.record_type()))
+ raise ValidationError(
+ 'A CNAME points to this {0} record. Change the CNAME'
+ ' before deleting this record.'.
+ format(self.record_type()))
from cyder.cydns.utils import prune_tree
objs_domain = self.domain
@@ -148,8 +151,9 @@ def validate_delegation_conditions(self):
return
else:
# Confusing error messege?
- raise ValidationError("You can only create A records in a "
- "delegated domain that have an NS record pointing to them.")
+ raise ValidationError(
+ 'You can only create A records in a delegated domain that have'
+ ' an NS record pointing to them.')
def check_glue_status(self):
"""If this record is a "glue" record for a Nameserver instance,
@@ -167,8 +171,9 @@ def check_glue_status(self):
# The label of the domain changed. Make sure it's not a glue record
Nameserver = cydns.nameserver.models.Nameserver
if Nameserver.objects.filter(addr_glue=self).exists():
- raise ValidationError("This record is a glue record for a"
- "Nameserver. Change the Nameserver to edit this record.")
+ raise ValidationError(
+ 'This record is a glue record for a Nameserver. Change '
+ 'the Nameserver to edit this record.')
def record_type(self):
# If PTR didn't share this field, we would use 'A' and 'AAAA'
@@ -188,9 +193,9 @@ class AddressRecord(BaseAddressRecord):
"""
id = models.AutoField(primary_key=True)
reverse_domain = models.ForeignKey(Domain, null=True, blank=True,
- related_name="addressrecordomain_set")
+ related_name='addressrecordomain_set')
class Meta:
- db_table = "address_record"
- unique_together = ("label", "domain", "fqdn", "ip_upper", "ip_lower",
- "ip_type")
+ db_table = 'address_record'
+ unique_together = ('label', 'domain', 'fqdn', 'ip_upper', 'ip_lower',
+ 'ip_type')
View
10 cyder/cydns/cname/models.py
@@ -23,9 +23,9 @@ class CNAME(CydnsRecord):
id = models.AutoField(primary_key=True)
target = models.CharField(max_length=100, validators=[validate_name],
help_text="CNAME Target")
- target_domain = models.ForeignKey(Domain, null=True,
- related_name='target_domains', blank=True,
- on_delete=models.SET_NULL)
+ target_domain = models.ForeignKey(
+ Domain, null=True, related_name='target_domains', blank=True,
+ on_delete=models.SET_NULL)
search_fields = ('fqdn', 'target')
@@ -37,10 +37,6 @@ def __str__(self):
return "{0} CNAME {1}".format(self.fqdn, self.target)
def details(self):
- return (
- )
-
- def details(self):
"""For tables."""
data = super(CNAME, self).details()
data['data'] = [
View
5 cyder/cydns/nameserver/models.py
@@ -32,8 +32,9 @@ class Nameserver(models.Model, ObjectUrlMixin):
id = models.AutoField(primary_key=True)
domain = models.ForeignKey(Domain, null=False, help_text="The domain this "
"record is for.")
- server = models.CharField(max_length=255, validators=[validate_name],
- help_text="The name of the server this records points to.")
+ server = models.CharField(
+ max_length=255, validators=[validate_name],
+ help_text="The name of the server this records points to.")
ttl = models.PositiveIntegerField(default=3600, blank=True, null=True,
validators=[validate_ttl])
# "If nameserver lies within domain, should have corresponding A record."
View
26 cyder/cydns/srv/models.py
@@ -4,12 +4,11 @@
import cydns
from cyder.cydns.mixins import ObjectUrlMixin
from cyder.cydns.domain.models import Domain
-from cyder.cydns.models import CydnsRecord
from cyder.cydns.soa.utils import update_soa
-from cyder.cydns.validation import (validate_name, validate_srv_label,
- validate_srv_port, validate_srv_priority,
- validate_srv_weight, validate_srv_name,
- validate_ttl, validate_srv_target)
+from cyder.cydns.validation import (validate_srv_label, validate_srv_port,
+ validate_srv_priority, validate_srv_weight,
+ validate_srv_name, validate_ttl,
+ validate_srv_target)
from cyder.cydns.view.models import View
@@ -25,9 +24,9 @@ class SRV(models.Model, ObjectUrlMixin):
... priority=priority, weight=weight, ttl=ttl)
"""
id = models.AutoField(primary_key=True)
- label = models.CharField(max_length=63, blank=True, null=True,
- validators=[validate_srv_label], help_text="Short name of the "
- "fqdn")
+ label = models.CharField(
+ max_length=63, blank=True, null=True, validators=[validate_srv_label],
+ help_text='Short name of the FQDN')
domain = models.ForeignKey(Domain, null=False, help_text="FQDN of the "
"domain after the short hostname. "
"(Ex: <i>Vlan</i>.<i>DC</i>.mozilla.com)")
@@ -67,17 +66,6 @@ def __repr__(self):
def details(self):
"""For tables."""
- return {
- 'metadata': [
- ('id', self.id),
- ('url', ''),
- ],
- 'data': [
- ]
- }
-
- def details(self):
- """For tables."""
data = super(SRV, self).details()
data['data'] = [
("Domain", self.domain),
View
11 cyder/cydns/sshfp/models.py
@@ -23,18 +23,18 @@ class SSHFP(CydnsRecord):
id = models.AutoField(primary_key=True)
key = models.TextField()
- algorithm_number = models.PositiveIntegerField(null=False, blank=False,
- validators=[validate_algorithm],
+ algorithm_number = models.PositiveIntegerField(
+ null=False, blank=False, validators=[validate_algorithm],
help_text='Algorithm number must be with 1 (RSA) or 2 (DSA)')
- fingerprint_type = models.PositiveIntegerField(null=False, blank=False,
- validators=[validate_fingerprint],
+ fingerprint_type = models.PositiveIntegerField(
+ null=False, blank=False, validators=[validate_fingerprint],
help_text='Fingerprint type must be 1 (SHA-1)')
search_fields = ("fqdn", "key")
def details(self):
"""For tables."""
- data = super(SRV, self).details()
+ data = super(SSHFP, self).details()
data['data'] = [
('Domain', self.fqdn),
('Algorithm', self.algorithm_number),
@@ -43,7 +43,6 @@ def details(self):
]
return data
-
def eg_metadata(self):
"""EditableGrid metadata."""
return {'metadata': [
View
1 cyder/cydns/txt/models.py
@@ -1,7 +1,6 @@
from django.db import models
from cyder.cydns.models import CydnsRecord
-import pdb
class TXT(CydnsRecord):

0 comments on commit 9ac4202

Please sign in to comment.