Skip to content

Commit 2a93378

Browse files
author
Mikhail Pyrev
committed
Add capitalist account number validator
1 parent 87191f4 commit 2a93378

File tree

5 files changed

+161
-1
lines changed

5 files changed

+161
-1
lines changed

MANIFEST.in

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include INSTALL
2+
include LICENSE.md
3+
include MANIFEST.in
4+
include README.md
5+
recursive-include *.py
6+
recursive-include capitalist/contrib/django/django_capitalist/locale *
7+
global-exclude __pycache__ *.pyc
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# SOME DESCRIPTIVE TITLE.
2+
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3+
# This file is distributed under the same license as the PACKAGE package.
4+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5+
#
6+
#, fuzzy
7+
msgid ""
8+
msgstr ""
9+
"Project-Id-Version: PACKAGE VERSION\n"
10+
"Report-Msgid-Bugs-To: \n"
11+
"POT-Creation-Date: 2020-05-27 15:22+0300\n"
12+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14+
"Language-Team: LANGUAGE <[email protected]>\n"
15+
"Language: \n"
16+
"MIME-Version: 1.0\n"
17+
"Content-Type: text/plain; charset=UTF-8\n"
18+
"Content-Transfer-Encoding: 8bit\n"
19+
"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
20+
"%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n"
21+
"%100>=11 && n%100<=14)? 2 : 3);\n"
22+
23+
#: apps.py:7
24+
msgid "Capitalist"
25+
msgstr ""
26+
27+
#: models.py:9
28+
msgid "ISO code"
29+
msgstr ""
30+
31+
#: models.py:12 models.py:30
32+
msgid "currency"
33+
msgstr ""
34+
35+
#: models.py:13
36+
msgid "currencies"
37+
msgstr ""
38+
39+
#: models.py:26
40+
msgid "unique number"
41+
msgstr ""
42+
43+
#: models.py:27
44+
msgid "name"
45+
msgstr ""
46+
47+
#: models.py:28
48+
msgid "balance"
49+
msgstr ""
50+
51+
#: models.py:29
52+
msgid "blocked amount"
53+
msgstr ""
54+
55+
#: models.py:33
56+
msgid "account"
57+
msgstr ""
58+
59+
#: models.py:34
60+
msgid "accounts"
61+
msgstr ""
62+
63+
#: models.py:41
64+
msgid "batch ID"
65+
msgstr ""
66+
67+
#: models.py:42 models.py:77
68+
msgid "created at"
69+
msgstr ""
70+
71+
#: models.py:43 models.py:78
72+
msgid "updated at"
73+
msgstr ""
74+
75+
#: models.py:51 models.py:73
76+
msgid "batch"
77+
msgstr ""
78+
79+
#: models.py:52
80+
msgid "batches"
81+
msgstr ""
82+
83+
#: models.py:66
84+
msgid "New"
85+
msgstr ""
86+
87+
#: models.py:67
88+
msgid "Ready"
89+
msgstr ""
90+
91+
#: models.py:68
92+
msgid "In process"
93+
msgstr ""
94+
95+
#: models.py:69
96+
msgid "Declined"
97+
msgstr ""
98+
99+
#: models.py:70
100+
msgid "Processed"
101+
msgstr ""
102+
103+
#: models.py:74
104+
msgid "status"
105+
msgstr ""
106+
107+
#: models.py:75
108+
msgid "record data (CSV)"
109+
msgstr ""
110+
111+
#: models.py:76
112+
msgid "internal ID"
113+
msgstr ""
114+
115+
#: models.py:86
116+
msgid "batch record"
117+
msgstr ""
118+
119+
#: models.py:87
120+
msgid "batch records"
121+
msgstr ""
122+
123+
#: validators.py:8
124+
msgid "Invalid Capitalist account number."
125+
msgstr "Некорректный номер счёта Capitalist."
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from django.core.exceptions import ValidationError
2+
from django.utils.deconstruct import deconstructible
3+
from django.utils.translation import gettext_lazy as _
4+
5+
6+
@deconstructible
7+
class CapitalistAccountValidator:
8+
message = _('Invalid Capitalist account number.')
9+
code = 'invalid_capitalist_account'
10+
account_types = (
11+
'R', # rub
12+
'U', # usd
13+
'E', # eur
14+
'T', # usd tether
15+
'B', # btc
16+
)
17+
18+
def __init__(self, account_types=None):
19+
self.account_types = account_types
20+
21+
def __call__(self, value):
22+
if len(value) < 2 or value[0] not in self.account_types:
23+
raise ValidationError(self.message, code=self.code)
24+
try:
25+
int(value[1:])
26+
except ValueError:
27+
raise ValidationError(self.message, code=self.code)

setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
# For a discussion on single-sourcing the version across setup.py and the
4444
# project code, see
4545
# https://packaging.python.org/en/latest/single_source_version.html
46-
version='1.2.3', # Required
46+
version='1.2.4', # Required
4747

4848
# This is a one-line description or tagline of what your project does. This
4949
# corresponds to the "Summary" metadata field:
@@ -164,6 +164,7 @@
164164
#
165165
# If using Python 2.6 or earlier, then these have to be included in
166166
# MANIFEST.in as well.
167+
include_package_data=True,
167168
package_data={ # Optional
168169
# 'sample': ['package_data.dat'],
169170
},

0 commit comments

Comments
 (0)