ohmyapi 0.4.3__tar.gz → 0.4.5__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.
Files changed (32) hide show
  1. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/PKG-INFO +1 -1
  2. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/pyproject.toml +1 -1
  3. ohmyapi-0.4.5/src/ohmyapi/__init__.py +1 -0
  4. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/builtin/auth/routes.py +7 -1
  5. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/core/runtime.py +5 -2
  6. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/db/__init__.py +1 -0
  7. ohmyapi-0.4.3/src/ohmyapi/__init__.py +0 -1
  8. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/README.md +0 -0
  9. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/__main__.py +0 -0
  10. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/builtin/auth/__init__.py +0 -0
  11. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/builtin/auth/models.py +0 -0
  12. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/builtin/auth/permissions.py +0 -0
  13. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/builtin/demo/__init__.py +0 -0
  14. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/builtin/demo/models.py +0 -0
  15. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/builtin/demo/routes.py +0 -0
  16. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/cli.py +0 -0
  17. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/core/__init__.py +0 -0
  18. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/core/logging.py +0 -0
  19. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/core/scaffolding.py +0 -0
  20. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/core/templates/app/__init__.py.j2 +0 -0
  21. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/core/templates/app/models.py.j2 +0 -0
  22. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/core/templates/app/routes.py.j2 +0 -0
  23. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/core/templates/docker/Dockerfile +0 -0
  24. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/core/templates/docker/docker-compose.yml +0 -0
  25. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/core/templates/project/README.md.j2 +0 -0
  26. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/core/templates/project/pyproject.toml.j2 +0 -0
  27. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/core/templates/project/settings.py.j2 +0 -0
  28. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/db/exceptions.py +0 -0
  29. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/db/model/__init__.py +0 -0
  30. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/db/model/model.py +0 -0
  31. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/middleware/cors.py +0 -0
  32. {ohmyapi-0.4.3 → ohmyapi-0.4.5}/src/ohmyapi/router.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ohmyapi
3
- Version: 0.4.3
3
+ Version: 0.4.5
4
4
  Summary: Django-flavored scaffolding and management layer around FastAPI, Pydantic, TortoiseORM and Aerich migrations
5
5
  License-Expression: MIT
6
6
  Keywords: fastapi,tortoise,orm,pydantic,async,web-framework
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ohmyapi"
3
- version = "0.4.3"
3
+ version = "0.4.5"
4
4
  description = "Django-flavored scaffolding and management layer around FastAPI, Pydantic, TortoiseORM and Aerich migrations"
5
5
  license = "MIT"
6
6
  keywords = ["fastapi", "tortoise", "orm", "pydantic", "async", "web-framework"]
@@ -0,0 +1 @@
1
+ __VERSION__ = "0.4.5"
@@ -1,6 +1,6 @@
1
1
  import time
2
2
  from enum import Enum
3
- from typing import Any, Dict, List
3
+ from typing import Any, Dict, List, Optional
4
4
 
5
5
  import jwt
6
6
  import settings
@@ -124,6 +124,12 @@ async def get_current_user(token: str = Depends(oauth2_scheme)) -> User:
124
124
  return user
125
125
 
126
126
 
127
+ async def optionally_authenticated(token: Optional[str] = Depends(oauth2_scheme)) -> Optional[User]:
128
+ if token is None:
129
+ return None
130
+ return await get_current_user(token)
131
+
132
+
127
133
  async def require_authenticated(current_user: User = Depends(get_current_user)) -> User:
128
134
  """Ensure the current user is an admin."""
129
135
  if not current_user:
@@ -154,7 +154,10 @@ class Project:
154
154
  tortoise_cfg = self.build_tortoise_config(db_url=db_url)
155
155
 
156
156
  # Prevent leaking other app's models to Aerich.
157
- tortoise_cfg["apps"] = {app_label: tortoise_cfg["apps"][app_label]}
157
+ if app_label in tortoise_cfg["apps"].keys():
158
+ tortoise_cfg["apps"] = {app_label: tortoise_cfg["apps"][app_label]}
159
+ else:
160
+ tortoise_cfg["apps"] = {app_label: {"default_connection": "default", "models": []}}
158
161
 
159
162
  # Append aerich.models to the models list of the target app only
160
163
  tortoise_cfg["apps"][app_label]["models"].append("aerich.models")
@@ -403,7 +406,7 @@ class App:
403
406
  """
404
407
  return {
405
408
  "models": [
406
- f"{self.name}.{m.__name__}" for m in self.models[f"{self.name}.models"]
409
+ f"{self.name}.{m.__name__}" for m in self._models[f"{self.name}.models"]
407
410
  ],
408
411
  "middlewares": self.__serialize_middleware(),
409
412
  "routes": self.__serialize_router(),
@@ -1,5 +1,6 @@
1
1
  from tortoise.expressions import Q
2
2
  from tortoise.manager import Manager
3
+ from tortoise.query_utils import Prefetch
3
4
  from tortoise.queryset import QuerySet
4
5
  from tortoise.signals import (
5
6
  post_delete,
@@ -1 +0,0 @@
1
- __VERSION__ = "0.4.3"
File without changes
File without changes
File without changes
File without changes