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
def domain_check(_):
""" Is domain available for registration? """
"""Is domain available for registration?"""
return True
def domain_info(domain):
""" What does the registry know about this domain? """
"""What does the registry know about this domain?"""
return {
"name": domain,
"roid": "EXAMPLE1-REP",
@ -36,5 +38,3 @@ def domain_info(domain):
"expiration_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 registrar.models import DomainApplication, Website
from registrar.models import DomainApplication, Domain
logger = logging.getLogger(__name__)
@ -134,8 +134,8 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
# This isn't really the requested_domain field
# but we need something in this field to make the form submittable
requested_site, _ = Website.objects.get_or_create(
website=contact_data["organization_name"] + ".gov"
requested_site, _ = Domain.objects.get_or_create(
name=contact_data["organization_name"] + ".gov"
)
application.requested_domain = requested_site
return application

View file

@ -4,7 +4,7 @@ from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import django_fsm
import django_fsm # type: ignore
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
application is approved
"""
class Meta:
constraints = [
# draft domains may share the same name, but
# once approved, they must be globally unique
models.UniqueConstraint(
fields=['name'],
fields=["name"],
condition=models.Q(is_active=True),
name='unique_domain_name_in_registry'
name="unique_domain_name_in_registry",
),
]
class Status(models.TextChoices):
"""The status codes we can receive from the registry."""
# Requests to delete the object MUST be rejected.
CLIENT_DELETE_PROHIBITED = "clientDeleteProhibited"
SERVER_DELETE_PROHIBITED = "serverDeleteProhibited"
@ -81,7 +83,6 @@ class Domain(TimeStampedModel):
PENDING_TRANSFER = "pendingTransfer"
PENDING_UPDATE = "pendingUpdate"
# 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
DOMAIN_REGEX = re.compile(r"^(?!-)[A-Za-z0-9-]{1,63}(?<!-)\.[A-Za-z]{2,6}")
@ -95,20 +96,21 @@ class Domain(TimeStampedModel):
@classmethod
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)
def transfer(self):
""" Going somewhere. Not implemented. """
"""Going somewhere. Not implemented."""
pass
def renew(self):
""" Time to renew. Not implemented. """
"""Time to renew. Not implemented."""
pass
def _get_property(self, property):
"""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"):
try:
# get info from registry
@ -194,7 +196,7 @@ class Domain(TimeStampedModel):
def last_transfer_date(self):
return self._get_property("last_transfer_date")
name = models.CharField(
name = models.CharField(
max_length=253,
blank=False,
default=None, # prevent saving without a value

View file

@ -3,10 +3,11 @@ from django.db import models
from .utility.time_stamped_model import TimeStampedModel
from .domain import Domain
class Host(TimeStampedModel):
"""
Hosts are internet-connected computers.
They may handle email, serve websites, or perform other tasks.
The registry is the source of truth for this data.
@ -14,7 +15,8 @@ class Host(TimeStampedModel):
This model exists ONLY to allow a new registrant to draft DNS entries
before their application is approved.
"""
name = models.CharField(
name = models.CharField(
max_length=253,
null=False,
blank=False,

View file

@ -4,6 +4,7 @@ from django.core.validators import validate_ipv46_address
from .utility.time_stamped_model import TimeStampedModel
from .host import Host
class HostIP(TimeStampedModel):
"""
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
before their application is approved.
"""
address = models.CharField(
max_length=46,
null=False,
@ -27,4 +29,3 @@ class HostIP(TimeStampedModel):
on_delete=models.PROTECT,
help_text="Host to which this IP address belongs",
)

View file

@ -1,5 +1,6 @@
from .host import Host
class Nameserver(Host):
"""
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
before their application is approved.
"""
pass
pass

View file

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

View file

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