biased 0.1.2.dev7__tar.gz → 0.1.2.dev10__tar.gz
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.
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/PKG-INFO +4 -1
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/pyproject.toml +10 -1
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/admin.py +8 -4
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/forms/pydantic_model_form_field.py +1 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/models/pydantic_model_field.py +1 -0
- biased-0.1.2.dev10/src/biased/django_jsonform/apps.py +11 -0
- biased-0.1.2.dev10/src/biased/django_jsonform/jsonform_action.py +18 -0
- biased-0.1.2.dev10/src/biased/django_jsonform/templates/admin_form_action/django_jsonform_form.html +9 -0
- biased-0.1.2.dev10/src/biased/utils/__init__.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/utils/default_json_encoder.py +1 -1
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/README.md +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/__init__.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/__init__.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/apps.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/aws_waf/__init__.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/aws_waf/aws_waf_regex_pattern.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/aws_waf/aws_waf_whitelist_middleware.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/aws_waf/url_patterns.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/dtos.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/filters/__init__.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/filters/entity_filter.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/filters/input_filter.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/forms/__init__.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/forms/json_editor_widget.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/models/__init__.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/models/bank_account.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/models/char_field.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/models/created_at_modified_at_mixin.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/models/default_money_amount_field.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/models/deleted_at_mixin.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/models/multi_select_field.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/templates/actions_change_form.html +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/templates/admin/input_filter.html +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/utils/__init__.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/utils/choices.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/utils/get_client_ip.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/utils/reverse.py +0 -0
- {biased-0.1.2.dev7/src/biased/django_redis → biased-0.1.2.dev10/src/biased/django_jsonform}/__init__.py +0 -0
- {biased-0.1.2.dev7/src/biased/dtos → biased-0.1.2.dev10/src/biased/django_redis}/__init__.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django_redis/pydantic_serializer.py +0 -0
- {biased-0.1.2.dev7/src/biased/logging → biased-0.1.2.dev10/src/biased/dtos}/__init__.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/dtos/base.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/dtos/env_file_paths.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/dtos/logging.py +0 -0
- {biased-0.1.2.dev7/src/biased/ninja → biased-0.1.2.dev10/src/biased/logging}/__init__.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/logging/dict_config.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/logging/settings.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/logging/utils.py +0 -0
- {biased-0.1.2.dev7/src/biased/structlog → biased-0.1.2.dev10/src/biased/ninja}/__init__.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/ninja/json_renderrer.py +0 -0
- {biased-0.1.2.dev7/src/biased/utils → biased-0.1.2.dev10/src/biased/structlog}/__init__.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/structlog/processors.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/structlog/structlog_json_encoder.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/types.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/utils/aba_routing_number.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/utils/attrgetter_default.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/utils/calculate_age.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/utils/filter_not_none_values.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/utils/time.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/utils/ulid.py +0 -0
- {biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/utils/uuid.py +0 -0
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: biased
|
|
3
|
-
Version: 0.1.2.
|
|
3
|
+
Version: 0.1.2.dev10
|
|
4
4
|
Summary: Various reusable components, helpers, and utilities which I would like to use in any Python project
|
|
5
5
|
Author: Dmitry Tatarkin
|
|
6
6
|
Author-email: Dmitry Tatarkin <tatarkin@gmail.com>
|
|
7
|
+
Requires-Dist: injector>=0.22.0
|
|
7
8
|
Requires-Dist: pydantic>=2
|
|
8
9
|
Requires-Dist: python-dateutil>=2.9.0.post0
|
|
9
10
|
Requires-Dist: structlog>=25.4.0
|
|
10
11
|
Requires-Dist: ulid-py>=1.1.0
|
|
11
12
|
Requires-Dist: django>=5.2.6 ; extra == 'django'
|
|
13
|
+
Requires-Dist: django-jsonform>=2.23.2 ; extra == 'django-jsonform'
|
|
12
14
|
Requires-Dist: django-redis>=6.0.0 ; extra == 'django-redis'
|
|
13
15
|
Requires-Dist: django-ninja>=1.4.3 ; extra == 'ninja'
|
|
14
16
|
Requires-Python: >=3.12
|
|
15
17
|
Provides-Extra: django
|
|
18
|
+
Provides-Extra: django-jsonform
|
|
16
19
|
Provides-Extra: django-redis
|
|
17
20
|
Provides-Extra: ninja
|
|
18
21
|
Description-Content-Type: text/markdown
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "biased"
|
|
3
|
-
version = "0.1.2.
|
|
3
|
+
version = "0.1.2.dev10"
|
|
4
4
|
description = "Various reusable components, helpers, and utilities which I would like to use in any Python project"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -8,6 +8,7 @@ authors = [
|
|
|
8
8
|
]
|
|
9
9
|
requires-python = ">=3.12"
|
|
10
10
|
dependencies = [
|
|
11
|
+
"injector>=0.22.0",
|
|
11
12
|
"pydantic>=2",
|
|
12
13
|
"python-dateutil>=2.9.0.post0",
|
|
13
14
|
"structlog>=25.4.0",
|
|
@@ -24,7 +25,15 @@ ninja = [
|
|
|
24
25
|
django-redis = [
|
|
25
26
|
"django-redis>=6.0.0",
|
|
26
27
|
]
|
|
28
|
+
django-jsonform = [
|
|
29
|
+
"django-jsonform>=2.23.2",
|
|
30
|
+
]
|
|
27
31
|
|
|
28
32
|
[build-system]
|
|
29
33
|
requires = ["uv_build>=0.8.16,<0.9.0"]
|
|
30
34
|
build-backend = "uv_build"
|
|
35
|
+
|
|
36
|
+
[dependency-groups]
|
|
37
|
+
dev = [
|
|
38
|
+
"rust-just>=1.43.0",
|
|
39
|
+
]
|
|
@@ -122,11 +122,15 @@ def html_image_tag(short_description: str, attributes: dict[str, Any] | None = N
|
|
|
122
122
|
|
|
123
123
|
|
|
124
124
|
def url_link(short_description: str, content: str = "-", target: str = "_self"):
|
|
125
|
-
def wrapper(func: Callable[[ModelAdmin, Model], dict[str, str]]):
|
|
125
|
+
def wrapper(func: Callable[[ModelAdmin, Model], dict[str, str] | None]):
|
|
126
126
|
def field_func(self, obj):
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
result = func(self, obj)
|
|
128
|
+
if result is None:
|
|
129
|
+
return content
|
|
130
|
+
else:
|
|
131
|
+
params = dict(content=content, target=target)
|
|
132
|
+
params.update(func(self, obj))
|
|
133
|
+
return format_html('<a href="{url}" target="{target}">{content}</a>', **params)
|
|
130
134
|
|
|
131
135
|
field_func.short_description = short_description
|
|
132
136
|
return field_func
|
{biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/forms/pydantic_model_form_field.py
RENAMED
|
@@ -6,6 +6,7 @@ from django.forms.fields import InvalidJSONInput
|
|
|
6
6
|
from pydantic import BaseModel
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
# Consider to use [django-pydantic-field](https://github.com/surenkov/django-pydantic-field) instead
|
|
9
10
|
class PydanticModelFormField(JSONField):
|
|
10
11
|
default_error_messages = {
|
|
11
12
|
"invalid": "Enter a valid JSON.",
|
|
@@ -7,6 +7,7 @@ from biased.django.forms.pydantic_model_form_field import PydanticModelFormField
|
|
|
7
7
|
from biased.utils.default_json_encoder import DefaultJsonEncoder
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
# Consider to use [django-pydantic-field](https://github.com/surenkov/django-pydantic-field) instead
|
|
10
11
|
class PydanticModelField(JSONField):
|
|
11
12
|
default_error_messages = {
|
|
12
13
|
"invalid": "Value must be valid JSON.",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from logging import getLogger
|
|
2
|
+
|
|
3
|
+
from django.apps import AppConfig
|
|
4
|
+
|
|
5
|
+
log = getLogger(__name__)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class BiasedDjangoJsonformConfig(AppConfig):
|
|
9
|
+
default_auto_field = "django.db.models.BigAutoField"
|
|
10
|
+
name = "biased.django_jsonform"
|
|
11
|
+
label = "biased_django_jsonform"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
from admin_form_action import Decorator, form_action
|
|
4
|
+
from django import forms
|
|
5
|
+
from django.contrib.admin import ModelAdmin
|
|
6
|
+
|
|
7
|
+
FormT = TypeVar("FormT", bound=forms.Form)
|
|
8
|
+
ModelAdminT = TypeVar("ModelAdminT", bound=ModelAdmin)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def jsonform_action[FormT: forms.Form](
|
|
12
|
+
form_class: type[FormT],
|
|
13
|
+
*,
|
|
14
|
+
template: str | None = None,
|
|
15
|
+
) -> Decorator[ModelAdminT, FormT]:
|
|
16
|
+
if template is None:
|
|
17
|
+
template = "admin_form_action/django_jsonform_form.html"
|
|
18
|
+
return form_action(form_class=form_class, template=template)
|
biased-0.1.2.dev10/src/biased/django_jsonform/templates/admin_form_action/django_jsonform_form.html
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{% extends "admin_form_action/form.html" %}
|
|
2
|
+
|
|
3
|
+
{% block extrastyle %}{{ block.super }}
|
|
4
|
+
<link rel="stylesheet" href="/static/dist/jsoneditor.min.css">
|
|
5
|
+
{% endblock %}
|
|
6
|
+
|
|
7
|
+
{% block extrahead %}{{ block.super }}
|
|
8
|
+
<script src="/static/dist/jsoneditor.min.js"></script>
|
|
9
|
+
{% endblock %}
|
|
File without changes
|
|
@@ -53,7 +53,7 @@ class DefaultJsonEncoder(JSONEncoder):
|
|
|
53
53
|
return r
|
|
54
54
|
if isinstance(o, timedelta):
|
|
55
55
|
return _duration_iso_string(o)
|
|
56
|
-
if isinstance(o,
|
|
56
|
+
if isinstance(o, Decimal | UUID | ULID | AnyUrl):
|
|
57
57
|
return str(o)
|
|
58
58
|
if isinstance(o, BaseModel):
|
|
59
59
|
return o.model_dump()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/aws_waf/aws_waf_whitelist_middleware.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/models/created_at_modified_at_mixin.py
RENAMED
|
File without changes
|
{biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/models/default_money_amount_field.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/templates/actions_change_form.html
RENAMED
|
File without changes
|
{biased-0.1.2.dev7 → biased-0.1.2.dev10}/src/biased/django/templates/admin/input_filter.html
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{biased-0.1.2.dev7/src/biased/dtos → biased-0.1.2.dev10/src/biased/django_redis}/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|