Fixed style errors

This commit is contained in:
Leo Kivikunnas
2019-05-27 20:46:56 +03:00
parent 5832bd1765
commit c9962c4d8e
5 changed files with 11 additions and 14 deletions
+6 -6
View File
@@ -5,7 +5,7 @@ from django import forms
class IBANField(forms.CharField):
"""Field that validates Bank Account numbers
acording to the IBAN standard."""
acording to the IBAN standard."""
def to_python(self, data):
"""1. Remove spaces
@@ -18,26 +18,26 @@ class IBANField(forms.CharField):
print(data)
data.replace(" ", "")
data = data[4:] + data[0:4]
LETTERS = {letter: str(index) for index,
LETTERS = {letter: str(index) for index,
letter in enumerate(ascii_uppercase, start=10)}
data = data.upper()
data = [LETTERS[char] for char in data if char in LETTERS]
print(data)
print(data)
return ''.join(data)
def validate(self, data):
"""Validate value constructed by normalize"""
super().validate(data)
if int(data) % 97 != 1:
raise forms.ValidationError("Invalid IBAN number!")
return data
class ExpensesClaim(forms.Form):
"""Expenses claim form"""
name = forms.CharField(label='Nimi', max_length=100)
iban = IBANField(label='IBAN', max_length=100)
amount = forms.CharField(label="Summa", max_length=100)
+1 -2
View File
@@ -1,8 +1,7 @@
"""Expenses claim urls."""
from django.conf.urls import url
from django.conf import settings
from .views import *
from .views import claim
urlpatterns = [
+2 -4
View File
@@ -1,7 +1,6 @@
"""Expenses claim views."""
from django.shortcuts import render
from django.http import *
from django.views.decorators.http import require_http_methods
from .forms import ExpensesClaim
@@ -14,9 +13,8 @@ def claim(request):
form = ExpensesClaim(request.POST)
if form.is_valid():
return HttpResponse()
elif request.method == 'GET':
form = ExpensesClaim()
return render(request, 'claim.html', {'form': form})
+1 -1
View File
@@ -1,4 +1,4 @@
[pycodestyle]
max-line-length = 120
ignore = E501,E722
exclude = '*/migrations/*'
exclude = '*/migrations/*', venv/*
+1 -1
View File
@@ -41,7 +41,7 @@ urlpatterns = [
url(r'^kaehmy/', include('kaehmy.urls')),
url(r'^ohlhafv/', include('ohlhafv.urls')),
url(r'^expenses/', include('expenses_claim.urls')),
# favourite icon
url(r'^favicon\.ico$', favicon_view),