python-terminusgps 28.9.0__py3-none-any.whl → 28.11.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.

Potentially problematic release.


This version of python-terminusgps might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-terminusgps
3
- Version: 28.9.0
3
+ Version: 28.11.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://app.terminusgps.com/docs/apps/python-terminusgps/index.html
6
6
  Project-URL: Repository, https://github.com/terminusgps/python-terminusgps
@@ -1,5 +1,7 @@
1
1
  terminusgps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ terminusgps/mixins.py,sha256=r6_I9D_7cX6_ZlkYp2GySu_2gywzhvs1lePFFf3dDYA,981
2
3
  terminusgps/settings.py,sha256=vY5yNjyMu-7Ya0bIPWUvrrSLERtxHGdkfeoY4Ul6cP0,613
4
+ terminusgps/validators.py,sha256=4qGYSNXje-8SstuRsKYF9RH7-0B1v0xjRuYDHFaz9eg,2278
3
5
  terminusgps/authorizenet/__init__.py,sha256=LiGLlWNNiqS7RSOP4Apabx-b9EBYyNbxRY_a0mvJoaE,466
4
6
  terminusgps/authorizenet/auth.py,sha256=ICxPPzoUc64VbsIIemEWKrn8xjHGwbNdo2VbtaFCFss,1107
5
7
  terminusgps/authorizenet/errors.py,sha256=HG5NwVxQCtOYidVl30y49PC0Ovw5VYdsy9wTgUFMw9M,949
@@ -30,7 +32,7 @@ terminusgps/wialon/items/route.py,sha256=8SzlqNmpYVdt-ZAY--B_KHoDIHgN0Zb7KBsBWAz
30
32
  terminusgps/wialon/items/unit.py,sha256=i7sQiRu3N0XxyTHVN2RnmjYy9X48KdnZLSB18ic37w8,9363
31
33
  terminusgps/wialon/items/unit_group.py,sha256=YsYh34l2DjSKcv5SIZkEVi5FSjveGB1gxU2fwdLyvl4,4101
32
34
  terminusgps/wialon/items/user.py,sha256=PFYBie04F16YE2B5364PLxkmlTmQr4sZXpItvRBxsDc,7143
33
- python_terminusgps-28.9.0.dist-info/METADATA,sha256=ikW1QHGC85Ch9G2-99zUIpaOrYiQCOnmU8gkUy-zNTc,946
34
- python_terminusgps-28.9.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
35
- python_terminusgps-28.9.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
36
- python_terminusgps-28.9.0.dist-info/RECORD,,
35
+ python_terminusgps-28.11.0.dist-info/METADATA,sha256=EiJNW0h7a2jgPPjIEQ8bYo2BvlcAmMKqnXkuVMp6vW0,947
36
+ python_terminusgps-28.11.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
37
+ python_terminusgps-28.11.0.dist-info/licenses/COPYING,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
38
+ python_terminusgps-28.11.0.dist-info/RECORD,,
terminusgps/mixins.py ADDED
@@ -0,0 +1,34 @@
1
+ import typing
2
+
3
+ from django.http import HttpResponse
4
+ from django.views.generic.base import TemplateResponseMixin
5
+
6
+
7
+ class HtmxTemplateResponseMixin(TemplateResponseMixin):
8
+ """
9
+ Renders a partial HTML template depending on HTTP headers.
10
+
11
+ `htmx documentation <https://htmx.org/docs/>`_
12
+
13
+ """
14
+
15
+ partial_template_name: str | None = None
16
+ """
17
+ A partial template rendered by `htmx`_.
18
+
19
+ .. _htmx: https://htmx.org/docs/
20
+
21
+ :type: :py:obj:`str` | :py:obj:`None`
22
+ :value: :py:obj:`None`
23
+
24
+ """
25
+
26
+ def render_to_response(
27
+ self, context: dict[str, typing.Any], **response_kwargs: typing.Any
28
+ ) -> HttpResponse:
29
+ htmx_request = self.request.headers.get("HX-Request", False)
30
+ boosted = self.request.headers.get("HX-Boosted", False)
31
+
32
+ if htmx_request and self.partial_template_name and not boosted:
33
+ self.template_name = self.partial_template_name
34
+ return super().render_to_response(context, **response_kwargs)
@@ -0,0 +1,58 @@
1
+ import string
2
+
3
+ from django.core.exceptions import ValidationError
4
+ from django.utils.translation import gettext_lazy as _
5
+
6
+
7
+ def validate_vin_number(value: str) -> None:
8
+ """Raises :py:exec:`ValidationError` if the value is an invalid VIN number."""
9
+ if not len(value) == 17:
10
+ raise ValidationError(
11
+ _("Whoops! VIN # must be exactly 17 characters long, got %(len)s."),
12
+ code="invalid",
13
+ params={"len": len(value)},
14
+ )
15
+
16
+
17
+ def validate_wialon_password(value: str) -> None:
18
+ """Raises :py:exec:`ValidationError` if the value represents an invalid Wialon password."""
19
+ special_symbols_0: list[str] = ["!", "@", "#", "$", "%", "^", "*"]
20
+ special_symbols_1: list[str] = ["(", ")", "[", "]", "-", "_", "+"]
21
+ forbidden_symbols: list[str] = [",", ":", "&", "<", ">", "'"]
22
+ value = value.strip() if value.startswith(" ") or value.endswith(" ") else value
23
+
24
+ if len(value) < 4:
25
+ raise ValidationError(
26
+ _("Password cannot be less than 4 characters in length. Got '%(len)s'."),
27
+ code="invalid",
28
+ params={"len": len(value)},
29
+ )
30
+ if len(value) > 64:
31
+ raise ValidationError(
32
+ _(
33
+ "Password cannot be greater than 64 characters in length. Got '%(len)s'."
34
+ ),
35
+ code="invalid",
36
+ params={"len": len(value)},
37
+ )
38
+ if not any([char for char in value if char in string.ascii_uppercase]):
39
+ raise ValidationError(
40
+ _("Password must contain at least one uppercase letter."), code="invalid"
41
+ )
42
+ if not any([char for char in value if char in string.ascii_lowercase]):
43
+ raise ValidationError(
44
+ _("Password must contain at least one lowercase letter."), code="invalid"
45
+ )
46
+ if not any(
47
+ [char for char in value if char in special_symbols_0 + special_symbols_1]
48
+ ):
49
+ raise ValidationError(
50
+ _("Password must contain at least one special symbol."), code="invalid"
51
+ )
52
+ for char in value:
53
+ if char in forbidden_symbols:
54
+ raise ValidationError(
55
+ _("Password cannot contain forbidden character '%(char)s'."),
56
+ code="invalid",
57
+ params={"char": char},
58
+ )