Skip to content

Commit

Permalink
easier to read view
Browse files Browse the repository at this point in the history
  • Loading branch information
smithellis committed Jan 8, 2025
1 parent ff166a0 commit 49638c1
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions kitsune/sumo/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,16 @@ def deprecated_redirect(request, url, **kwargs):

def robots(request):
"""Generate a robots.txt."""
# If our settings say not to engage robots, or if we're not on
# https://support.mozilla.org (i.e. we're on stage, dev, non-canonical, etc.),
# then we should disallow all robots.
# Disallow all robots if settings say not to engage robots
if not settings.ENGAGE_ROBOTS:
template = "User-Agent: *\nDisallow: /"
else:
if not request.build_absolute_uri("/").startswith("https://support.mozilla.org"):
# Disallow all robots on non-canonical domains.
template = "User-Agent: *\nDisallow: /"
else:
template = render(request, "sumo/robots.html")
return HttpResponse(template, content_type="text/plain")
return HttpResponse("User-Agent: *\nDisallow: /", content_type="text/plain")

# Disallow all robots if we're not on https://support.mozilla.org
if not request.build_absolute_uri("/").startswith("https://support.mozilla.org"):
return HttpResponse("User-Agent: *\nDisallow: /", content_type="text/plain")

# Allow robots on the canonical domain
return render(request, "sumo/robots.html", content_type="text/plain")


def manifest(request):
Expand Down

0 comments on commit 49638c1

Please sign in to comment.