python-terminusgps 33.0.0__py3-none-any.whl → 33.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_terminusgps-33.0.0.dist-info → python_terminusgps-33.1.0.dist-info}/METADATA +1 -1
- {python_terminusgps-33.0.0.dist-info → python_terminusgps-33.1.0.dist-info}/RECORD +5 -4
- terminusgps/django/forms.py +139 -0
- {python_terminusgps-33.0.0.dist-info → python_terminusgps-33.1.0.dist-info}/WHEEL +0 -0
- {python_terminusgps-33.0.0.dist-info → python_terminusgps-33.1.0.dist-info}/licenses/COPYING +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-terminusgps
|
|
3
|
-
Version: 33.
|
|
3
|
+
Version: 33.1.0
|
|
4
4
|
Summary: Provides abstractions/utilities for working with Wialon API, Authorize.NET API, AWS API, and more.
|
|
5
5
|
Project-URL: Documentation, https://docs.terminusgps.com
|
|
6
6
|
Project-URL: Repository, https://github.com/terminusgps/python-terminusgps
|
|
@@ -19,6 +19,7 @@ terminusgps/aws/connect.py,sha256=TWf2bVz6LqSNQfVD7FKRn3K71VuLOwBj05Gs-9BsROg,69
|
|
|
19
19
|
terminusgps/aws/secrets.py,sha256=MxQEmmBLpMUQ2tYAsHdCYf-7RZ84LiogdKcTsACX5dw,361
|
|
20
20
|
terminusgps/aws/utils.py,sha256=68GWcllu4h41qzFiKdUkWOAA4LDsTPqRY446VRMxYsY,116
|
|
21
21
|
terminusgps/django/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
+
terminusgps/django/forms.py,sha256=47z0NWtA1edkHviVmmpwmG-ofxU6j36BCRzO3UW3aek,4989
|
|
22
23
|
terminusgps/django/mixins.py,sha256=Q9ZJuzpk3d9lDnlVA8ZTVvnZWxB13p08EQ8yVJcztn4,1034
|
|
23
24
|
terminusgps/django/settings.py,sha256=yJIcBE0xjY60AXF_gonY5hS3ofseqPW2k9uSoELgoho,639
|
|
24
25
|
terminusgps/django/utils.py,sha256=SYDQyHA5tTuVwdpZGsCtf0LpTTD0ilRKoxa8StfSTpQ,156
|
|
@@ -46,7 +47,7 @@ terminusgps/wialon/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
|
46
47
|
terminusgps/wialon/tests/test_items.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
47
48
|
terminusgps/wialon/tests/test_session.py,sha256=9mBlYchMo9NeqRIZsmxYzrM1zBHorqu4ooxqSNppLpI,1336
|
|
48
49
|
terminusgps/wialon/tests/test_utils.py,sha256=SK4PxJQGECFnzx_EQeRAQfsQ5_3FLaVcis2W9u_ibuI,1730
|
|
49
|
-
python_terminusgps-33.
|
|
50
|
-
python_terminusgps-33.
|
|
51
|
-
python_terminusgps-33.
|
|
52
|
-
python_terminusgps-33.
|
|
50
|
+
python_terminusgps-33.1.0.dist-info/METADATA,sha256=K_96np1Rmj8DPiPs4pxWKQygqzSkHm7Zzlloa2y8hNc,1581
|
|
51
|
+
python_terminusgps-33.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
52
|
+
python_terminusgps-33.1.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
53
|
+
python_terminusgps-33.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
from collections.abc import Sequence
|
|
2
|
+
|
|
3
|
+
from authorizenet import apicontractsv1
|
|
4
|
+
from django import forms
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class CreditCardWidget(forms.widgets.MultiWidget):
|
|
8
|
+
def __init__(self, widgets=(), attrs: dict | None = None) -> None:
|
|
9
|
+
if not widgets:
|
|
10
|
+
widgets = [
|
|
11
|
+
forms.TextInput(attrs=attrs),
|
|
12
|
+
forms.TextInput(attrs=attrs),
|
|
13
|
+
forms.TextInput(attrs=attrs),
|
|
14
|
+
forms.TextInput(attrs=attrs),
|
|
15
|
+
]
|
|
16
|
+
super().__init__(widgets=widgets, attrs=attrs)
|
|
17
|
+
|
|
18
|
+
def decompress(
|
|
19
|
+
self, value: apicontractsv1.creditCardType | None
|
|
20
|
+
) -> list[str | None]:
|
|
21
|
+
"""Decompresses a :py:attr:`~authorizenet.apicontractsv1.creditCardType` into a list of strings."""
|
|
22
|
+
if value is None:
|
|
23
|
+
return [None, None, None, None]
|
|
24
|
+
|
|
25
|
+
expiry_parts = value.expirationDate.split("-")
|
|
26
|
+
return [value.cardNumber, expiry_parts[0], expiry_parts[1], value.cardCode]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class AddressWidget(forms.widgets.MultiWidget):
|
|
30
|
+
def __init__(self, widgets=(), attrs: dict | None = None) -> None:
|
|
31
|
+
if not widgets:
|
|
32
|
+
widgets = [
|
|
33
|
+
forms.TextInput(attrs=attrs),
|
|
34
|
+
forms.TextInput(attrs=attrs),
|
|
35
|
+
forms.TextInput(attrs=attrs),
|
|
36
|
+
forms.TextInput(attrs=attrs),
|
|
37
|
+
forms.TextInput(attrs=attrs),
|
|
38
|
+
]
|
|
39
|
+
super().__init__(widgets=widgets, attrs=attrs)
|
|
40
|
+
|
|
41
|
+
def decompress(
|
|
42
|
+
self, value: apicontractsv1.customerAddressType | None
|
|
43
|
+
) -> list[str | None]:
|
|
44
|
+
"""Decompresses a :py:attr:`~authorizenet.apicontractsv1.customerAddressType` into a list of strings."""
|
|
45
|
+
if value is None:
|
|
46
|
+
return [None, None, None, None, None]
|
|
47
|
+
|
|
48
|
+
return [value.address, value.city, value.state, value.country, value.zip]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class CreditCardField(forms.MultiValueField):
|
|
52
|
+
require_all_fields = True
|
|
53
|
+
|
|
54
|
+
def __init__(self, fields=(), widget=CreditCardWidget(), *args, **kwargs) -> None:
|
|
55
|
+
if not fields:
|
|
56
|
+
fields = (
|
|
57
|
+
forms.CharField(label="Card #"),
|
|
58
|
+
forms.IntegerField(label="Expiry Month", min_value=1, max_value=12),
|
|
59
|
+
forms.IntegerField(label="Expiry Year"),
|
|
60
|
+
forms.CharField(label="CCV #"),
|
|
61
|
+
)
|
|
62
|
+
super().__init__(fields=fields, widget=widget, *args, **kwargs)
|
|
63
|
+
|
|
64
|
+
def compress(self, data_list: Sequence[str]) -> apicontractsv1.creditCardType:
|
|
65
|
+
"""Compresses ``data_list`` into a :py:obj:`~authorizenet.apicontractsv1.creditCardType`."""
|
|
66
|
+
return apicontractsv1.creditCardType(
|
|
67
|
+
**{
|
|
68
|
+
"cardNumber": data_list[0],
|
|
69
|
+
"expirationDate": f"{data_list[1]}-{data_list[2]}",
|
|
70
|
+
"cardCode": data_list[3],
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class AddressField(forms.MultiValueField):
|
|
76
|
+
require_all_fields = True
|
|
77
|
+
|
|
78
|
+
def __init__(self, fields=(), widget=AddressWidget(), *args, **kwargs) -> None:
|
|
79
|
+
if not fields:
|
|
80
|
+
fields = (
|
|
81
|
+
forms.CharField(label="Street", max_length=128),
|
|
82
|
+
forms.CharField(label="City", max_length=128),
|
|
83
|
+
forms.CharField(label="State", max_length=64),
|
|
84
|
+
forms.CharField(label="Zip #", min_length=5, max_length=10),
|
|
85
|
+
forms.CharField(label="Country", max_length=2),
|
|
86
|
+
)
|
|
87
|
+
super().__init__(fields=fields, widget=widget, *args, **kwargs)
|
|
88
|
+
|
|
89
|
+
def compress(self, data_list: Sequence[str]) -> apicontractsv1.customerAddressType:
|
|
90
|
+
"""Compresses ``data_list`` into a :py:obj:`~authorizenet.apicontractsv1.customerAddressType`."""
|
|
91
|
+
return apicontractsv1.customerAddressType(
|
|
92
|
+
**{
|
|
93
|
+
"address": data_list[0],
|
|
94
|
+
"city": data_list[1],
|
|
95
|
+
"state": data_list[2],
|
|
96
|
+
"zip": data_list[3],
|
|
97
|
+
"country": data_list[4],
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def main() -> None:
|
|
103
|
+
import os
|
|
104
|
+
|
|
105
|
+
import django
|
|
106
|
+
|
|
107
|
+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "terminusgps.django.settings")
|
|
108
|
+
django.setup()
|
|
109
|
+
|
|
110
|
+
class TestForm(forms.Form):
|
|
111
|
+
first_name = forms.CharField(label="First Name")
|
|
112
|
+
last_name = forms.CharField(label="Last Name")
|
|
113
|
+
phone = forms.CharField(label="Phone #")
|
|
114
|
+
address = AddressField(label="Address")
|
|
115
|
+
credit_card = CreditCardField(label="Credit Card")
|
|
116
|
+
|
|
117
|
+
form_data = {
|
|
118
|
+
"first_name": "TestFirst",
|
|
119
|
+
"last_name": "TestLast",
|
|
120
|
+
"phone": "555-555-5555",
|
|
121
|
+
"address_0": "123 Main St.",
|
|
122
|
+
"address_1": "Houston",
|
|
123
|
+
"address_2": "Texas",
|
|
124
|
+
"address_3": "77065",
|
|
125
|
+
"address_4": "US",
|
|
126
|
+
"credit_card_0": "4111111111111111",
|
|
127
|
+
"credit_card_1": "1",
|
|
128
|
+
"credit_card_2": "41",
|
|
129
|
+
"credit_card_3": "444",
|
|
130
|
+
}
|
|
131
|
+
form = TestForm(form_data)
|
|
132
|
+
print(f"{form.is_valid() = }")
|
|
133
|
+
print(f"{form.errors = }")
|
|
134
|
+
print(f"{type(form.clean()["address"]) = }")
|
|
135
|
+
print(f"{type(form.clean()["credit_card"]) = }")
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
if __name__ == "__main__":
|
|
139
|
+
main()
|
|
File without changes
|
{python_terminusgps-33.0.0.dist-info → python_terminusgps-33.1.0.dist-info}/licenses/COPYING
RENAMED
|
File without changes
|