Added Flake8 lib and fixed PEP8 violations

This commit is contained in:
Siarhei Puhach 2017-06-29 17:34:40 +03:00
commit edcfd3e9f4
65 changed files with 340 additions and 387 deletions

View file

@ -1,5 +1,5 @@
from django.contrib import admin
from .models import BillingAddress, UserBillingAddress
from .models import UserBillingAddress
# Register your models here.

View file

@ -1,6 +1,5 @@
from django.utils.translation import ugettext as _
from django.db import models
from django import forms
# http://xml.coverpages.org/country3166.html
COUNTRIES = (
@ -255,4 +254,4 @@ class CountryField(models.CharField):
super(CountryField, self).__init__(*args, **kwargs)
def get_internal_type(self):
return "CharField"
return "CharField"

View file

@ -115,7 +115,8 @@ class BillingAddressForm(forms.ModelForm):
class UserBillingAddressForm(forms.ModelForm):
user = forms.ModelChoiceField(queryset=CustomUser.objects.all(),
widget=forms.HiddenInput())
widget=forms.HiddenInput())
class Meta:
model = UserBillingAddress
fields = ['street_address', 'city', 'postal_code', 'country', 'user']
@ -126,6 +127,7 @@ class UserBillingAddressForm(forms.ModelForm):
'Country': _('Country'),
}
class ContactUsForm(forms.ModelForm):
error_css_class = 'autofocus'

View file

@ -77,4 +77,3 @@ class DigitalGlarusRegistrationMailer(BaseMailer):
self.registration = self.message
self._message = self._message.format(slug=self._slug)
super().__init__()

View file

@ -1,6 +1,4 @@
from django.db import models
from django.core import serializers
from django.forms.models import model_to_dict
from membership.models import CustomUser
@ -18,6 +16,7 @@ class BaseBillingAddress(models.Model):
class Meta:
abstract = True
class BillingAddress(BaseBillingAddress):
def __str__(self):

View file

@ -127,22 +127,10 @@ class StripeUtils(object):
id=id)
@handleStripeError
def make_payment(self, user, amount, token):
def make_payment(self, customer, amount, token):
charge = self.stripe.Charge.create(
amount=amount, # in cents
currency=self.CURRENCY,
customer=customer
)
return charge
@handleStripeError
def create_plan(self, amount, name, id):
self.stripe.Plan.create(
amount=amount,
interval=self.INTERVAL,
name=name,
currency=self.CURRENCY,
id=id)