Skip to content

Commit

Permalink
only run sync stripe subscriptions middleware on pages that update su…
Browse files Browse the repository at this point in the history
…bscription
  • Loading branch information
Moggach committed Sep 2, 2024
1 parent 798da50 commit 240a3c4
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions app/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,14 @@ def update_stripe_customer_subscription(get_response):
# One-time configuration and initialization.

def middleware(request):
stripeless_request = (
request.path.startswith(settings.STATIC_URL)
or request.path.startswith(settings.MEDIA_URL)
or request.path.startswith("/anonymous/")
or settings.SHOPIFY_WEBHOOK_PATH in request.path
or settings.SHOPIFY_WEBHOOK_PATH == request.path
or request.path.startswith("/admin/")
or request.path.startswith("/django/")
or request.path.startswith("/oauth/")
or request.path.startswith("/documents/")
or request.path.startswith("/silk/")
or request.path.startswith("/__debug__/")
or "favicon.ico" in request.path
membership_request = (
'checkout/success' in request.path
or "accounts/cancel" in request.path
or "gift/redeemed" in request.path
or "update-membership/success" in request.path
)

if not stripeless_request:
if membership_request:
# Code to be executed for each request before
# the view (and later middleware) are called.
if request.user.is_authenticated:
Expand Down

0 comments on commit 240a3c4

Please sign in to comment.