Respond to PR feedback

This commit is contained in:
Seamus Johnston 2023-01-17 09:52:23 -06:00
parent f6c70f88a9
commit 0f87d9ea9a
No known key found for this signature in database
GPG key ID: 2F21225985069105
31 changed files with 392 additions and 355 deletions

View file

@ -1,6 +1,6 @@
"""Internal API views"""
from django.apps import apps
from django.core.exceptions import BadRequest
from django.views.decorators.http import require_http_methods
from django.http import JsonResponse
@ -11,7 +11,6 @@ import requests
from cachetools.func import ttl_cache
from registrar.models import Domain
DOMAIN_FILE_URL = (
"https://raw.githubusercontent.com/cisagov/dotgov-data/main/current-full.csv"
@ -27,6 +26,7 @@ def _domains():
Fetch a file from DOMAIN_FILE_URL, parse the CSV for the domain,
lowercase everything and return the list.
"""
Domain = apps.get_model("registrar.Domain")
# 5 second timeout
file_contents = requests.get(DOMAIN_FILE_URL, timeout=5).text
domains = set()
@ -65,6 +65,7 @@ def available(request, domain=""):
Response is a JSON dictionary with the key "available" and value true or
false.
"""
Domain = apps.get_model("registrar.Domain")
# validate that the given domain could be a domain name and fail early if
# not.
if not (