Fixed style errors
This commit is contained in:
@@ -5,7 +5,7 @@ from django import forms
|
|||||||
|
|
||||||
class IBANField(forms.CharField):
|
class IBANField(forms.CharField):
|
||||||
"""Field that validates Bank Account numbers
|
"""Field that validates Bank Account numbers
|
||||||
acording to the IBAN standard."""
|
acording to the IBAN standard."""
|
||||||
|
|
||||||
def to_python(self, data):
|
def to_python(self, data):
|
||||||
"""1. Remove spaces
|
"""1. Remove spaces
|
||||||
@@ -18,26 +18,26 @@ class IBANField(forms.CharField):
|
|||||||
print(data)
|
print(data)
|
||||||
data.replace(" ", "")
|
data.replace(" ", "")
|
||||||
data = data[4:] + data[0:4]
|
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)}
|
letter in enumerate(ascii_uppercase, start=10)}
|
||||||
data = data.upper()
|
data = data.upper()
|
||||||
data = [LETTERS[char] for char in data if char in LETTERS]
|
data = [LETTERS[char] for char in data if char in LETTERS]
|
||||||
print(data)
|
print(data)
|
||||||
return ''.join(data)
|
return ''.join(data)
|
||||||
|
|
||||||
def validate(self, data):
|
def validate(self, data):
|
||||||
"""Validate value constructed by normalize"""
|
"""Validate value constructed by normalize"""
|
||||||
|
|
||||||
super().validate(data)
|
super().validate(data)
|
||||||
if int(data) % 97 != 1:
|
if int(data) % 97 != 1:
|
||||||
raise forms.ValidationError("Invalid IBAN number!")
|
raise forms.ValidationError("Invalid IBAN number!")
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
class ExpensesClaim(forms.Form):
|
class ExpensesClaim(forms.Form):
|
||||||
"""Expenses claim form"""
|
"""Expenses claim form"""
|
||||||
|
|
||||||
name = forms.CharField(label='Nimi', max_length=100)
|
name = forms.CharField(label='Nimi', max_length=100)
|
||||||
iban = IBANField(label='IBAN', max_length=100)
|
iban = IBANField(label='IBAN', max_length=100)
|
||||||
amount = forms.CharField(label="Summa", max_length=100)
|
amount = forms.CharField(label="Summa", max_length=100)
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
"""Expenses claim urls."""
|
"""Expenses claim urls."""
|
||||||
|
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from django.conf import settings
|
from .views import claim
|
||||||
from .views import *
|
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"""Expenses claim views."""
|
"""Expenses claim views."""
|
||||||
|
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.http import *
|
|
||||||
from django.views.decorators.http import require_http_methods
|
from django.views.decorators.http import require_http_methods
|
||||||
from .forms import ExpensesClaim
|
from .forms import ExpensesClaim
|
||||||
|
|
||||||
@@ -14,9 +13,8 @@ def claim(request):
|
|||||||
form = ExpensesClaim(request.POST)
|
form = ExpensesClaim(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
return HttpResponse()
|
return HttpResponse()
|
||||||
|
|
||||||
elif request.method == 'GET':
|
elif request.method == 'GET':
|
||||||
form = ExpensesClaim()
|
form = ExpensesClaim()
|
||||||
|
|
||||||
return render(request, 'claim.html', {'form': form})
|
return render(request, 'claim.html', {'form': form})
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
[pycodestyle]
|
[pycodestyle]
|
||||||
max-line-length = 120
|
max-line-length = 120
|
||||||
ignore = E501,E722
|
ignore = E501,E722
|
||||||
exclude = '*/migrations/*'
|
exclude = '*/migrations/*', venv/*
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ urlpatterns = [
|
|||||||
url(r'^kaehmy/', include('kaehmy.urls')),
|
url(r'^kaehmy/', include('kaehmy.urls')),
|
||||||
url(r'^ohlhafv/', include('ohlhafv.urls')),
|
url(r'^ohlhafv/', include('ohlhafv.urls')),
|
||||||
url(r'^expenses/', include('expenses_claim.urls')),
|
url(r'^expenses/', include('expenses_claim.urls')),
|
||||||
|
|
||||||
# favourite icon
|
# favourite icon
|
||||||
url(r'^favicon\.ico$', favicon_view),
|
url(r'^favicon\.ico$', favicon_view),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user