mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 18:09:25 +02:00
Fix logic of availability API
This commit is contained in:
parent
1644109292
commit
ff44ee2f1e
5 changed files with 39 additions and 36 deletions
|
@ -50,8 +50,8 @@ def _domains():
|
|||
return domains
|
||||
|
||||
|
||||
def in_domains(domain):
|
||||
"""Return true if the given domain is in the domains list.
|
||||
def check_domain_available(domain):
|
||||
"""Return true if the given domain is available.
|
||||
|
||||
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
|
||||
|
@ -83,11 +83,11 @@ def available(request, domain=""):
|
|||
{"available": False, "message": DOMAIN_API_MESSAGES["invalid"]}
|
||||
)
|
||||
# a domain is available if it is NOT in the list of current domains
|
||||
if in_domains(domain):
|
||||
return JsonResponse(
|
||||
{"available": False, "message": DOMAIN_API_MESSAGES["unavailable"]}
|
||||
)
|
||||
else:
|
||||
if check_domain_available(domain):
|
||||
return JsonResponse(
|
||||
{"available": True, "message": DOMAIN_API_MESSAGES["success"]}
|
||||
)
|
||||
else:
|
||||
return JsonResponse(
|
||||
{"available": False, "message": DOMAIN_API_MESSAGES["unavailable"]}
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue