Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only import django.contrib.sites if it is required #256

Merged
merged 1 commit into from
Jul 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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