Skip to content

Commit

Permalink
Only import django.contrib.sites if it is required
Browse files Browse the repository at this point in the history
Some sites may not need the extra dependency (if they send their own
receipts, for example).
  • Loading branch information
streeter committed Jun 17, 2016
1 parent 09234b5 commit b9d9a11
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pinax/stripe/hooks.py
Original file line number Diff line number Diff line change
@@ -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):

Expand Down Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions pinax/stripe/tests/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit b9d9a11

Please sign in to comment.