Merge branch 'main' into za/1403-add-aws-bucket

This commit is contained in:
zandercymatics 2023-12-04 12:58:34 -07:00
commit db54637ea5
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
29 changed files with 328 additions and 50 deletions

View file

@ -5,6 +5,8 @@ from django.http import HttpResponse, JsonResponse
from django.utils.safestring import mark_safe
from registrar.templatetags.url_helpers import public_site_url
from registrar.utility.errors import GenericError, GenericErrorCodes
import requests
from login_required import login_not_required
@ -31,7 +33,7 @@ DOMAIN_API_MESSAGES = {
),
"invalid": "Enter a domain using only letters, numbers, or hyphens (though we don't recommend using hyphens).",
"success": "That domain is available!",
"error": "Error finding domain availability.",
"error": GenericError.get_error_message(GenericErrorCodes.CANNOT_CONTACT_REGISTRY),
}
@ -64,17 +66,14 @@ def check_domain_available(domain):
The given domain is lowercased to match against the domains list. If the
given domain doesn't end with .gov, ".gov" is added when looking for
a match.
a match. If check fails, throws a RegistryError.
"""
Domain = apps.get_model("registrar.Domain")
try:
if domain.endswith(".gov"):
return Domain.available(domain)
else:
# domain search string doesn't end with .gov, add it on here
return Domain.available(domain + ".gov")
except Exception:
return False
if domain.endswith(".gov"):
return Domain.available(domain)
else:
# domain search string doesn't end with .gov, add it on here
return Domain.available(domain + ".gov")
@require_http_methods(["GET"])