Fix lint errors

This commit is contained in:
Seamus Johnston 2022-11-17 08:26:41 -06:00
parent 2b91a3c1d1
commit eda5e9751b
No known key found for this signature in database
GPG key ID: 2F21225985069105
9 changed files with 27 additions and 23 deletions

View file

@ -4,12 +4,14 @@ communication with the registry until that integration is implemented.
""" """
from datetime import datetime from datetime import datetime
def domain_check(_): def domain_check(_):
""" Is domain available for registration? """ """Is domain available for registration?"""
return True return True
def domain_info(domain): def domain_info(domain):
""" What does the registry know about this domain? """ """What does the registry know about this domain?"""
return { return {
"name": domain, "name": domain,
"roid": "EXAMPLE1-REP", "roid": "EXAMPLE1-REP",
@ -36,5 +38,3 @@ def domain_info(domain):
"expiration_date": datetime.today(), "expiration_date": datetime.today(),
"last_transfer_date": datetime.today(), "last_transfer_date": datetime.today(),
} }

View file

@ -9,7 +9,7 @@ from django.contrib.auth.mixins import LoginRequiredMixin
from formtools.wizard.views import NamedUrlSessionWizardView # type: ignore from formtools.wizard.views import NamedUrlSessionWizardView # type: ignore
from registrar.models import DomainApplication, Website from registrar.models import DomainApplication, Domain
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -134,8 +134,8 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
# This isn't really the requested_domain field # This isn't really the requested_domain field
# but we need something in this field to make the form submittable # but we need something in this field to make the form submittable
requested_site, _ = Website.objects.get_or_create( requested_site, _ = Domain.objects.get_or_create(
website=contact_data["organization_name"] + ".gov" name=contact_data["organization_name"] + ".gov"
) )
application.requested_domain = requested_site application.requested_domain = requested_site
return application return application

View file

@ -4,7 +4,7 @@ from django.conf import settings
import django.core.validators import django.core.validators
from django.db import migrations, models from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
import django_fsm import django_fsm # type: ignore
class Migration(migrations.Migration): class Migration(migrations.Migration):

View file

@ -23,19 +23,21 @@ class Domain(TimeStampedModel):
2. To allow a new registrant to draft DNS entries before their 2. To allow a new registrant to draft DNS entries before their
application is approved application is approved
""" """
class Meta: class Meta:
constraints = [ constraints = [
# draft domains may share the same name, but # draft domains may share the same name, but
# once approved, they must be globally unique # once approved, they must be globally unique
models.UniqueConstraint( models.UniqueConstraint(
fields=['name'], fields=["name"],
condition=models.Q(is_active=True), condition=models.Q(is_active=True),
name='unique_domain_name_in_registry' name="unique_domain_name_in_registry",
), ),
] ]
class Status(models.TextChoices): class Status(models.TextChoices):
"""The status codes we can receive from the registry.""" """The status codes we can receive from the registry."""
# Requests to delete the object MUST be rejected. # Requests to delete the object MUST be rejected.
CLIENT_DELETE_PROHIBITED = "clientDeleteProhibited" CLIENT_DELETE_PROHIBITED = "clientDeleteProhibited"
SERVER_DELETE_PROHIBITED = "serverDeleteProhibited" SERVER_DELETE_PROHIBITED = "serverDeleteProhibited"
@ -81,7 +83,6 @@ class Domain(TimeStampedModel):
PENDING_TRANSFER = "pendingTransfer" PENDING_TRANSFER = "pendingTransfer"
PENDING_UPDATE = "pendingUpdate" PENDING_UPDATE = "pendingUpdate"
# a domain name is alphanumeric or hyphen, up to 63 characters, doesn't # a domain name is alphanumeric or hyphen, up to 63 characters, doesn't
# begin or end with a hyphen, followed by a TLD of 2-6 alphabetic characters # begin or end with a hyphen, followed by a TLD of 2-6 alphabetic characters
DOMAIN_REGEX = re.compile(r"^(?!-)[A-Za-z0-9-]{1,63}(?<!-)\.[A-Za-z]{2,6}") DOMAIN_REGEX = re.compile(r"^(?!-)[A-Za-z0-9-]{1,63}(?<!-)\.[A-Za-z]{2,6}")
@ -95,20 +96,21 @@ class Domain(TimeStampedModel):
@classmethod @classmethod
def available(cls, domain: str) -> bool: def available(cls, domain: str) -> bool:
"""Check if a domain is available. Not implemented. """ """Check if a domain is available. Not implemented."""
return domain_check(domain) return domain_check(domain)
def transfer(self): def transfer(self):
""" Going somewhere. Not implemented. """ """Going somewhere. Not implemented."""
pass pass
def renew(self): def renew(self):
""" Time to renew. Not implemented. """ """Time to renew. Not implemented."""
pass pass
def _get_property(self, property): def _get_property(self, property):
"""Get some info about a domain.""" """Get some info about a domain."""
if not self.is_active: return None if not self.is_active:
return None
if not hasattr(self, "info"): if not hasattr(self, "info"):
try: try:
# get info from registry # get info from registry

View file

@ -3,6 +3,7 @@ from django.db import models
from .utility.time_stamped_model import TimeStampedModel from .utility.time_stamped_model import TimeStampedModel
from .domain import Domain from .domain import Domain
class Host(TimeStampedModel): class Host(TimeStampedModel):
""" """
Hosts are internet-connected computers. Hosts are internet-connected computers.
@ -14,6 +15,7 @@ class Host(TimeStampedModel):
This model exists ONLY to allow a new registrant to draft DNS entries This model exists ONLY to allow a new registrant to draft DNS entries
before their application is approved. before their application is approved.
""" """
name = models.CharField( name = models.CharField(
max_length=253, max_length=253,
null=False, null=False,

View file

@ -4,6 +4,7 @@ from django.core.validators import validate_ipv46_address
from .utility.time_stamped_model import TimeStampedModel from .utility.time_stamped_model import TimeStampedModel
from .host import Host from .host import Host
class HostIP(TimeStampedModel): class HostIP(TimeStampedModel):
""" """
Hosts may have one or more IP addresses. Hosts may have one or more IP addresses.
@ -13,6 +14,7 @@ class HostIP(TimeStampedModel):
This model exists ONLY to allow a new registrant to draft DNS entries This model exists ONLY to allow a new registrant to draft DNS entries
before their application is approved. before their application is approved.
""" """
address = models.CharField( address = models.CharField(
max_length=46, max_length=46,
null=False, null=False,
@ -27,4 +29,3 @@ class HostIP(TimeStampedModel):
on_delete=models.PROTECT, on_delete=models.PROTECT,
help_text="Host to which this IP address belongs", help_text="Host to which this IP address belongs",
) )

View file

@ -1,5 +1,6 @@
from .host import Host from .host import Host
class Nameserver(Host): class Nameserver(Host):
""" """
A nameserver is a host which has been delegated to respond to DNS queries. A nameserver is a host which has been delegated to respond to DNS queries.
@ -9,4 +10,5 @@ class Nameserver(Host):
This model exists ONLY to allow a new registrant to draft DNS entries This model exists ONLY to allow a new registrant to draft DNS entries
before their application is approved. before their application is approved.
""" """
pass pass

View file

@ -73,5 +73,3 @@ class MockUserLogin:
response = self.get_response(request) response = self.get_response(request)
return response return response

View file

@ -85,7 +85,6 @@ class TestDomain(TestCase):
domain.save() domain.save()
self.assertIn("ok", domain.status) self.assertIn("ok", domain.status)
def test_fsm_activate_fail_unique(self): def test_fsm_activate_fail_unique(self):
# can't activate domain if name is not unique # can't activate domain if name is not unique
d1, _ = Domain.objects.get_or_create(name="igorville.gov") d1, _ = Domain.objects.get_or_create(name="igorville.gov")