diff --git a/ghostwriter/shepherd/forms.py b/ghostwriter/shepherd/forms.py index d8444ad00..41b9689eb 100644 --- a/ghostwriter/shepherd/forms.py +++ b/ghostwriter/shepherd/forms.py @@ -183,7 +183,7 @@ def __init__(self, *args, **kwargs): for field in self.fields: self.fields[field].widget.attrs["autocomplete"] = "off" self.fields["name"].widget.attrs["placeholder"] = "ghostwriter.wiki" - self.fields["registrar"].widget.attrs["placeholder"] = "NameCheap" + self.fields["registrar"].widget.attrs["placeholder"] = "Namecheap" self.fields["domain_status"].empty_label = "-- Select Status --" self.fields["whois_status"].empty_label = "-- Select Status --" self.fields["health_status"].empty_label = "-- Select Status --" diff --git a/ghostwriter/shepherd/tasks.py b/ghostwriter/shepherd/tasks.py index 1e994fef8..922683486 100644 --- a/ghostwriter/shepherd/tasks.py +++ b/ghostwriter/shepherd/tasks.py @@ -760,6 +760,7 @@ def fetch_namecheap_domains(): domain_queryset = Domain.objects.filter(registrar="Namecheap") expired_status = DomainStatus.objects.get(domain_status="Expired") burned_status = DomainStatus.objects.get(domain_status="Burned") + available_status = DomainStatus.objects.get(domain_status="Available") health_burned_status = HealthStatus.objects.get(health_status="Burned") for domain in domain_queryset: # Check if a domain in the library is _not_ in the Namecheap response @@ -799,6 +800,18 @@ def fetch_namecheap_domains(): domain=domain, note="Automatically set to Expired because the domain did not appear in Namecheap during a sync.", ) + # Catch domains that were marked as expired but are now back in the Namecheap data + else: + if domain.expired: + logger.info("Domain %s is marked as expired but is now back in the Namecheap data", domain.name) + domain_changes["updates"][domain.id] = {} + domain_changes["updates"][domain.id]["domain"] = domain.name + domain_changes["updates"][domain.id]["change"] = "renewed" + domain.expired = False + if domain.domain_status == expired_status: + domain.domain_status = available_status + domain.save() + # Now, loop over every domain returned by Namecheap for domain in domains_list: logger.info("Domain %s is now being processed", domain["Name"]) @@ -840,8 +853,12 @@ def fetch_namecheap_domains(): ] = "
Namecheap has locked the domain. This is usually the result of a legal complaint related to phishing/malicious activities.
" # Set AutoRenew status + # Ignore Namecheap's `AutoRenew` value if the domain is expired (both can be true) if domain["AutoRenew"] == "false" or domain["IsExpired"] == "true": entry["auto_renew"] = False + # Ensure the domain's auto-renew status in the database matches Namecheap + elif domain["AutoRenew"] == "true": + entry["auto_renew"] = True # Convert Namecheap dates to Django entry["creation"] = datetime.strptime(domain["Created"], "%m/%d/%Y").strftime("%Y-%m-%d")