Skip to content

Commit

Permalink
Merge branch 'master' into hotfix/replace-blanks-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismaddalena authored Sep 25, 2024
2 parents 8dfc267 + 1137f9d commit 525ba79
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ghostwriter/shepherd/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 --"
Expand Down
17 changes: 17 additions & 0 deletions ghostwriter/shepherd/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"])
Expand Down Expand Up @@ -840,8 +853,12 @@ def fetch_namecheap_domains():
] = "<p>Namecheap has locked the domain. This is usually the result of a legal complaint related to phishing/malicious activities.</p>"

# 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")
Expand Down

0 comments on commit 525ba79

Please sign in to comment.