mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-19 10:59:21 +02:00
Update views.py
This commit is contained in:
parent
f8d2898836
commit
02456e9297
1 changed files with 8 additions and 1 deletions
|
@ -88,10 +88,17 @@ def available(request, domain=""):
|
||||||
"""
|
"""
|
||||||
domain = request.GET.get("domain", "")
|
domain = request.GET.get("domain", "")
|
||||||
DraftDomain = apps.get_model("registrar.DraftDomain")
|
DraftDomain = apps.get_model("registrar.DraftDomain")
|
||||||
|
if domain is None or domain.strip() == "":
|
||||||
|
# TODO - change this... should it be the regular required?
|
||||||
|
return JsonResponse({"available": False, "code": "invalid", "message": "This field is required"})
|
||||||
# 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, "code": "invalid", "message": DOMAIN_API_MESSAGES["invalid"]})
|
print(f"What is the domain at this point? {domain}")
|
||||||
|
if "." in domain:
|
||||||
|
return JsonResponse({"available": False, "code": "invalid", "message": DOMAIN_API_MESSAGES["extra_dots"]})
|
||||||
|
else:
|
||||||
|
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):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue