From 7401b4a3c397e4f07f7bda7e9a265a8ed142e70b Mon Sep 17 00:00:00 2001 From: "russell@unturf.com" Date: Tue, 10 Feb 2026 08:54:51 -0500 Subject: [PATCH] Fix 502s from anonymous visitors: guard request.user.can_edit_shop with null check Bot crawlers (AhrefsBot, SemrushBot) hitting content pages caused jinja2.UndefinedError: 'None' has no attribute 'can_edit_shop' because request.user is None for unauthenticated visitors. --- make_post_sell/templates/base.j2 | 4 ++-- make_post_sell/templates/content.j2 | 4 ++-- make_post_sell/templates/markup_renderer.j2 | 2 +- make_post_sell/templates/product.j2 | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/make_post_sell/templates/base.j2 b/make_post_sell/templates/base.j2 index 20e077d..69e72c6 100644 --- a/make_post_sell/templates/base.j2 +++ b/make_post_sell/templates/base.j2 @@ -151,14 +151,14 @@
- {% if request.is_saas_domain or request.user.can_edit_shop(request.shop) %} + {% if request.is_saas_domain or request.user and request.user.can_edit_shop(request.shop) %} ☰   {{ request.shop.name }} {% endif %}
{% block call_to_action %} - {% if request.is_saas_domain or request.user.can_edit_shop(request.shop) %} + {% if request.is_saas_domain or request.user and request.user.can_edit_shop(request.shop) %} {% if request.user.shops %} + New {% else %} diff --git a/make_post_sell/templates/content.j2 b/make_post_sell/templates/content.j2 index d333da6..fc2c111 100644 --- a/make_post_sell/templates/content.j2 +++ b/make_post_sell/templates/content.j2 @@ -22,7 +22,7 @@ {%- block call_to_action -%} -{% if request.user.can_edit_shop(request.shop) %} +{% if request.user and request.user.can_edit_shop(request.shop) %} ✎ Edit {% endif %} {%- endblock call_to_action -%} @@ -32,7 +32,7 @@
-{% if request.shop.watch_mode_enabled %}
{% endif %} +{% if request.shop.watch_mode_enabled %}
{% endif %}
{% set video_extensions = ["mp4", "avi", "mov", "wmv", "flv", "mkv", "webm", "m4v"] %} diff --git a/make_post_sell/templates/markup_renderer.j2 b/make_post_sell/templates/markup_renderer.j2 index fb964fd..e5be529 100644 --- a/make_post_sell/templates/markup_renderer.j2 +++ b/make_post_sell/templates/markup_renderer.j2 @@ -1,7 +1,7 @@ {% extends "base.j2" -%} {%- block call_to_action -%} -{% if request.user.can_edit_shop(request.shop) %} +{% if request.user and request.user.can_edit_shop(request.shop) %} ✎ Edit {% endif %} {%- endblock call_to_action -%} diff --git a/make_post_sell/templates/product.j2 b/make_post_sell/templates/product.j2 index 43e8bec..cabeeaf 100644 --- a/make_post_sell/templates/product.j2 +++ b/make_post_sell/templates/product.j2 @@ -21,7 +21,7 @@ {%- endblock append_to_head_tag_section -%} {%- block call_to_action -%} -{% if request.user.can_edit_shop(request.shop) %} +{% if request.user and request.user.can_edit_shop(request.shop) %} ✎ Edit {% endif %} {%- endblock call_to_action -%} @@ -30,7 +30,7 @@
-{% if request.shop.watch_mode_enabled %}
{% endif %} +{% if request.shop.watch_mode_enabled %}
{% endif %}

{{ product.title }}
sold by {{ product.shop.name }}