mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-19 02:49: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,9 +88,16 @@ def available(request, domain=""):
|
|||
"""
|
||||
domain = request.GET.get("domain", "")
|
||||
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
|
||||
# not.
|
||||
if not (DraftDomain.string_could_be_domain(domain) or DraftDomain.string_could_be_domain(domain + ".gov")):
|
||||
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
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue