Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request dj-stripe#414 from jleclanche/cleanup/misc
Browse files Browse the repository at this point in the history
Misc. cleanups
  • Loading branch information
kavdev authored Mar 13, 2017
2 parents 15afd97 + 9ca930f commit c5d0a8f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 50 deletions.
17 changes: 0 additions & 17 deletions djstripe/migrations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1 @@
"""
Migrations have been built for Django=>1.7 versions. Alternative migrations
for Django<1.7 users are provided with the ``south_migrations`` dir.

"""

SOUTH_ERROR_MESSAGE = """\n
For South support, customize the SOUTH_MIGRATION_MODULES setting like so:
SOUTH_MIGRATION_MODULES = {
'djstripe': 'djstripe.south_migrations',
}
"""

try:
from django.db import migrations # noqa
except ImportError:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured(SOUTH_ERROR_MESSAGE)
12 changes: 0 additions & 12 deletions djstripe/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@
"""
from __future__ import unicode_literals

import sys

from django.apps import apps as django_apps
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils import six
from django.utils.module_loading import import_string

PY3 = sys.version > "3"


def get_callback_function(setting_name, default=None):
"""
Expand Down Expand Up @@ -58,19 +54,11 @@ def get_callback_function(setting_name, default=None):
PAYMENTS_PLANS = getattr(settings, "DJSTRIPE_PLANS", {})
PLAN_HIERARCHY = getattr(settings, "DJSTRIPE_PLAN_HIERARCHY", {})

PASSWORD_INPUT_RENDER_VALUE = getattr(settings, 'DJSTRIPE_PASSWORD_INPUT_RENDER_VALUE', False)
PASSWORD_MIN_LENGTH = getattr(settings, 'DJSTRIPE_PASSWORD_MIN_LENGTH', 6)

PRORATION_POLICY = getattr(settings, 'DJSTRIPE_PRORATION_POLICY', False)
PRORATION_POLICY_FOR_UPGRADES = getattr(settings, 'DJSTRIPE_PRORATION_POLICY_FOR_UPGRADES', False)
CANCELLATION_AT_PERIOD_END = not getattr(settings, 'DJSTRIPE_PRORATION_POLICY', False)

SEND_INVOICE_RECEIPT_EMAILS = getattr(settings, "DJSTRIPE_SEND_INVOICE_RECEIPT_EMAILS", True)
CURRENCIES = getattr(settings, "DJSTRIPE_CURRENCIES", (
('usd', 'U.S. Dollars',),
('gbp', 'Pounds (GBP)',),
('eur', 'Euros',))
)

DEFAULT_PLAN = getattr(settings, "DJSTRIPE_DEFAULT_PLAN", None)

Expand Down
5 changes: 1 addition & 4 deletions djstripe/templatetags/djstripe_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
register = Library()


@register.filter
@register.filter(is_safe=False)
def djdiv(value, arg):
"""
Divide the value by the arg, using Python 3-style division that returns floats.
Expand All @@ -30,9 +30,6 @@ def djdiv(value, arg):
return ''


division.is_safe = False


@register.filter(name='djstripe_plan_level')
def djstripe_plan_level(name):
"""
Expand Down
2 changes: 1 addition & 1 deletion djstripe/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# ============================================================================ #


class AccountView(LoginRequiredMixin, SelectRelatedMixin, SubscriptionMixin, PaymentsContextMixin, TemplateView):
class AccountView(LoginRequiredMixin, SubscriptionMixin, PaymentsContextMixin, TemplateView):
"""Shows account details including customer and subscription details."""

template_name = "djstripe/account.html"
Expand Down
25 changes: 10 additions & 15 deletions docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Settings
DJSTRIPE_DEFAULT_PLAN (=None)
=============================

Payment plans default.
Payment plans default.

Possibly deprecated in favor of model based plans.

Expand All @@ -17,7 +17,7 @@ Invoice emails come from this address.
DJSTRIPE_PLANS (={})
====================

Payment plans.
Payment plans.

Possibly deprecated in favor of model based plans.

Expand Down Expand Up @@ -60,7 +60,7 @@ Example:
DJSTRIPE_PLAN_HIERARCHY (={})
=============================

Payment plans levels.
Payment plans levels.

Allows you to set levels of access to the plans.

Expand Down Expand Up @@ -130,11 +130,11 @@ Example:
{% elif customer.subscription|djstripe_plan_level > plan.plan|djstripe_plan_level %}
<h4>Downgrade</h4>
{% endif %}
DJSTRIPE_PRORATION_POLICY (=False)
==================================

By default, plans are not prorated in dj-stripe. Concretely, this is how this translates:
By default, plans are not prorated in dj-stripe. Concretely, this is how this translates:

1) If a customer cancels their plan during a trial, the cancellation is effective right away.
2) If a customer cancels their plan outside of a trial, their subscription remains active until the subscription's period end, and they do not receive a refund.
Expand Down Expand Up @@ -207,7 +207,7 @@ Example Model:
name = CharField(max_length=200, unique=True)
subdomain = CharField(max_length=63, unique=True, verbose_name="Organization Subdomain")
owner = ForeignKey(settings.AUTH_USER_MODEL, related_name="organization_owner", verbose_name="Organization Owner")
@property
def email(self):
return self.owner.email
Expand All @@ -232,7 +232,7 @@ Examples:
class DynamicOrganizationIDMiddleware(object):
""" Adds the current organization's ID based on the subdomain."""
def process_request(self, request):
subdomain = parse_subdomain(request.get_host())
Expand All @@ -242,7 +242,7 @@ Examples:
return TemplateResponse(request=request, template='404.html', status=404)
else:
organization_id = organization.id
request.organization_id = organization_id
`settings.py`
Expand All @@ -251,7 +251,7 @@ Examples:
def organization_request_callback(request):
""" Gets an organization instance from the id passed through ``request``"""
from <models_path> import Organization # Import models here to avoid an ``AppRegistryNotReady`` exception
return Organization.objects.get(id=request.organization_id)
Expand Down Expand Up @@ -279,7 +279,7 @@ Examples:
Adds a static trial period of 7 days to each subscriber's plan,
unless they've accepted our month-long promotion.
"""
if subscriber.coupons.get(slug="monthlongtrial"):
return 30
else:
Expand Down Expand Up @@ -336,8 +336,3 @@ Examples:
.. code-block:: python
DJSTRIPE_WEBHOOK_EVENT_CALLBACK = 'callbacks.webhook_event_callback'
DJSTRIPE_CURRENCIES (=(('usd', 'U.S. Dollars',), ('gbp', 'Pounds (GBP)',), ('eur', 'Euros',)))
==============================================================================================

A Field.choices list of allowed currencies for Plan models.
2 changes: 1 addition & 1 deletion tests/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def empty_view(request):
return HttpResponse
return HttpResponse()


urlpatterns = [
Expand Down

0 comments on commit c5d0a8f

Please sign in to comment.