From b9d9a112a7b0b61843bd7c77e232f602e8e6f4df Mon Sep 17 00:00:00 2001 From: Chris Streeter Date: Mon, 11 Apr 2016 08:40:58 -0700 Subject: [PATCH] Only import django.contrib.sites if it is required Some sites may not need the extra dependency (if they send their own receipts, for example). --- pinax/stripe/hooks.py | 5 +++-- pinax/stripe/tests/hooks.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pinax/stripe/hooks.py b/pinax/stripe/hooks.py index f1d10d6a1..19da66c6a 100644 --- a/pinax/stripe/hooks.py +++ b/pinax/stripe/hooks.py @@ -1,8 +1,6 @@ from django.core.mail import EmailMessage from django.template.loader import render_to_string -from django.contrib.sites.models import Site - class DefaultHookSet(object): @@ -30,6 +28,9 @@ def trial_period(self, user, plan): def send_receipt(self, charge): from django.conf import settings if not charge.receipt_sent: + # Import here to not add a hard dependency on the Sites framework + from django.contrib.sites.models import Site + site = Site.objects.get_current() protocol = getattr(settings, "DEFAULT_HTTP_PROTOCOL", "http") ctx = { diff --git a/pinax/stripe/tests/hooks.py b/pinax/stripe/tests/hooks.py index 475cb02f9..2662f1d79 100644 --- a/pinax/stripe/tests/hooks.py +++ b/pinax/stripe/tests/hooks.py @@ -5,8 +5,6 @@ from django.template.loader import render_to_string from django.utils import timezone -from django.contrib.sites.models import Site - from ..hooks import DefaultHookSet @@ -34,6 +32,8 @@ def trial_period(self, user, plan): def send_receipt(self, charge): if not charge.receipt_sent: + from django.contrib.sites.models import Site + site = Site.objects.get_current() protocol = getattr(settings, "DEFAULT_HTTP_PROTOCOL", "http") ctx = {