Skip to content

Commit

Permalink
fix: example
Browse files Browse the repository at this point in the history
  • Loading branch information
long2ice committed May 24, 2024
1 parent e4a4cd5 commit 66b69c2
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 48 deletions.
6 changes: 3 additions & 3 deletions examples/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from contextlib import asynccontextmanager

import redis.asyncio as redis
import uvicorn
Expand Down Expand Up @@ -46,6 +47,7 @@ async def lifespan(app: FastAPI):
],
redis=r,
)
yield


def create_app():
Expand All @@ -60,9 +62,7 @@ def create_app():
async def index():
return RedirectResponse(url="/admin")

admin_app.add_exception_handler(
HTTP_500_INTERNAL_SERVER_ERROR, server_error_exception
)
admin_app.add_exception_handler(HTTP_500_INTERNAL_SERVER_ERROR, server_error_exception)
admin_app.add_exception_handler(HTTP_404_NOT_FOUND, not_found_error_exception)
admin_app.add_exception_handler(HTTP_403_FORBIDDEN, forbidden_error_exception)
admin_app.add_exception_handler(HTTP_401_UNAUTHORIZED, unauthorized_error_exception)
Expand Down
2 changes: 1 addition & 1 deletion fastapi_admin/providers/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async def authenticate(
request: Request,
call_next: RequestResponseEndpoint,
):
redis = request.app.redis # type:Redis
redis = request.app.redis # type:ignore
token = request.cookies.get(self.access_token)
path = request.scope["path"]
admin = None
Expand Down
88 changes: 44 additions & 44 deletions fastapi_admin/widgets/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Input(Widget):
template = "widgets/inputs/input.html"

def __init__(
self, help_text: Optional[str] = None, default: Any = None, null: bool = False, **context
self, help_text: Optional[str] = None, default: Any = None, null: bool = False, **context
):
super().__init__(null=null, help_text=help_text, **context)
self.default = default
Expand Down Expand Up @@ -44,12 +44,12 @@ class Text(Input):
input_type: Optional[str] = "text"

def __init__(
self,
help_text: Optional[str] = None,
default: Any = None,
null: bool = False,
placeholder: str = "",
disabled: bool = False,
self,
help_text: Optional[str] = None,
default: Any = None,
null: bool = False,
placeholder: str = "",
disabled: bool = False,
):
super().__init__(
null=null,
Expand All @@ -65,11 +65,11 @@ class Select(Input):
template = "widgets/inputs/select.html"

def __init__(
self,
help_text: Optional[str] = None,
default: Any = None,
null: bool = False,
disabled: bool = False,
self,
help_text: Optional[str] = None,
default: Any = None,
null: bool = False,
disabled: bool = False,
):
super().__init__(help_text=help_text, null=null, default=default, disabled=disabled)

Expand All @@ -91,12 +91,12 @@ async def render(self, request: Request, value: Any):

class ForeignKey(Select):
def __init__(
self,
model: Type[Model],
default: Any = None,
null: bool = False,
disabled: bool = False,
help_text: Optional[str] = None,
self,
model: Type[Model],
default: Any = None,
null: bool = False,
disabled: bool = False,
help_text: Optional[str] = None,
):
super().__init__(help_text=help_text, default=default, null=null, disabled=disabled)
self.model = model
Expand All @@ -116,10 +116,10 @@ class ManyToMany(Select):
template = "widgets/inputs/many_to_many.html"

def __init__(
self,
model: Type[Model],
disabled: bool = False,
help_text: Optional[str] = None,
self,
model: Type[Model],
disabled: bool = False,
help_text: Optional[str] = None,
):
super().__init__(help_text=help_text, disabled=disabled)
self.model = model
Expand All @@ -144,13 +144,13 @@ async def render(self, request: Request, value: Any):

class Enum(Select):
def __init__(
self,
enum: Type[EnumCLS],
default: Any = None,
enum_type: Type = int,
null: bool = False,
disabled: bool = False,
help_text: Optional[str] = None,
self,
enum: Type[EnumCLS],
default: Any = None,
enum_type: Type = int,
null: bool = False,
disabled: bool = False,
help_text: Optional[str] = None,
):
super().__init__(help_text=help_text, default=default, null=null, disabled=disabled)
self.enum = enum
Expand All @@ -174,10 +174,10 @@ class Json(Input):
template = "widgets/inputs/json.html"

def __init__(
self,
help_text: Optional[str] = None,
null: bool = False,
options: Optional[dict] = None,
self,
help_text: Optional[str] = None,
null: bool = False,
options: Optional[dict] = None,
):
"""
options config to jsoneditor, see https://github.com/josdejong/jsoneditor
Expand Down Expand Up @@ -215,12 +215,12 @@ class File(Input):
input_type = "file"

def __init__(
self,
upload: FileUpload,
default: Any = None,
null: bool = False,
disabled: bool = False,
help_text: Optional[str] = None,
self,
upload: FileUpload,
default: Any = None,
null: bool = False,
disabled: bool = False,
help_text: Optional[str] = None,
):
super().__init__(
null=null,
Expand All @@ -246,11 +246,11 @@ class Radio(Select):
template = "widgets/inputs/radio.html"

def __init__(
self,
options: List[Tuple[str, Any]],
help_text: Optional[str] = None,
default: Any = None,
disabled: bool = False,
self,
options: List[Tuple[str, Any]],
help_text: Optional[str] = None,
default: Any = None,
disabled: bool = False,
):
super().__init__(default=default, disabled=disabled, help_text=help_text)
self.options = options
Expand Down

0 comments on commit 66b69c2

Please sign in to comment.