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

Commit

Permalink
pep8 (hard 119 line length)
Browse files Browse the repository at this point in the history
  • Loading branch information
kavdev committed Sep 12, 2016
1 parent 83a88e5 commit f40f93a
Show file tree
Hide file tree
Showing 43 changed files with 1,641 additions and 577 deletions.
8 changes: 4 additions & 4 deletions djstripe/contrib/rest_framework/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SubscriptionRestView(APIView):

permission_classes = (IsAuthenticated,)

def get(self, request, format=None):
def get(self, request, **kwargs):
"""
Returns the customer's valid subscriptions.
Returns with status code 200.
Expand All @@ -40,7 +40,7 @@ def get(self, request, format=None):
except:
return Response(status=status.HTTP_204_NO_CONTENT)

def post(self, request, format=None):
def post(self, request, **kwargs):
"""
Create a new current subscription for the user.
Returns with status code 201.
Expand All @@ -50,7 +50,7 @@ def post(self, request, format=None):

if serializer.is_valid():
try:
customer, created = Customer.get_or_create(
customer, _created = Customer.get_or_create(
subscriber=subscriber_request_callback(self.request)
)
customer.add_card(serializer.data["stripe_token"])
Expand All @@ -68,7 +68,7 @@ def post(self, request, format=None):

return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

def delete(self, request, format=None):
def delete(self, request, **kwargs):
"""
Marks the users current subscription as cancelled.
Returns with status code 204.
Expand Down
28 changes: 24 additions & 4 deletions djstripe/event_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ def customer_webhook_handler(event, event_data, event_type, event_subtype):
if crud_type.valid and event.customer:
# As customers are tied to local users, djstripe will not create
# customers that do not already exist locally.
_handle_crud_type_event(target_cls=Customer, event_data=event_data, event_subtype=event_subtype, crud_type=crud_type)
_handle_crud_type_event(
target_cls=Customer,
event_data=event_data,
event_subtype=event_subtype,
crud_type=crud_type
)


@webhooks.handler("customer.source")
Expand All @@ -58,14 +63,24 @@ def customer_source_webhook_handler(

# TODO: other sources
if source_type == "card":
_handle_crud_type_event(target_cls=Card, event_data=event_data, event_subtype=event_subtype, customer=event.customer)
_handle_crud_type_event(
target_cls=Card,
event_data=event_data,
event_subtype=event_subtype,
customer=event.customer
)


@webhooks.handler("customer.subscription")
def customer_subscription_webhook_handler(event, event_data, event_type, event_subtype):
""" Handles updates for customer subscription objects. """

_handle_crud_type_event(target_cls=Subscription, event_data=event_data, event_subtype=event_subtype, customer=event.customer)
_handle_crud_type_event(
target_cls=Subscription,
event_data=event_data,
event_subtype=event_subtype,
customer=event.customer
)


@webhooks.handler(["transfer", "charge", "invoice", "invoiceitem", "plan"])
Expand All @@ -80,7 +95,12 @@ def other_object_webhook_handler(event, event_data, event_type, event_subtype):
"transfer": Transfer
}.get(event_type)

_handle_crud_type_event(target_cls=target_cls, event_data=event_data, event_subtype=event_subtype, customer=event.customer)
_handle_crud_type_event(
target_cls=target_cls,
event_data=event_data,
event_subtype=event_subtype,
customer=event.customer
)


#
Expand Down
3 changes: 2 additions & 1 deletion djstripe/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ class StripeBooleanField(StripeFieldMixin, models.BooleanField):

def __init__(self, *args, **kwargs):
if kwargs.get("deprecated", False):
raise ImproperlyConfigured("Boolean field cannot be deprecated. Change field type to StripeNullBooleanField")
raise ImproperlyConfigured("Boolean field cannot be deprecated. Change field type to "
"StripeNullBooleanField")
super(StripeBooleanField, self).__init__(*args, **kwargs)


Expand Down
73 changes: 48 additions & 25 deletions djstripe/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
from django.db import models, migrations
import jsonfield.fields
import django.utils.timezone
from django.conf import settings
import jsonfield.fields
import model_utils.fields


Expand All @@ -19,8 +19,10 @@ class Migration(migrations.Migration):
name='Charge',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now,
verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now,
verbose_name='modified', editable=False)),
('stripe_id', models.CharField(unique=True, max_length=50)),
('card_last_4', models.CharField(max_length=4, blank=True)),
('card_kind', models.CharField(max_length=50, blank=True)),
Expand All @@ -43,8 +45,10 @@ class Migration(migrations.Migration):
name='CurrentSubscription',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now,
verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now,
verbose_name='modified', editable=False)),
('plan', models.CharField(max_length=100)),
('quantity', models.IntegerField()),
('start', models.DateTimeField()),
Expand All @@ -67,8 +71,10 @@ class Migration(migrations.Migration):
name='Customer',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now,
verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now,
verbose_name='modified', editable=False)),
('stripe_id', models.CharField(unique=True, max_length=50)),
('card_fingerprint', models.CharField(max_length=200, blank=True)),
('card_last_4', models.CharField(max_length=4, blank=True)),
Expand All @@ -85,8 +91,10 @@ class Migration(migrations.Migration):
name='Event',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now,
verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now,
verbose_name='modified', editable=False)),
('stripe_id', models.CharField(unique=True, max_length=50)),
('kind', models.CharField(max_length=250)),
('livemode', models.BooleanField(default=False)),
Expand All @@ -105,8 +113,10 @@ class Migration(migrations.Migration):
name='EventProcessingException',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now,
verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now,
verbose_name='modified', editable=False)),
('data', models.TextField()),
('message', models.CharField(max_length=500)),
('traceback', models.TextField()),
Expand All @@ -121,8 +131,10 @@ class Migration(migrations.Migration):
name='Invoice',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now,
verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now,
verbose_name='modified', editable=False)),
('stripe_id', models.CharField(max_length=50)),
('attempted', models.NullBooleanField()),
('attempts', models.PositiveIntegerField(null=True)),
Expand All @@ -145,8 +157,10 @@ class Migration(migrations.Migration):
name='InvoiceItem',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now,
verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now,
verbose_name='modified', editable=False)),
('stripe_id', models.CharField(max_length=50)),
('amount', models.DecimalField(max_digits=7, decimal_places=2)),
('currency', models.CharField(max_length=10)),
Expand All @@ -168,13 +182,18 @@ class Migration(migrations.Migration):
name='Plan',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now,
verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now,
verbose_name='modified', editable=False)),
('stripe_id', models.CharField(unique=True, max_length=50)),
('name', models.CharField(max_length=100)),
('currency', models.CharField(max_length=10, choices=[('usd', 'U.S. Dollars'), ('gbp', 'Pounds (GBP)'), ('eur', 'Euros')])),
('interval', models.CharField(max_length=10, verbose_name='Interval type', choices=[('week', 'Week'), ('month', 'Month'), ('year', 'Year')])),
('interval_count', models.IntegerField(default=1, null=True, verbose_name='Intervals between charges')),
('currency', models.CharField(max_length=10, choices=[('usd', 'U.S. Dollars'),
('gbp', 'Pounds (GBP)'), ('eur', 'Euros')])),
('interval', models.CharField(max_length=10, verbose_name='Interval type',
choices=[('week', 'Week'), ('month', 'Month'), ('year', 'Year')])),
('interval_count', models.IntegerField(default=1, null=True,
verbose_name='Intervals between charges')),
('amount', models.DecimalField(verbose_name='Amount (per period)', max_digits=7, decimal_places=2)),
('trial_period_days', models.IntegerField(null=True)),
],
Expand All @@ -187,8 +206,10 @@ class Migration(migrations.Migration):
name='Transfer',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now,
verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now,
verbose_name='modified', editable=False)),
('stripe_id', models.CharField(unique=True, max_length=50)),
('amount', models.DecimalField(max_digits=7, decimal_places=2)),
('status', models.CharField(max_length=25)),
Expand Down Expand Up @@ -219,8 +240,10 @@ class Migration(migrations.Migration):
name='TransferChargeFee',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now,
verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now,
verbose_name='modified', editable=False)),
('amount', models.DecimalField(max_digits=7, decimal_places=2)),
('application', models.TextField(null=True, blank=True)),
('description', models.TextField(null=True, blank=True)),
Expand Down
Loading

0 comments on commit f40f93a

Please sign in to comment.