Second revision of Domain model draft

This commit is contained in:
Seamus Johnston 2022-11-17 07:50:28 -06:00
parent 523c699865
commit 2b91a3c1d1
No known key found for this signature in database
GPG key ID: 2F21225985069105
12 changed files with 561 additions and 33 deletions

View file

@ -11,7 +11,7 @@ import requests
from cachetools.func import ttl_cache
from registrar.models import Website
from registrar.models import Domain
DOMAIN_FILE_URL = (
"https://raw.githubusercontent.com/cisagov/dotgov-data/main/current-full.csv"
@ -35,7 +35,7 @@ def _domains():
# get the domain before the first comma
domain = line.split(",", 1)[0]
# sanity-check the string we got from the file here
if Website.string_could_be_domain(domain):
if Domain.string_could_be_domain(domain):
# lowercase everything when we put it in domains
domains.add(domain.lower())
return domains
@ -68,8 +68,8 @@ def available(request, domain=""):
# validate that the given domain could be a domain name and fail early if
# not.
if not (
Website.string_could_be_domain(domain)
or Website.string_could_be_domain(domain + ".gov")
Domain.string_could_be_domain(domain)
or Domain.string_could_be_domain(domain + ".gov")
):
raise BadRequest("Invalid request.")
# a domain is available if it is NOT in the list of current domains