mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-18 15:34:16 +02:00
Merge pull request #1508 from cisagov/dk/125-check-availability-error
Issue #125: support for check availability messaging in beta.get.gov
This commit is contained in:
commit
69d5dd4d5c
2 changed files with 11 additions and 9 deletions
|
@ -91,15 +91,17 @@ def available(request, domain=""):
|
||||||
# validate that the given domain could be a domain name and fail early if
|
# validate that the given domain could be a domain name and fail early if
|
||||||
# not.
|
# not.
|
||||||
if not (DraftDomain.string_could_be_domain(domain) or DraftDomain.string_could_be_domain(domain + ".gov")):
|
if not (DraftDomain.string_could_be_domain(domain) or DraftDomain.string_could_be_domain(domain + ".gov")):
|
||||||
return JsonResponse({"available": False, "message": DOMAIN_API_MESSAGES["invalid"]})
|
return JsonResponse({"available": False, "code": "invalid", "message": DOMAIN_API_MESSAGES["invalid"]})
|
||||||
# a domain is available if it is NOT in the list of current domains
|
# a domain is available if it is NOT in the list of current domains
|
||||||
try:
|
try:
|
||||||
if check_domain_available(domain):
|
if check_domain_available(domain):
|
||||||
return JsonResponse({"available": True, "message": DOMAIN_API_MESSAGES["success"]})
|
return JsonResponse({"available": True, "code": "success", "message": DOMAIN_API_MESSAGES["success"]})
|
||||||
else:
|
else:
|
||||||
return JsonResponse({"available": False, "message": DOMAIN_API_MESSAGES["unavailable"]})
|
return JsonResponse(
|
||||||
|
{"available": False, "code": "unavailable", "message": DOMAIN_API_MESSAGES["unavailable"]}
|
||||||
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
return JsonResponse({"available": False, "message": DOMAIN_API_MESSAGES["error"]})
|
return JsonResponse({"available": False, "code": "error", "message": DOMAIN_API_MESSAGES["error"]})
|
||||||
|
|
||||||
|
|
||||||
@require_http_methods(["GET"])
|
@require_http_methods(["GET"])
|
||||||
|
|
|
@ -43,11 +43,11 @@ class GenericError(Exception):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_error_mapping = {
|
_error_mapping = {
|
||||||
GenericErrorCodes.CANNOT_CONTACT_REGISTRY: """
|
GenericErrorCodes.CANNOT_CONTACT_REGISTRY: (
|
||||||
We’re experiencing a system connection error. Please wait a few minutes
|
"We’re experiencing a system connection error. Please wait a few minutes "
|
||||||
and try again. If you continue to receive this error after a few tries,
|
"and try again. If you continue to receive this error after a few tries, "
|
||||||
contact help@get.gov.
|
"contact help@get.gov."
|
||||||
""",
|
),
|
||||||
GenericErrorCodes.GENERIC_ERROR: ("Value entered was wrong."),
|
GenericErrorCodes.GENERIC_ERROR: ("Value entered was wrong."),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue