Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
klen committed Jul 11, 2024
2 parents 3bdecb4 + db60ae6 commit 019f94a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "muffin-admin",
"version": "3.8.0",
"version": "3.8.1",
"description": "NPM package for https://github.com/klen/muffin-admin",
"files": [
"src",
Expand Down
8 changes: 4 additions & 4 deletions muffin_admin/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def to_ra(cls) -> Dict[str, Any]:
for source in meta.actions:
info = dict(source)
if info.get("schema"):
_, inputs = cls.to_ra_schema(info["schema"])
_, inputs = cls.to_ra_schema(info["schema"], resource=False)
info["schema"] = inputs
actions.append(info)

Expand Down Expand Up @@ -222,7 +222,7 @@ def to_ra(cls) -> Dict[str, Any]:
return data

@classmethod
def to_ra_schema(cls, schema_cls: Type[ma.Schema]):
def to_ra_schema(cls, schema_cls: Type[ma.Schema], *, resource: bool = True):
meta = cls.meta
schema_opts = schema_cls.opts
schema_fields = schema_opts.fields
Expand Down Expand Up @@ -261,7 +261,7 @@ def to_ra_schema(cls, schema_cls: Type[ma.Schema]):
input_info = (
inputs_customize[source]
if source in inputs_customize
else cls.to_ra_input(field, source)
else cls.to_ra_input(field, source, resource=resource)
)
if isinstance(input_info, str):
input_info = input_info, {}
Expand All @@ -287,7 +287,7 @@ def to_ra_field(cls, field: ma.fields.Field, source: str) -> TRAInfo:
return converter(field)

@classmethod
def to_ra_input(cls, field: ma.fields.Field, _: str) -> TRAInfo:
def to_ra_input(cls, field: ma.fields.Field, source: str, *, resource: bool = True) -> TRAInfo:
"""Convert a field to react-admin."""
converter = find_ra(field, MA_TO_RAI)
rtype, props = converter(field)
Expand Down
4 changes: 2 additions & 2 deletions muffin_admin/peewee/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ def to_ra_field(cls, field: ma.fields.Field, source: str) -> TRAInfo:
return super(PWAdminHandler, cls).to_ra_field(field, source)

@classmethod
def to_ra_input(cls, field: ma.fields.Field, source: str) -> TRAInfo:
def to_ra_input(cls, field: ma.fields.Field, source: str, *, resource: bool = True) -> TRAInfo:
"""Setup RA inputs."""
model_field = getattr(cls.meta.model, field.attribute or source, None)
model_field = resource and getattr(cls.meta.model, field.attribute or source, None)
ra_type, props = super(PWAdminHandler, cls).to_ra_input(field, source)
refs = dict(cls.meta.ra_refs)
if model_field:
Expand Down
2 changes: 1 addition & 1 deletion muffin_admin/sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def to_ra_field(cls, field: ma.fields.Field, source: str) -> TRAInfo:
return super(SAAdminHandler, cls).to_ra_field(field, source)

@classmethod
def to_ra_input(cls, field: ma.fields.Field, source: str) -> TRAInfo:
def to_ra_input(cls, field: ma.fields.Field, source: str, *, resource: bool = True) -> TRAInfo:
"""Setup RA inputs."""
column = getattr(cls.meta.table.c, field.attribute or source, None)
ra_type, props = super(SAAdminHandler, cls).to_ra_input(field, source)
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "muffin-admin"
version = "3.8.0"
version = "3.8.1"
description = "Admin interface for Muffin Framework"
readme = "README.rst"
license = "MIT"
Expand Down Expand Up @@ -98,6 +98,7 @@ exclude = [".venv", "docs", "examples"]
select = ["ALL"]
ignore = [
"A003",
"ARG003",
"ANN",
"COM",
"D",
Expand Down

0 comments on commit 019f94a

Please sign in to comment.