mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-30 09:20:15 +02:00
Fix lint errors
This commit is contained in:
parent
2b91a3c1d1
commit
eda5e9751b
9 changed files with 27 additions and 23 deletions
|
@ -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(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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):
|
||||||
|
|
|
@ -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
|
||||||
|
@ -194,7 +196,7 @@ class Domain(TimeStampedModel):
|
||||||
def last_transfer_date(self):
|
def last_transfer_date(self):
|
||||||
return self._get_property("last_transfer_date")
|
return self._get_property("last_transfer_date")
|
||||||
|
|
||||||
name = models.CharField(
|
name = models.CharField(
|
||||||
max_length=253,
|
max_length=253,
|
||||||
blank=False,
|
blank=False,
|
||||||
default=None, # prevent saving without a value
|
default=None, # prevent saving without a value
|
||||||
|
|
|
@ -3,10 +3,11 @@ 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.
|
||||||
|
|
||||||
They may handle email, serve websites, or perform other tasks.
|
They may handle email, serve websites, or perform other tasks.
|
||||||
|
|
||||||
The registry is the source of truth for this data.
|
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
|
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,
|
||||||
blank=False,
|
blank=False,
|
||||||
|
|
|
@ -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",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -73,5 +73,3 @@ class MockUserLogin:
|
||||||
|
|
||||||
response = self.get_response(request)
|
response = self.get_response(request)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue