Flake8 fixes

This commit is contained in:
Sachi King 2017-04-22 19:06:30 +10:00
parent 9719546bda
commit d360e880d9
8 changed files with 40 additions and 31 deletions

View file

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

View file

@ -3,7 +3,6 @@ from registripe import models
from django import forms from django import forms
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.core.exceptions import ValidationError
from django.db.models import F, Q from django.db.models import F, Q
from django.forms import widgets from django.forms import widgets
from django.utils import timezone from django.utils import timezone
@ -12,8 +11,6 @@ from django_countries import countries
from django_countries.fields import LazyTypedChoiceField from django_countries.fields import LazyTypedChoiceField
from django_countries.widgets import CountrySelectWidget from django_countries.widgets import CountrySelectWidget
from pinax.stripe import models as pinax_stripe_models
class NoRenderWidget(forms.widgets.HiddenInput): class NoRenderWidget(forms.widgets.HiddenInput):
@ -101,7 +98,7 @@ class CreditCardForm(forms.Form):
stripe_token = forms.CharField( stripe_token = forms.CharField(
max_length=255, max_length=255,
#required=True, # required=True,
widget=NoRenderWidget(), widget=NoRenderWidget(),
) )
@ -177,8 +174,7 @@ class StripeRefundForm(forms.Form):
q2 = ( q2 = (
Q(charge__amount_refunded__isnull=False) & Q(charge__amount_refunded__isnull=False) &
Q(charge__amount__gte=( Q(charge__amount__gte=(
F("charge__amount_refunded") + min_value) F("charge__amount_refunded") + min_value))
)
) )
qs = qs.filter(q1 | q2) qs = qs.filter(q1 | q2)
@ -195,15 +191,22 @@ From stripe.js details:
Card details: Card details:
The first argument to createToken is a JavaScript object containing credit card data entered by the user. It should contain the following required members: The first argument to createToken is a JavaScript object containing credit
card data entered by the user. It should contain the following required
members:
number: card number as a string without any separators (e.g., "4242424242424242") number: card number as a string without any separators
exp_month: two digit number representing the card's expiration month (e.g., 12) (e.g., "4242424242424242")
exp_year: two or four digit number representing the card's expiration year (e.g., 2017) exp_month: two digit number representing the card's expiration month
(e.g., 12)
exp_year: two or four digit number representing the card's expiration year
(e.g., 2017)
(The expiration date can also be passed as a single string.) (The expiration date can also be passed as a single string.)
cvc: optional, but we highly recommend you provide it to help prevent fraud. This is the card's security code, as a string (e.g., "123"). cvc: optional, but we highly recommend you provide it to help prevent fraud.
The following fields are entirely optional and cannot result in a token creation failure: This is the card's security code, as a string (e.g., "123").
The following fields are entirely optional and cannot result in a token
creation failure:
name: cardholder name name: cardholder name
address_line1: billing address line 1 address_line1: billing address line 1

View file

@ -19,8 +19,15 @@ class Migration(migrations.Migration):
migrations.CreateModel( migrations.CreateModel(
name='StripePayment', name='StripePayment',
fields=[ fields=[
('paymentbase_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='registrasion.PaymentBase')), ('paymentbase_ptr', models.OneToOneField(
('charge', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='pinax_stripe.Charge')), auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True, primary_key=True, serialize=False,
to='registrasion.PaymentBase')),
('charge',
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to='pinax_stripe.Charge')),
], ],
bases=('registrasion.paymentbase',), bases=('registrasion.paymentbase',),
), ),

View file

@ -18,8 +18,15 @@ class Migration(migrations.Migration):
migrations.CreateModel( migrations.CreateModel(
name='StripeCreditNoteRefund', name='StripeCreditNoteRefund',
fields=[ fields=[
('creditnoterefund_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='registrasion.CreditNoteRefund')), ('creditnoterefund_ptr', models.OneToOneField(
('charge', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='pinax_stripe.Charge')), auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True, primary_key=True, serialize=False,
to='registrasion.CreditNoteRefund')),
('charge',
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to='pinax_stripe.Charge')),
], ],
bases=('registrasion.creditnoterefund',), bases=('registrasion.creditnoterefund',),
), ),

View file

@ -9,6 +9,7 @@ class StripePayment(commerce.PaymentBase):
charge = models.ForeignKey(Charge) charge = models.ForeignKey(Charge)
class StripeCreditNoteRefund(commerce.CreditNoteRefund): class StripeCreditNoteRefund(commerce.CreditNoteRefund):
charge = models.ForeignKey(Charge) charge = models.ForeignKey(Charge)

View file

@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View file

@ -2,14 +2,13 @@ from django.conf.urls import url
from registripe import views from registripe import views
from pinax.stripe.views import ( from pinax.stripe.views import Webhook
Webhook,
)
urlpatterns = [ urlpatterns = [
url(r"^card/([0-9]*)/$", views.card, name="registripe_card"), url(r"^card/([0-9]*)/$", views.card, name="registripe_card"),
url(r"^card/([0-9]*)/([0-9A-Za-z]*)/$", views.card, name="registripe_card"), url(r"^card/([0-9]*)/([0-9A-Za-z]*)/$", views.card,
name="registripe_card"),
url(r"^pubkey/$", views.pubkey_script, name="registripe_pubkey"), url(r"^pubkey/$", views.pubkey_script, name="registripe_pubkey"),
url(r"^refund/([0-9]*)/$", views.refund, name="registripe_refund"), url(r"^refund/([0-9]*)/$", views.refund, name="registripe_refund"),
url(r"^webhook/$", Webhook.as_view(), name="pinax_stripe_webhook"), url(r"^webhook/$", Webhook.as_view(), name="pinax_stripe_webhook"),

View file

@ -12,10 +12,8 @@ from django.shortcuts import redirect, render
from registrasion.controllers.credit_note import CreditNoteController from registrasion.controllers.credit_note import CreditNoteController
from registrasion.controllers.invoice import InvoiceController from registrasion.controllers.invoice import InvoiceController
from registrasion.models import commerce
from pinax.stripe import actions from pinax.stripe import actions
from pinax.stripe.actions import refunds as pinax_stripe_actions_refunds
from stripe.error import StripeError from stripe.error import StripeError
@ -67,7 +65,7 @@ def card(request, invoice_id, access_code=None):
if request.POST and form.is_valid(): if request.POST and form.is_valid():
try: try:
inv.validate_allowed_to_pay() # Verify that we're allowed to do this. inv.validate_allowed_to_pay()
process_card(request, form, inv) process_card(request, form, inv)
return to_invoice return to_invoice
except StripeError as e: except StripeError as e:
@ -107,7 +105,7 @@ def process_card(request, form, inv):
card = actions.sources.create_card(customer, token) card = actions.sources.create_card(customer, token)
description="Payment for %s invoice #%s" % ( description = "Payment for %s invoice #%s" % (
conference.title, inv.invoice.id conference.title, inv.invoice.id
) )
@ -187,7 +185,7 @@ def process_refund(cn, form):
"the credit note." "the credit note."
) )
refund = actions.refunds.create(charge, to_refund) refund = actions.refunds.create(charge, to_refund) # noqa
models.StripeCreditNoteRefund.objects.create( models.StripeCreditNoteRefund.objects.create(
parent=cn.credit_note, parent=cn.credit_note,