statezero 0.1.0b65__tar.gz → 0.1.0b67__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.
- {statezero-0.1.0b65 → statezero-0.1.0b67}/PKG-INFO +1 -1
- {statezero-0.1.0b65 → statezero-0.1.0b67}/pyproject.toml +1 -1
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/orm.py +2 -10
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/urls.py +2 -1
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/views.py +59 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero.egg-info/PKG-INFO +1 -1
- {statezero-0.1.0b65 → statezero-0.1.0b67}/README.md +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/requirements.txt +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/setup.cfg +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/__init__.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/__init__.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/__init__.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/action_serializers.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/actions.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/apps.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/config.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/context_manager.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/db_telemetry.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/event_emitters.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/exception_handler.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/extensions/__init__.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/extensions/custom_field_serializers/__init__.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/extensions/custom_field_serializers/file_fields.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/extensions/custom_field_serializers/money_field.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/extensions/custom_field_serializers/pydantic_field.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/extensions/simple_history.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/f_handler.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/helpers.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/management/commands/statezero_testserver.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/middleware.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/migrations/0001_initial.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/migrations/0002_delete_modelviewsubscription.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/migrations/__init__.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/permissions.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/query_optimizer.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/schemas.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/search_providers/__init__.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/search_providers/basic_search.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/search_providers/postgres_search.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/serializers.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/signals.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/testing.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/utils.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/core/__init__.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/core/actions.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/core/ast_parser.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/core/ast_validator.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/core/classes.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/core/config.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/core/context_storage.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/core/event_bus.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/core/event_emitters.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/core/exceptions.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/core/hook_checks.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/core/interfaces.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/core/process_request.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/core/query_cache.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/core/telemetry.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/core/types.py +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero.egg-info/SOURCES.txt +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero.egg-info/dependency_links.txt +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero.egg-info/requires.txt +0 -0
- {statezero-0.1.0b65 → statezero-0.1.0b67}/statezero.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: statezero
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.0b67
|
|
4
4
|
Summary: Connect your Python backend to a modern JavaScript SPA frontend with 90% less complexity.
|
|
5
5
|
Author-email: Robert <robert.herring@statezero.dev>
|
|
6
6
|
Project-URL: homepage, https://www.statezero.dev
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "statezero"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.0b67"
|
|
8
8
|
description = "Connect your Python backend to a modern JavaScript SPA frontend with 90% less complexity."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { file = "LICENSE" }
|
|
@@ -314,11 +314,7 @@ class DjangoORMAdapter(AbstractORMProvider):
|
|
|
314
314
|
instance = model.objects.get(q_obj)
|
|
315
315
|
|
|
316
316
|
# Check object-level permissions for update.
|
|
317
|
-
|
|
318
|
-
perm = perm_cls()
|
|
319
|
-
allowed = perm.allowed_object_actions(req, instance, model)
|
|
320
|
-
if ActionType.UPDATE not in allowed:
|
|
321
|
-
raise PermissionDenied(f"Update not permitted on {instance}")
|
|
317
|
+
check_object_permissions(req, instance, ActionType.UPDATE, permissions, model)
|
|
322
318
|
|
|
323
319
|
# Use the provided serializer's save method for the update
|
|
324
320
|
return serializer.save(
|
|
@@ -347,11 +343,7 @@ class DjangoORMAdapter(AbstractORMProvider):
|
|
|
347
343
|
instance = model.objects.get(q_obj)
|
|
348
344
|
|
|
349
345
|
# Check object-level permissions.
|
|
350
|
-
|
|
351
|
-
perm = perm_cls()
|
|
352
|
-
allowed = perm.allowed_object_actions(req, instance, model)
|
|
353
|
-
if ActionType.DELETE not in allowed:
|
|
354
|
-
raise PermissionDenied(f"Delete not permitted on {instance}")
|
|
346
|
+
check_object_permissions(req, instance, ActionType.DELETE, permissions, model)
|
|
355
347
|
|
|
356
348
|
instance.delete()
|
|
357
349
|
return 1
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
from django.urls import path
|
|
2
2
|
|
|
3
|
-
from .views import EventsAuthView, ModelListView, ModelView, SchemaView, FileUploadView, FastUploadView, ActionSchemaView, ActionView, ValidateView, FieldPermissionsView
|
|
3
|
+
from .views import EventsAuthView, ModelListView, MeView, ModelView, SchemaView, FileUploadView, FastUploadView, ActionSchemaView, ActionView, ValidateView, FieldPermissionsView
|
|
4
4
|
|
|
5
5
|
app_name = "statezero"
|
|
6
6
|
|
|
7
7
|
urlpatterns = [
|
|
8
8
|
path("events/auth/", EventsAuthView.as_view(), name="events_auth"),
|
|
9
9
|
path("models/", ModelListView.as_view(), name="model_list"),
|
|
10
|
+
path("me/", MeView.as_view(), name="me"),
|
|
10
11
|
path("files/upload/", FileUploadView.as_view(), name="file_upload"),
|
|
11
12
|
path("files/fast-upload/", FastUploadView.as_view(), name="fast_file_upload"),
|
|
12
13
|
path("actions/<str:action_name>/", ActionView.as_view(), name="action"),
|
|
@@ -23,6 +23,7 @@ from statezero.adaptors.django.exception_handler import \
|
|
|
23
23
|
from statezero.adaptors.django.permissions import ORMBridgeViewAccessGate
|
|
24
24
|
from statezero.adaptors.django.actions import DjangoActionSchemaGenerator
|
|
25
25
|
from statezero.adaptors.django.action_serializers import get_or_build_action_serializer
|
|
26
|
+
from statezero.adaptors.django.serializers import DRFDynamicSerializer
|
|
26
27
|
from statezero.core.interfaces import AbstractEventEmitter, AbstractActionPermission
|
|
27
28
|
from statezero.core.process_request import RequestProcessor
|
|
28
29
|
from statezero.core.actions import action_registry
|
|
@@ -114,6 +115,64 @@ class ModelListView(APIView):
|
|
|
114
115
|
model_names.append(model_name)
|
|
115
116
|
return Response(model_names, status=status.HTTP_200_OK)
|
|
116
117
|
|
|
118
|
+
class MeView(APIView):
|
|
119
|
+
"""
|
|
120
|
+
Returns the current authenticated user as a guaranteed model summary.
|
|
121
|
+
Uses the existing StateZero serializer with only the PK field requested,
|
|
122
|
+
which includes `pk` and `repr` by design.
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
permission_classes = []
|
|
126
|
+
|
|
127
|
+
def get(self, request, *args, **kwargs):
|
|
128
|
+
try:
|
|
129
|
+
user = config.orm_provider.get_user(request)
|
|
130
|
+
if not user or not getattr(user, "is_authenticated", False):
|
|
131
|
+
raise PermissionDenied(detail="Authentication required.")
|
|
132
|
+
|
|
133
|
+
model = user.__class__
|
|
134
|
+
model_name = config.orm_provider.get_model_name(model)
|
|
135
|
+
pk_field = model._meta.pk.name
|
|
136
|
+
pk_value = getattr(user, pk_field)
|
|
137
|
+
|
|
138
|
+
fields_map = {
|
|
139
|
+
model_name: {pk_field},
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
serializer = DRFDynamicSerializer()
|
|
143
|
+
serialized = serializer.serialize(
|
|
144
|
+
data=user,
|
|
145
|
+
model=model,
|
|
146
|
+
depth=0,
|
|
147
|
+
fields_map=fields_map,
|
|
148
|
+
many=False,
|
|
149
|
+
request=request,
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
included = serialized.get("included", {})
|
|
153
|
+
user_bucket = included.get(model_name, {})
|
|
154
|
+
user_data = user_bucket.get(pk_value)
|
|
155
|
+
|
|
156
|
+
# Defensive fallback to keep the endpoint contract stable.
|
|
157
|
+
if user_data is None:
|
|
158
|
+
user_data = {
|
|
159
|
+
pk_field: pk_value,
|
|
160
|
+
"repr": {
|
|
161
|
+
"str": str(user),
|
|
162
|
+
"img": user.__img__() if hasattr(user, "__img__") else None,
|
|
163
|
+
},
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return Response(
|
|
167
|
+
{
|
|
168
|
+
"model_name": model_name,
|
|
169
|
+
"data": user_data,
|
|
170
|
+
},
|
|
171
|
+
status=status.HTTP_200_OK,
|
|
172
|
+
)
|
|
173
|
+
except Exception as original_exception:
|
|
174
|
+
return explicit_exception_handler(original_exception)
|
|
175
|
+
|
|
117
176
|
|
|
118
177
|
class ModelView(APIView):
|
|
119
178
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: statezero
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.0b67
|
|
4
4
|
Summary: Connect your Python backend to a modern JavaScript SPA frontend with 90% less complexity.
|
|
5
5
|
Author-email: Robert <robert.herring@statezero.dev>
|
|
6
6
|
Project-URL: homepage, https://www.statezero.dev
|
|
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
|
{statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/extensions/simple_history.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/migrations/0001_initial.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/search_providers/__init__.py
RENAMED
|
File without changes
|
{statezero-0.1.0b65 → statezero-0.1.0b67}/statezero/adaptors/django/search_providers/basic_search.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|